diff options
-rw-r--r-- | cloudinit/CloudConfig/cc_apt_update_upgrade.py | 16 | ||||
-rw-r--r-- | cloudinit/UserDataHandler.py | 8 | ||||
-rw-r--r-- | cloudinit/util.py | 22 |
3 files changed, 23 insertions, 23 deletions
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py index 22651067..d466f3c4 100644 --- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py +++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py @@ -102,14 +102,14 @@ def handle(_name,cfg,cloud,log,_args): return(True) def mirror2lists_fileprefix(mirror): - file=mirror + string=mirror # take of http:// or ftp:// - if file.endswith("/"): file=file[0:-1] - pos=file.find("://") + if string.endswith("/"): string=string[0:-1] + pos=string.find("://") if pos >= 0: - file=file[pos+3:] - file=file.replace("/","_") - return file + string=string[pos+3:] + string=string.replace("/","_") + return string def rename_apt_lists(omirror,new_mirror,lists_d="/var/lib/apt/lists"): @@ -117,8 +117,8 @@ def rename_apt_lists(omirror,new_mirror,lists_d="/var/lib/apt/lists"): nprefix="%s/%s" % (lists_d,mirror2lists_fileprefix(new_mirror)) if(oprefix==nprefix): return olen=len(oprefix) - for file in glob.glob("%s_*" % oprefix): - os.rename(file,"%s%s" % (nprefix, file[olen:])) + for filename in glob.glob("%s_*" % oprefix): + os.rename(filename,"%s%s" % (nprefix, filename[olen:])) def get_release(): stdout, _stderr = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).communicate() diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py index 0afe5a18..2d257d12 100644 --- a/cloudinit/UserDataHandler.py +++ b/cloudinit/UserDataHandler.py @@ -37,15 +37,15 @@ starts_with_mappings={ '#cloud-config-archive' : 'text/cloud-config-archive', } -# if 'str' is compressed return decompressed otherwise return it -def decomp_str(str): +# if 'string' is compressed return decompressed otherwise return it +def decomp_str(string): import StringIO import gzip try: - uncomp = gzip.GzipFile(None,"rb",1,StringIO.StringIO(str)).read() + uncomp = gzip.GzipFile(None,"rb",1,StringIO.StringIO(string)).read() return(uncomp) except: - return(str) + return(string) def do_include(content, appendmsg): import os diff --git a/cloudinit/util.py b/cloudinit/util.py index 90998297..deb4b33b 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -111,19 +111,19 @@ def mergedict(src,cand): src[k] = mergedict(src[k],v) return src -def write_file(file,content,mode=0644,omode="wb"): +def write_file(filename,content,mode=0644,omode="wb"): try: - os.makedirs(os.path.dirname(file)) + os.makedirs(os.path.dirname(filename)) except OSError as e: if e.errno != errno.EEXIST: raise e - f=open(file,omode) + f=open(filename,omode) if mode != None: - os.chmod(file,mode) + os.chmod(filename,mode) f.write(content) f.close() - restorecon_if_possible(file) + restorecon_if_possible(filename) def restorecon_if_possible(path, recursive=False): if HAVE_LIBSELINUX and selinux.is_selinux_enabled(): @@ -159,10 +159,10 @@ def runparts(dirp, skip_no_exist=True): raise subprocess.CalledProcessError(sp.returncode,cmd) return -def subp(args, input=None): +def subp(args, input_=None): sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) - out,err = sp.communicate(input) + out,err = sp.communicate(input_) if sp.returncode is not 0: raise subprocess.CalledProcessError(sp.returncode,args, (out,err)) return(out,err) @@ -421,11 +421,11 @@ def shellify(cmdlist): content="%s%s\n" % ( content, str(args) ) return content -def dos2unix(input): +def dos2unix(string): # find first end of line - pos = input.find('\n') - if pos <= 0 or input[pos-1] != '\r': return(input) - return(input.replace('\r\n','\n')) + pos = string.find('\n') + if pos <= 0 or string[pos-1] != '\r': return(string) + return(string.replace('\r\n','\n')) def islxc(): # is this host running lxc? |