diff options
| author | harlowja <harlowja@virtualbox.rhel> | 2012-10-27 19:25:48 -0700 | 
|---|---|---|
| committer | harlowja <harlowja@virtualbox.rhel> | 2012-10-27 19:25:48 -0700 | 
| commit | aa8b51a48a30e3a3c863ca0ddb8bc4667026d57a (patch) | |
| tree | 664d7bfb27d2394a02b9a3aeb4f25b8a835f6be5 /cloudinit/config/cc_apt_update_upgrade.py | |
| parent | 71b4108d029fff61ff8183ffbd77917569bea2cd (diff) | |
| download | vyos-cloud-init-aa8b51a48a30e3a3c863ca0ddb8bc4667026d57a.tar.gz vyos-cloud-init-aa8b51a48a30e3a3c863ca0ddb8bc4667026d57a.zip | |
Helpful cleanups.
1. Remove the usage of the path.join function
   now that all code should be going through
   the util file methods (and they can be
   mocked out as needed).
2. Adjust all occurences of the above join
   function to either not use it or replace
   it with the standard os.path.join (which
   can also be mocked out as needed)
3. Fix pylint from complaining about the
   tests folder 'helpers.py' not being found
4. Add a pylintrc file that is used instead
   of the options hidden in the 'run_pylint' 
   tool.
Diffstat (limited to 'cloudinit/config/cc_apt_update_upgrade.py')
| -rw-r--r-- | cloudinit/config/cc_apt_update_upgrade.py | 13 | 
1 files changed, 5 insertions, 8 deletions
| diff --git a/cloudinit/config/cc_apt_update_upgrade.py b/cloudinit/config/cc_apt_update_upgrade.py index 356bb98d..59c34b59 100644 --- a/cloudinit/config/cc_apt_update_upgrade.py +++ b/cloudinit/config/cc_apt_update_upgrade.py @@ -78,8 +78,7 @@ def handle(name, cfg, cloud, log, _args):          try:              # See man 'apt.conf'              contents = PROXY_TPL % (proxy) -            util.write_file(cloud.paths.join(False, proxy_filename), -                            contents) +            util.write_file(proxy_filename, contents)          except Exception as e:              util.logexc(log, "Failed to write proxy to %s", proxy_filename)      elif os.path.isfile(proxy_filename): @@ -90,7 +89,7 @@ def handle(name, cfg, cloud, log, _args):          params = mirrors          params['RELEASE'] = release          params['MIRROR'] = mirror -        errors = add_sources(cloud, cfg['apt_sources'], params) +        errors = add_sources(cfg['apt_sources'], params)          for e in errors:              log.warn("Source Error: %s", ':'.join(e)) @@ -196,11 +195,10 @@ def generate_sources_list(codename, mirrors, cloud, log):      params = {'codename': codename}      for k in mirrors:          params[k] = mirrors[k] -    out_fn = cloud.paths.join(False, '/etc/apt/sources.list') -    templater.render_to_file(template_fn, out_fn, params) +    templater.render_to_file(template_fn, '/etc/apt/sources.list', params) -def add_sources(cloud, srclist, template_params=None): +def add_sources(srclist, template_params=None):      """      add entries in /etc/apt/sources.list.d for each abbreviated      sources.list entry in 'srclist'.  When rendering template, also @@ -250,8 +248,7 @@ def add_sources(cloud, srclist, template_params=None):          try:              contents = "%s\n" % (source) -            util.write_file(cloud.paths.join(False, ent['filename']), -                            contents, omode="ab") +            util.write_file(ent['filename'], contents, omode="ab")          except:              errorlist.append([source,                               "failed write to file %s" % ent['filename']]) | 
