diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-01-17 12:33:38 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-01-17 12:33:38 -0500 |
commit | 89eafa0a6c1a28331b3b3c59ba94803052c63583 (patch) | |
tree | 8ebd0885d0caded95d6c5c6d471b0c35fc16272a /cloudinit/CloudConfig/__init__.py | |
parent | 1d00c0936bfc63117493d89268da8c81611b3c40 (diff) | |
download | vyos-cloud-init-89eafa0a6c1a28331b3b3c59ba94803052c63583.tar.gz vyos-cloud-init-89eafa0a6c1a28331b3b3c59ba94803052c63583.zip |
[PATCH 1/4] Fix pylint conventions C0321 (more than one statement on a single line)
From: Juerg Haefliger <juerg.haefliger@hp.com>
Diffstat (limited to 'cloudinit/CloudConfig/__init__.py')
-rw-r--r-- | cloudinit/CloudConfig/__init__.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/cloudinit/CloudConfig/__init__.py b/cloudinit/CloudConfig/__init__.py index f5c4143c..a30940fa 100644 --- a/cloudinit/CloudConfig/__init__.py +++ b/cloudinit/CloudConfig/__init__.py @@ -49,7 +49,8 @@ class CloudConfig(): cloudinit.log.critical("Failed loading of cloud config '%s'. Continuing with empty config\n" % cfgfile) cloudinit.log.debug(traceback.format_exc() + "\n") cfg = None - if cfg is None: cfg = { } + if cfg is None: + cfg = { } try: ds_cfg = self.cloud.datasource.get_config_obj() @@ -76,7 +77,8 @@ class CloudConfig(): # reads a cloudconfig module list, returns # a 2 dimensional array suitable to pass to run_cc_modules def read_cc_modules(cfg,name): - if name not in cfg: return([]) + if name not in cfg: + return([]) module_list = [] # create 'module_list', an array of arrays # where array[0] = config @@ -126,13 +128,15 @@ def run_cc_modules(cc,module_list,log): # None if if none is given def get_output_cfg(cfg, mode="init"): ret = [ None, None ] - if not 'output' in cfg: return ret + if not 'output' in cfg: + return ret outcfg = cfg['output'] if mode in outcfg: modecfg = outcfg[mode] else: - if 'all' not in outcfg: return ret + if 'all' not in outcfg: + return ret # if there is a 'all' item in the output list # then it applies to all users of this (init, config, final) modecfg = outcfg['all'] @@ -143,7 +147,8 @@ def get_output_cfg(cfg, mode="init"): # if its a list, then we expect (stdout, stderr) if isinstance(modecfg,list): - if len(modecfg) > 0: ret[0] = modecfg[0] + if len(modecfg) > 0: + ret[0] = modecfg[0] if len(modecfg) > 1: ret[1] = modecfg[1] @@ -157,11 +162,13 @@ def get_output_cfg(cfg, mode="init"): # if err's entry == "&1", then make it same as stdout # as in shell syntax of "echo foo >/dev/null 2>&1" - if ret[1] == "&1": ret[1] = ret[0] + if ret[1] == "&1": + ret[1] = ret[0] swlist = [ ">>", ">", "|" ] for i in range(len(ret)): - if not ret[i]: continue + if not ret[i]: + continue val = ret[i].lstrip() found = False for s in swlist: @@ -191,7 +198,8 @@ def redirect_output(outfmt,errfmt, o_out=sys.stdout, o_err=sys.stderr): (mode, arg) = outfmt.split(" ",1) if mode == ">" or mode == ">>": owith = "ab" - if mode == ">": owith = "wb" + if mode == ">": + owith = "wb" new_fp = open(arg, owith) elif mode == "|": proc = subprocess.Popen(arg, shell=True, stdin=subprocess.PIPE) @@ -209,7 +217,8 @@ def redirect_output(outfmt,errfmt, o_out=sys.stdout, o_err=sys.stderr): (mode, arg) = errfmt.split(" ",1) if mode == ">" or mode == ">>": owith = "ab" - if mode == ">": owith = "wb" + if mode == ">": + owith = "wb" new_fp = open(arg, owith) elif mode == "|": proc = subprocess.Popen(arg, shell=True, stdin=subprocess.PIPE) @@ -223,13 +232,15 @@ def redirect_output(outfmt,errfmt, o_out=sys.stdout, o_err=sys.stderr): def run_per_instance(name, func, args, clear_on_fail=False): semfile = "%s/%s" % (cloudinit.get_ipath_cur("data"),name) - if os.path.exists(semfile): return + if os.path.exists(semfile): + return util.write_file(semfile,str(time.time())) try: func(*args) except: - if clear_on_fail: os.unlink(semfile) + if clear_on_fail: + os.unlink(semfile) raise # apt_get top level command (install, update...), and args to pass it |