summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-01-17 12:34:19 -0500
committerScott Moser <smoser@ubuntu.com>2012-01-17 12:34:19 -0500
commitc33eedb47b2b22c797051da197fd80e74f1db179 (patch)
treef1958cfc36e53fc406fea4963b1305f760570847
parent89eafa0a6c1a28331b3b3c59ba94803052c63583 (diff)
downloadvyos-cloud-init-c33eedb47b2b22c797051da197fd80e74f1db179.tar.gz
vyos-cloud-init-c33eedb47b2b22c797051da197fd80e74f1db179.zip
[PATCH 2/4] Fix pylint conventions C0322 (operator not preceded by a space)
From: Juerg Haefliger <juerg.haefliger@hp.com>
-rwxr-xr-xcloud-init-cfg.py4
-rwxr-xr-xcloud-init.py4
-rw-r--r--cloudinit/CloudConfig/__init__.py11
-rw-r--r--cloudinit/CloudConfig/cc_apt_update_upgrade.py22
-rw-r--r--cloudinit/CloudConfig/cc_bootcmd.py4
-rw-r--r--cloudinit/CloudConfig/cc_disable_ec2_metadata.py2
-rw-r--r--cloudinit/CloudConfig/cc_final_message.py4
-rw-r--r--cloudinit/CloudConfig/cc_grub_dpkg.py14
-rw-r--r--cloudinit/CloudConfig/cc_mounts.py8
-rw-r--r--cloudinit/CloudConfig/cc_resizefs.py4
-rw-r--r--cloudinit/CloudConfig/cc_runcmd.py2
-rw-r--r--cloudinit/CloudConfig/cc_set_passwords.py16
-rw-r--r--cloudinit/CloudConfig/cc_ssh.py4
-rw-r--r--cloudinit/CloudConfig/cc_timezone.py2
-rw-r--r--cloudinit/DataSource.py2
-rw-r--r--cloudinit/DataSourceEc2.py12
-rw-r--r--cloudinit/DataSourceNoCloud.py24
-rw-r--r--cloudinit/DataSourceOVF.py4
-rw-r--r--cloudinit/SshUtil.py6
-rw-r--r--cloudinit/UserDataHandler.py2
-rw-r--r--cloudinit/__init__.py34
-rw-r--r--cloudinit/util.py24
22 files changed, 104 insertions, 105 deletions
diff --git a/cloud-init-cfg.py b/cloud-init-cfg.py
index de64ef9c..0717ca95 100755
--- a/cloud-init-cfg.py
+++ b/cloud-init-cfg.py
@@ -49,13 +49,13 @@ def main():
else:
freq = None
run_args = []
- name=sys.argv[1]
+ name = sys.argv[1]
if len(sys.argv) > 2:
freq = sys.argv[2]
if freq == "None":
freq = None
if len(sys.argv) > 3:
- run_args=sys.argv[3:]
+ run_args = sys.argv[3:]
cfg_path = cloudinit.get_ipath_cur("cloud_config")
cfg_env_name = cloudinit.cfg_env_name
diff --git a/cloud-init.py b/cloud-init.py
index ba2b4499..f6313ba2 100755
--- a/cloud-init.py
+++ b/cloud-init.py
@@ -56,8 +56,8 @@ def main():
now = time.strftime("%a, %d %b %Y %H:%M:%S %z",time.gmtime())
try:
- uptimef=open("/proc/uptime")
- uptime=uptimef.read().split(" ")[0]
+ uptimef = open("/proc/uptime")
+ uptime = uptimef.read().split(" ")[0]
uptimef.close()
except IOError as e:
warn("unable to open /proc/uptime\n")
diff --git a/cloudinit/CloudConfig/__init__.py b/cloudinit/CloudConfig/__init__.py
index a30940fa..fb390090 100644
--- a/cloudinit/CloudConfig/__init__.py
+++ b/cloudinit/CloudConfig/__init__.py
@@ -25,7 +25,7 @@ import os
import subprocess
import time
-per_instance= cloudinit.per_instance
+per_instance = cloudinit.per_instance
per_always = cloudinit.per_always
per_once = cloudinit.per_once
@@ -247,11 +247,10 @@ def run_per_instance(name, func, args, clear_on_fail=False):
def apt_get(tlc,args=None):
if args is None:
args = []
- e=os.environ.copy()
- e['DEBIAN_FRONTEND']='noninteractive'
- cmd=[ 'apt-get',
- '--option', 'Dpkg::Options::=--force-confold', '--assume-yes',
- tlc ]
+ e = os.environ.copy()
+ e['DEBIAN_FRONTEND'] = 'noninteractive'
+ cmd = ['apt-get', '--option', 'Dpkg::Options::=--force-confold',
+ '--assume-yes', tlc]
cmd.extend(args)
subprocess.check_call(cmd,env=e)
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
index e911db89..e4c08708 100644
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
@@ -102,23 +102,23 @@ def handle(_name,cfg,cloud,log,_args):
return(True)
def mirror2lists_fileprefix(mirror):
- string=mirror
+ string = mirror
# take of http:// or ftp://
if string.endswith("/"):
- string=string[0:-1]
- pos=string.find("://")
+ string = string[0:-1]
+ pos = string.find("://")
if pos >= 0:
- string=string[pos+3:]
- string=string.replace("/","_")
+ string = string[pos+3:]
+ string = string.replace("/","_")
return string
def rename_apt_lists(omirror,new_mirror,lists_d="/var/lib/apt/lists"):
- oprefix="%s/%s" % (lists_d,mirror2lists_fileprefix(omirror))
- nprefix="%s/%s" % (lists_d,mirror2lists_fileprefix(new_mirror))
- if(oprefix==nprefix):
+ oprefix = "%s/%s" % (lists_d,mirror2lists_fileprefix(omirror))
+ nprefix = "%s/%s" % (lists_d,mirror2lists_fileprefix(new_mirror))
+ if(oprefix == nprefix):
return
- olen=len(oprefix)
+ olen = len(oprefix)
for filename in glob.glob("%s_*" % oprefix):
os.rename(filename,"%s%s" % (nprefix, filename[olen:]))
@@ -143,7 +143,7 @@ def add_sources(srclist, searchList=None):
elst.append([ "", "missing source" ])
continue
- source=ent['source']
+ source = ent['source']
if source.startswith("ppa:"):
try:
util.subp(["add-apt-repository",source])
@@ -154,7 +154,7 @@ def add_sources(srclist, searchList=None):
source = util.render_string(source, searchList)
if not ent.has_key('filename'):
- ent['filename']='cloud_config_sources.list'
+ ent['filename'] = 'cloud_config_sources.list'
if not ent['filename'].startswith("/"):
ent['filename'] = "%s/%s" % \
diff --git a/cloudinit/CloudConfig/cc_bootcmd.py b/cloudinit/CloudConfig/cc_bootcmd.py
index fc925447..47778897 100644
--- a/cloudinit/CloudConfig/cc_bootcmd.py
+++ b/cloudinit/CloudConfig/cc_bootcmd.py
@@ -35,8 +35,8 @@ def handle(_name,cfg,cloud,log,_args):
raise
try:
- env=os.environ.copy()
- env['INSTANCE_ID']=cloud.get_instance_id()
+ env = os.environ.copy()
+ env['INSTANCE_ID'] = cloud.get_instance_id()
subprocess.check_call(['/bin/sh'], env=env, stdin=tmpf)
tmpf.close()
except:
diff --git a/cloudinit/CloudConfig/cc_disable_ec2_metadata.py b/cloudinit/CloudConfig/cc_disable_ec2_metadata.py
index f06d4dfc..ff95f4bf 100644
--- a/cloudinit/CloudConfig/cc_disable_ec2_metadata.py
+++ b/cloudinit/CloudConfig/cc_disable_ec2_metadata.py
@@ -23,5 +23,5 @@ frequency = per_always
def handle(_name,cfg,_cloud,_log,_args):
if util.get_cfg_option_bool(cfg, "disable_ec2_metadata", False):
- fwall="route add -host 169.254.169.254 reject"
+ fwall = "route add -host 169.254.169.254 reject"
subprocess.call(fwall.split(' '))
diff --git a/cloudinit/CloudConfig/cc_final_message.py b/cloudinit/CloudConfig/cc_final_message.py
index c8631d01..ef0d9ad0 100644
--- a/cloudinit/CloudConfig/cc_final_message.py
+++ b/cloudinit/CloudConfig/cc_final_message.py
@@ -31,8 +31,8 @@ def handle(_name,cfg,_cloud,log,args):
msg_in = util.get_cfg_option_str(cfg,"final_message",final_message)
try:
- uptimef=open("/proc/uptime")
- uptime=uptimef.read().split(" ")[0]
+ uptimef = open("/proc/uptime")
+ uptime = uptimef.read().split(" ")[0]
uptimef.close()
except IOError as e:
log.warn("unable to open /proc/uptime\n")
diff --git a/cloudinit/CloudConfig/cc_grub_dpkg.py b/cloudinit/CloudConfig/cc_grub_dpkg.py
index fde8cca1..4e1ba4d4 100644
--- a/cloudinit/CloudConfig/cc_grub_dpkg.py
+++ b/cloudinit/CloudConfig/cc_grub_dpkg.py
@@ -22,24 +22,24 @@ import os
def handle(_name,cfg,_cloud,log,_args):
- idevs=None
- idevs_empty=None
+ idevs = None
+ idevs_empty = None
if "grub-dpkg" in cfg:
- idevs=util.get_cfg_option_str(cfg["grub-dpkg"],
+ idevs = util.get_cfg_option_str(cfg["grub-dpkg"],
"grub-pc/install_devices",None)
- idevs_empty=util.get_cfg_option_str(cfg["grub-dpkg"],
+ idevs_empty = util.get_cfg_option_str(cfg["grub-dpkg"],
"grub-pc/install_devices_empty",None)
if (( os.path.exists("/dev/sda1") and not os.path.exists("/dev/sda") ) or
( os.path.exists("/dev/xvda1") and not os.path.exists("/dev/xvda") )):
if idevs == None:
- idevs=""
+ idevs = ""
if idevs_empty == None:
- idevs_empty="true"
+ idevs_empty = "true"
else:
if idevs_empty == None:
- idevs_empty="false"
+ idevs_empty = "false"
if idevs == None:
idevs = "/dev/sda"
for dev in ( "/dev/sda", "/dev/vda", "/dev/sda1", "/dev/vda1"):
diff --git a/cloudinit/CloudConfig/cc_mounts.py b/cloudinit/CloudConfig/cc_mounts.py
index 94ad1bba..248abb24 100644
--- a/cloudinit/CloudConfig/cc_mounts.py
+++ b/cloudinit/CloudConfig/cc_mounts.py
@@ -76,7 +76,7 @@ def handle(_name,cfg,cloud,log,_args):
# but do not convert None to 'None' (LP: #898365)
for j in range(len(cfgmnt[i])):
if isinstance(cfgmnt[i][j], int):
- cfgmnt[i][j]=str(cfgmnt[i][j])
+ cfgmnt[i][j] = str(cfgmnt[i][j])
for i in range(len(cfgmnt)):
# fill in values with defaults from defvals above
@@ -124,13 +124,13 @@ def handle(_name,cfg,cloud,log,_args):
if len(actlist) == 0:
return
- comment="comment=cloudconfig"
+ comment = "comment=cloudconfig"
cc_lines = [ ]
needswap = False
dirs = [ ]
for line in actlist:
# write 'comment' in the fs_mntops, entry, claiming this
- line[3]="%s,comment=cloudconfig" % line[3]
+ line[3] = "%s,comment=cloudconfig" % line[3]
if line[2] == "swap":
needswap = True
if line[1].startswith("/"):
@@ -138,7 +138,7 @@ def handle(_name,cfg,cloud,log,_args):
cc_lines.append('\t'.join(line))
fstab_lines = [ ]
- fstab=open("/etc/fstab","r+")
+ fstab = open("/etc/fstab","r+")
ws = re.compile("[%s]+" % string.whitespace)
for line in fstab.read().splitlines():
try:
diff --git a/cloudinit/CloudConfig/cc_resizefs.py b/cloudinit/CloudConfig/cc_resizefs.py
index 29e0fa34..1fdf8647 100644
--- a/cloudinit/CloudConfig/cc_resizefs.py
+++ b/cloudinit/CloudConfig/cc_resizefs.py
@@ -42,8 +42,8 @@ def handle(_name,cfg,_cloud,log,args):
os.close(fd)
try:
- st_dev=os.stat("/").st_dev
- dev=os.makedev(os.major(st_dev),os.minor(st_dev))
+ st_dev = os.stat("/").st_dev
+ dev = os.makedev(os.major(st_dev),os.minor(st_dev))
os.mknod(devpth, 0400 | stat.S_IFBLK, dev)
except:
if util.islxc():
diff --git a/cloudinit/CloudConfig/cc_runcmd.py b/cloudinit/CloudConfig/cc_runcmd.py
index d255223b..0adf31ad 100644
--- a/cloudinit/CloudConfig/cc_runcmd.py
+++ b/cloudinit/CloudConfig/cc_runcmd.py
@@ -21,7 +21,7 @@ import cloudinit.util as util
def handle(_name,cfg,cloud,log,_args):
if not cfg.has_key("runcmd"):
return
- outfile="%s/runcmd" % cloud.get_ipath('scripts')
+ outfile = "%s/runcmd" % cloud.get_ipath('scripts')
try:
content = util.shellify(cfg["runcmd"])
util.write_file(outfile,content,0700)
diff --git a/cloudinit/CloudConfig/cc_set_passwords.py b/cloudinit/CloudConfig/cc_set_passwords.py
index 07e3ca1b..4059e9c1 100644
--- a/cloudinit/CloudConfig/cc_set_passwords.py
+++ b/cloudinit/CloudConfig/cc_set_passwords.py
@@ -70,7 +70,7 @@ def handle(_name,cfg,_cloud,log,args):
'\n'.join(randlist) ))
if expire:
- enum=len(errors)
+ enum = len(errors)
for u in users:
try:
util.subp(['passwd', '--expire', u])
@@ -83,13 +83,13 @@ def handle(_name,cfg,_cloud,log,args):
if 'ssh_pwauth' in cfg:
val = str(cfg['ssh_pwauth']).lower()
if val in ( "true", "1", "yes"):
- pw_auth="yes"
- change_pwauth=True
+ pw_auth = "yes"
+ change_pwauth = True
elif val in ( "false", "0", "no"):
- pw_auth="no"
- change_pwauth=True
+ pw_auth = "no"
+ change_pwauth = True
else:
- change_pwauth=False
+ change_pwauth = False
if change_pwauth:
pa_s = "\(#*\)\(PasswordAuthentication[[:space:]]\+\)\(yes\|no\)"
@@ -118,7 +118,7 @@ def rand_str(strlen=32, select_from=string.letters+string.digits):
return("".join([random.choice(select_from) for _x in range(0, strlen)]))
def rand_user_password(pwlen=9):
- selfrom=(string.letters.translate(None,'loLOI') +
- string.digits.translate(None,'01'))
+ selfrom = (string.letters.translate(None,'loLOI') +
+ string.digits.translate(None,'01'))
return(rand_str(pwlen,select_from=selfrom))
diff --git a/cloudinit/CloudConfig/cc_ssh.py b/cloudinit/CloudConfig/cc_ssh.py
index 897ba9dc..6031a436 100644
--- a/cloudinit/CloudConfig/cc_ssh.py
+++ b/cloudinit/CloudConfig/cc_ssh.py
@@ -21,7 +21,7 @@ import os
import glob
import subprocess
-DISABLE_ROOT_OPTS="no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command=\"echo \'Please login as the user \\\"$USER\\\" rather than the user \\\"root\\\".\';echo;sleep 10\""
+DISABLE_ROOT_OPTS = "no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command=\"echo \'Please login as the user \\\"$USER\\\" rather than the user \\\"root\\\".\';echo;sleep 10\""
global_log = None
@@ -60,7 +60,7 @@ def handle(_name,cfg,cloud,log,_args):
for priv,pub in priv2pub.iteritems():
if pub in cfg['ssh_keys'] or not priv in cfg['ssh_keys']:
continue
- pair=(key2file[priv][0], key2file[pub][0])
+ pair = (key2file[priv][0], key2file[pub][0])
subprocess.call(('sh', '-xc', cmd % pair))
log.debug("generated %s from %s" % pair)
else:
diff --git a/cloudinit/CloudConfig/cc_timezone.py b/cloudinit/CloudConfig/cc_timezone.py
index 091271f4..e7c855d6 100644
--- a/cloudinit/CloudConfig/cc_timezone.py
+++ b/cloudinit/CloudConfig/cc_timezone.py
@@ -40,7 +40,7 @@ def handle(_name,cfg,_cloud,log,args):
raise Exception("Invalid timezone %s" % tz_file)
try:
- fp=open("/etc/timezone","wb")
+ fp = open("/etc/timezone","wb")
fp.write("%s\n" % timezone)
fp.close()
except:
diff --git a/cloudinit/DataSource.py b/cloudinit/DataSource.py
index edf62359..bb4b6c19 100644
--- a/cloudinit/DataSource.py
+++ b/cloudinit/DataSource.py
@@ -165,7 +165,7 @@ def list_sources(cfg_list, depends, pkglist=None):
for ds_coll in cfg_list:
for pkg in pkglist:
if pkg:
- pkg="%s." % pkg
+ pkg = "%s." % pkg
try:
mod = __import__("%sDataSource%s" % (pkg, ds_coll))
if pkg:
diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py
index 1c2bac9f..f4de0288 100644
--- a/cloudinit/DataSourceEc2.py
+++ b/cloudinit/DataSourceEc2.py
@@ -35,7 +35,7 @@ class DataSourceEc2(DataSource.DataSource):
return("DataSourceEc2")
def get_data(self):
- seedret={ }
+ seedret = { }
if util.read_optional_seed(seedret,base=self.seeddir+ "/"):
self.userdata_raw = seedret['user-data']
self.metadata = seedret['meta-data']
@@ -74,7 +74,7 @@ class DataSourceEc2(DataSource.DataSource):
return fallback
try:
- host="%s.ec2.archive.ubuntu.com" % availability_zone[:-1]
+ host = "%s.ec2.archive.ubuntu.com" % availability_zone[:-1]
socket.getaddrinfo(host, None, 0, socket.SOCK_STREAM)
return 'http://%s/ubuntu/' % host
except:
@@ -168,7 +168,7 @@ class DataSourceEc2(DataSource.DataSource):
short = os.path.basename(found)
if not found.startswith("/"):
- found="/dev/%s" % found
+ found = "/dev/%s" % found
if os.path.exists(found):
return(found)
@@ -193,8 +193,8 @@ class DataSourceEc2(DataSource.DataSource):
def is_vpc(self):
# per comment in LP: #615545
- ph="public-hostname"
- p4="public-ipv4"
+ ph = "public-hostname"
+ p4 = "public-ipv4"
if ((ph not in self.metadata or self.metadata[ph] == "") and
(p4 not in self.metadata or self.metadata[p4] == "")):
return True
@@ -238,7 +238,7 @@ def wait_for_metadata_service(urls, max_wait=None, timeout=None, status_cb=None)
loop_n = 0
while True:
- sleeptime=int(loop_n/5)+1
+ sleeptime = int(loop_n/5)+1
for url in urls:
now = time.time()
if loop_n != 0:
diff --git a/cloudinit/DataSourceNoCloud.py b/cloudinit/DataSourceNoCloud.py
index 3ddae914..d2e9b5a1 100644
--- a/cloudinit/DataSourceNoCloud.py
+++ b/cloudinit/DataSourceNoCloud.py
@@ -31,7 +31,7 @@ class DataSourceNoCloud(DataSource.DataSource):
seeddir = seeddir + '/nocloud'
def __str__(self):
- mstr="DataSourceNoCloud"
+ mstr = "DataSourceNoCloud"
mstr = mstr + " [seed=%s]" % self.seed
return(mstr)
@@ -53,7 +53,7 @@ class DataSourceNoCloud(DataSource.DataSource):
return False
# check to see if the seeddir has data.
- seedret={ }
+ seedret = { }
if util.read_optional_seed(seedret,base=self.seeddir + "/"):
md = util.mergedict(md,seedret['meta-data'])
ud = seedret['user-data']
@@ -72,7 +72,7 @@ class DataSourceNoCloud(DataSource.DataSource):
seedfound = False
for proto in self.supported_seed_starts:
if seedfrom.startswith(proto):
- seedfound=proto
+ seedfound = proto
break
if not seedfound:
log.debug("seed from %s not supported by %s" %
@@ -106,20 +106,20 @@ def parse_cmdline_data(ds_id,fill,cmdline=None):
if not ( " %s " % ds_id in cmdline or " %s;" % ds_id in cmdline ):
return False
- argline=""
+ argline = ""
# cmdline can contain:
# ds=nocloud[;key=val;key=val]
for tok in cmdline.split():
if tok.startswith(ds_id):
- argline=tok.split("=",1)
+ argline = tok.split("=",1)
# argline array is now 'nocloud' followed optionally by
# a ';' and then key=value pairs also terminated with ';'
- tmp=argline[1].split(";")
+ tmp = argline[1].split(";")
if len(tmp) > 1:
- kvpairs=tmp[1:]
+ kvpairs = tmp[1:]
else:
- kvpairs=()
+ kvpairs = ()
# short2long mapping to save cmdline typing
s2l = { "h" : "local-hostname", "i" : "instance-id", "s" : "seedfrom" }
@@ -127,11 +127,11 @@ def parse_cmdline_data(ds_id,fill,cmdline=None):
try:
(k,v) = item.split("=",1)
except:
- k=item
- v=None
+ k = item
+ v = None
if k in s2l:
- k=s2l[k]
- fill[k]=v
+ k = s2l[k]
+ fill[k] = v
return(True)
diff --git a/cloudinit/DataSourceOVF.py b/cloudinit/DataSourceOVF.py
index cdfa0c64..4da21df1 100644
--- a/cloudinit/DataSourceOVF.py
+++ b/cloudinit/DataSourceOVF.py
@@ -39,7 +39,7 @@ class DataSourceOVF(DataSource.DataSource):
supported_seed_starts = ( "/" , "file://" )
def __str__(self):
- mstr="DataSourceOVF"
+ mstr = "DataSourceOVF"
mstr = mstr + " [seed=%s]" % self.seed
return(mstr)
@@ -175,7 +175,7 @@ def transport_iso9660(require_iso=False):
mounted = { }
for mpline in mounts:
(dev,mp,fstype,_opts,_freq,_passno) = mpline.split()
- mounted[dev]=(dev,fstype,mp,False)
+ mounted[dev] = (dev,fstype,mp,False)
mp = mp.replace("\\040"," ")
if fstype != "iso9660" and require_iso:
continue
diff --git a/cloudinit/SshUtil.py b/cloudinit/SshUtil.py
index 125ca618..198f7206 100644
--- a/cloudinit/SshUtil.py
+++ b/cloudinit/SshUtil.py
@@ -18,7 +18,7 @@ class AuthKeyEntry():
line_in = ""
def __init__(self, line, def_opt=None):
- line=line.rstrip("\n\r")
+ line = line.rstrip("\n\r")
self.line_in = line
if line.startswith("#") or line.strip() == "":
self.is_comment = True
@@ -184,13 +184,13 @@ if __name__ == "__main__":
def parse_ssh_config(fname="/etc/ssh/sshd_config"):
ret = { }
- fp=open(fname)
+ fp = open(fname)
for l in fp.readlines():
l = l.strip()
if not l or l.startswith("#"):
continue
key,val = l.split(None,1)
- ret[key]=val
+ ret[key] = val
fp.close()
return(ret)
diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py
index feaf27cf..b21eacbe 100644
--- a/cloudinit/UserDataHandler.py
+++ b/cloudinit/UserDataHandler.py
@@ -26,7 +26,7 @@ import cloudinit.util as util
import hashlib
import urllib
-starts_with_mappings={
+starts_with_mappings = {
'#include' : 'text/x-include-url',
'#include-once' : 'text/x-include-once-url',
'#!' : 'text/x-shellscript',
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py
index 554ebf6b..3a3c9c85 100644
--- a/cloudinit/__init__.py
+++ b/cloudinit/__init__.py
@@ -46,9 +46,9 @@ pathmap = {
None : "",
}
-per_instance="once-per-instance"
-per_always="always"
-per_once="once"
+per_instance = "once-per-instance"
+per_always = "always"
+per_once = "once"
parsed_cfgs = { }
@@ -81,7 +81,7 @@ def logging_set_from_cfg_file(cfg_file=system_config):
def logging_set_from_cfg(cfg):
log_cfgs = []
- logcfg=util.get_cfg_option_str(cfg, "log_cfg", False)
+ logcfg = util.get_cfg_option_str(cfg, "log_cfg", False)
if logcfg:
# if there is a 'logcfg' entry in the config, respect
# it, it is the old keyname
@@ -131,8 +131,8 @@ class CloudInit:
if ds_deps != None:
self.ds_deps = ds_deps
- self.sysconfig=sysconfig
- self.cfg=self.read_cfg()
+ self.sysconfig = sysconfig
+ self.cfg = self.read_cfg()
def read_cfg(self):
if self.cfg:
@@ -162,7 +162,7 @@ class CloudInit:
# by using the instance link, if purge_cache was called
# the file wont exist
cache = get_ipath_cur('obj_pkl')
- f=open(cache, "rb")
+ f = open(cache, "rb")
data = cPickle.load(f)
f.close()
self.datasource = data
@@ -179,7 +179,7 @@ class CloudInit:
return False
try:
- f=open(cache, "wb")
+ f = open(cache, "wb")
cPickle.dump(self.datasource,f)
f.close()
os.chmod(cache,0400)
@@ -194,7 +194,7 @@ class CloudInit:
log.debug("restored from cache type %s" % self.datasource)
return True
- cfglist=self.cfg['datasource_list']
+ cfglist = self.cfg['datasource_list']
dslist = list_sources(cfglist, self.ds_deps)
dsnames = [f.__name__ for f in dslist]
@@ -382,7 +382,7 @@ class CloudInit:
# maybe delete existing things here
return
- filename=filename.replace(os.sep,'_')
+ filename = filename.replace(os.sep,'_')
scriptsdir = get_ipath_cur('scripts')
util.write_file("%s/%s" %
(scriptsdir,filename), util.dos2unix(payload), 0700)
@@ -395,14 +395,14 @@ class CloudInit:
if ctype == "__end__" or ctype == "__begin__":
return
if not filename.endswith(".conf"):
- filename=filename+".conf"
+ filename = filename+".conf"
util.write_file("%s/%s" % ("/etc/init",filename),
util.dos2unix(payload), 0644)
def handle_cloud_config(self,_data,ctype,filename,payload, _frequency):
if ctype == "__begin__":
- self.cloud_config_str=""
+ self.cloud_config_str = ""
return
if ctype == "__end__":
cloud_config = self.get_ipath("cloud_config")
@@ -418,7 +418,7 @@ class CloudInit:
return
- self.cloud_config_str+="\n#%s\n%s" % (filename,payload)
+ self.cloud_config_str += "\n#%s\n%s" % (filename,payload)
def handle_cloud_boothook(self,_data,ctype,filename,payload, _frequency):
if ctype == "__end__":
@@ -426,9 +426,9 @@ class CloudInit:
if ctype == "__begin__":
return
- filename=filename.replace(os.sep,'_')
+ filename = filename.replace(os.sep,'_')
payload = util.dos2unix(payload)
- prefix="#cloud-boothook"
+ prefix = "#cloud-boothook"
start = 0
if payload.startswith(prefix):
start = len(prefix) + 1
@@ -437,8 +437,8 @@ class CloudInit:
filepath = "%s/%s" % (boothooks_dir,filename)
util.write_file(filepath, payload[start:], 0700)
try:
- env=os.environ.copy()
- env['INSTANCE_ID']= self.datasource.get_instance_id()
+ env = os.environ.copy()
+ env['INSTANCE_ID'] = self.datasource.get_instance_id()
subprocess.check_call([filepath], env=env)
except subprocess.CalledProcessError as e:
log.error("boothooks script %s returned %i" %
diff --git a/cloudinit/util.py b/cloudinit/util.py
index ec1cb01c..f57392fd 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -125,7 +125,7 @@ def write_file(filename,content,mode=0644,omode="wb"):
if e.errno != errno.EEXIST:
raise e
- f=open(filename,omode)
+ f = open(filename,omode)
if mode != None:
os.chmod(filename,mode)
f.write(content)
@@ -138,7 +138,7 @@ def restorecon_if_possible(path, recursive=False):
# get keyid from keyserver
def getkeybyid(keyid,keyserver):
- shcmd="""
+ shcmd = """
k=${1} ks=${2};
exec 2>/dev/null
[ -n "$k" ] || exit 1;
@@ -150,7 +150,7 @@ def getkeybyid(keyid,keyserver):
fi
[ -n "${armour}" ] && echo "${armour}"
"""
- args=['sh', '-c', shcmd, "export-gpg-keyid", keyid, keyserver]
+ args = ['sh', '-c', shcmd, "export-gpg-keyid", keyid, keyserver]
return(subp(args)[0])
def runparts(dirp, skip_no_exist=True):
@@ -193,8 +193,8 @@ def render_string(template, searchList):
def read_optional_seed(fill,base="",ext="", timeout=5):
try:
(md,ud) = read_seeded(base,ext,timeout)
- fill['user-data']= ud
- fill['meta-data']= md
+ fill['user-data'] = ud
+ fill['meta-data'] = md
return True
except OSError, e:
if e.errno == errno.ENOENT:
@@ -205,7 +205,7 @@ def read_optional_seed(fill,base="",ext="", timeout=5):
# raise OSError with enoent if not found
def read_seeded(base="", ext="", timeout=5, retries=10, file_retries=0):
if base.startswith("/"):
- base="file://%s" % base
+ base = "file://%s" % base
# default retries for file is 0. for network is 10
if base.startswith("file://"):
@@ -356,8 +356,8 @@ def read_cc_from_cmdline(cmdline=None):
if cmdline is None:
cmdline = get_cmdline()
- tag_begin="cc:"
- tag_end="end_cc"
+ tag_begin = "cc:"
+ tag_end = "end_cc"
begin_l = len(tag_begin)
end_l = len(tag_end)
clen = len(cmdline)
@@ -423,8 +423,8 @@ def readurl(url, data=None, timeout=None):
# if it is an array, shell protect it (with single ticks)
# if it is a string, do nothing
def shellify(cmdlist):
- content="#!/bin/sh\n"
- escaped="%s%s%s%s" % ( "'", '\\', "'", "'" )
+ content = "#!/bin/sh\n"
+ escaped = "%s%s%s%s" % ( "'", '\\', "'", "'" )
for args in cmdlist:
# if the item is a list, wrap all items in single tick
# if its not, then just write it directly
@@ -432,9 +432,9 @@ def shellify(cmdlist):
fixed = [ ]
for f in args:
fixed.append("'%s'" % str(f).replace("'",escaped))
- content="%s%s\n" % ( content, ' '.join(fixed) )
+ content = "%s%s\n" % ( content, ' '.join(fixed) )
else:
- content="%s%s\n" % ( content, str(args) )
+ content = "%s%s\n" % ( content, str(args) )
return content
def dos2unix(string):