diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-01-17 14:41:29 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-01-17 14:41:29 -0500 |
commit | 15e3241ba725a21604e0f3570e755a91b5edba00 (patch) | |
tree | d84be61c3a56ddc03eb927d5de5433afacadf64b /cloud-init-cfg.py | |
parent | 2f7227c7092ad873757167f62c2a82fb4ee69472 (diff) | |
download | vyos-cloud-init-15e3241ba725a21604e0f3570e755a91b5edba00.tar.gz vyos-cloud-init-15e3241ba725a21604e0f3570e755a91b5edba00.zip |
[PATCH] PEP8 coding style fixes.
From: Juerg Haefliger <juerg.haefliger@hp.com>
This pulls in the named patch for LP: #914739 with a few other changes.
Diffstat (limited to 'cloud-init-cfg.py')
-rwxr-xr-x | cloud-init-cfg.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/cloud-init-cfg.py b/cloud-init-cfg.py index 37fe6398..def9583a 100755 --- a/cloud-init-cfg.py +++ b/cloud-init-cfg.py @@ -24,9 +24,11 @@ import cloudinit.CloudConfig as CC import logging import os -def Usage(out = sys.stdout): + +def Usage(out=sys.stdout): out.write("Usage: %s name\n" % sys.argv[0]) - + + def main(): # expect to be called with # name [ freq [ args ] @@ -38,7 +40,7 @@ def main(): util.close_stdin() modename = "config" - + if len(sys.argv) < 2: Usage(sys.stderr) sys.exit(1) @@ -59,10 +61,10 @@ def main(): cfg_path = cloudinit.get_ipath_cur("cloud_config") cfg_env_name = cloudinit.cfg_env_name - if os.environ.has_key(cfg_env_name): + if cfg_env_name in os.environ: cfg_path = os.environ[cfg_env_name] - cloud = cloudinit.CloudInit(ds_deps=[]) # ds_deps=[], get only cached + cloud = cloudinit.CloudInit(ds_deps=[]) # ds_deps=[], get only cached try: cloud.get_data_source() except cloudinit.DataSourceNotFoundException as e: @@ -81,7 +83,7 @@ def main(): log = logging.getLogger() log.info("cloud-init-cfg %s" % sys.argv[1:]) - module_list = [ ] + module_list = [] if name == "all": modlist_cfg_name = "cloud_%s_modules" % modename module_list = CC.read_cc_modules(cc.cfg, modlist_cfg_name) @@ -89,18 +91,20 @@ def main(): err("no modules to run in cloud_config [%s]" % modename, log) sys.exit(0) else: - module_list.append( [ name, freq ] + run_args ) + module_list.append([name, freq] + run_args) failures = CC.run_cc_modules(cc, module_list, log) if len(failures): err("errors running cloud_config [%s]: %s" % (modename, failures), log) sys.exit(len(failures)) + def err(msg, log=None): if log: log.error(msg) sys.stderr.write(msg + "\n") + def fail(msg, log=None): err(msg, log) sys.exit(1) |