pyflakes fixes.

make pyflakes now passes.
This commit is contained in:
Scott Moser 2014-09-10 14:32:37 -04:00
commit 748e90a72e
12 changed files with 28 additions and 28 deletions

View File

@ -132,7 +132,7 @@ def handle(_name, cfg, cloud, log, args):
'PasswordAuthentication',
pw_auth))
lines = [str(e) for e in new_lines]
lines = [str(l) for l in new_lines]
util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
try:

View File

@ -85,7 +85,7 @@ def import_ssh_ids(ids, user, log):
return
try:
_check = pwd.getpwnam(user)
pwd.getpwnam(user)
except KeyError as exc:
raise exc

View File

@ -861,5 +861,5 @@ def set_etc_timezone(tz, tz_file=None, tz_conf="/etc/timezone",
util.write_file(tz_conf, str(tz).rstrip() + "\n")
# This ensures that the correct tz will be used for the system
if tz_local and tz_file:
util.copy(tz_file, self.tz_local_fn)
util.copy(tz_file, tz_local)
return

View File

@ -159,7 +159,7 @@ class Distro(distros.Distro):
return hostname
def set_timezone(self, tz):
set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
def package_command(self, command, args=None, pkgs=None):
if pkgs is None:

View File

@ -131,7 +131,7 @@ class Distro(distros.Distro):
return "127.0.1.1"
def set_timezone(self, tz):
set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
def package_command(self, command, args=None, pkgs=None):
if pkgs is None:

View File

@ -264,7 +264,7 @@ class Distro(distros.Distro):
if 'dns-nameservers' in info:
nameservers.extend(info['dns-nameservers'])
if 'dns-search' in info:
searchservers.extend(info['dns-search'])
searchdomains.extend(info['dns-search'])
else:
ifconfig = 'DHCP'

View File

@ -138,7 +138,7 @@ class Distro(distros.Distro):
return hostname
def set_timezone(self, tz):
set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
def package_command(self, command, args=None, pkgs=None):
if pkgs is None:

View File

@ -64,13 +64,13 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
try:
max_wait = int(self.ds_cfg.get("max_wait", max_wait))
except Exception:
util.logexc(LOG, "Failed to get max wait. using %s", max_wait)
except Exception as e:
LOG.debug("Failed to get max wait. using %s: %s", max_wait, e)
try:
timeout = max(0, int(self.ds_cfg.get("timeout", timeout)))
except Exception:
util.logexc(LOG, "Failed to get timeout, using %s", timeout)
except Exception as e:
LOG.debug("Failed to get timeout, using %s: %s", timeout, e)
return (max_wait, timeout)
def wait_for_metadata_service(self):
@ -82,7 +82,7 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
if len(filtered):
urls = filtered
else:
LOG.warn("Empty metadata url list! using default list")
LOG.debug("Empty metadata url list! using default list")
urls = [DEF_MD_URL]
md_urls = []
@ -123,9 +123,9 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
'version': openstack.OS_HAVANA})
except openstack.NonReadable:
return False
except (openstack.BrokenMetadata, IOError):
util.logexc(LOG, "Broken metadata address %s",
self.metadata_address)
except (openstack.BrokenMetadata, IOError) as e:
LOG.debug("Broken metadata address %s: %s",
self.metadata_address, e)
return False
user_dsmode = results.get('dsmode', None)

View File

@ -163,10 +163,10 @@ class BaseReader(object):
def _find_working_version(self, version):
try:
versions_available = self._fetch_available_versions(self)
versions_available = self._fetch_available_versions()
except Exception as e:
LOG.warn("Unable to read openstack versions from %s due to: %s",
self.base_path, e)
LOG.debug("Unable to read openstack versions from %s due to: %s",
self.base_path, e)
versions_available = []
search_versions = [version] + list(OS_VERSIONS)
@ -178,8 +178,8 @@ class BaseReader(object):
break
if selected_version != version:
LOG.warn("Version '%s' not available, attempting to use"
" version '%s' instead", version, selected_version)
LOG.debug("Version '%s' not available, attempting to use"
" version '%s' instead", version, selected_version)
return selected_version
def _read_content_path(self, item):
@ -239,7 +239,8 @@ class BaseReader(object):
LOG.debug("Failed reading optional path %s due"
" to: %s", path, e)
else:
LOG.exception("Failed reading mandatory path %s", path)
LOG.debug("Failed reading mandatory path %s due"
" to: %s", path, e)
else:
found = True
if required and not found:
@ -420,6 +421,7 @@ class MetadataReader(BaseReader):
if self._versions is not None:
return self.os_versions
found = []
version_path = self._path_join(self.base_path, "openstack")
content = self._path_read(version_path)
for line in content.splitlines():
line = line.strip()

View File

@ -106,7 +106,7 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
initer.read_cfg()
initer.initialize()
initer.fetch()
_iid = initer.instancify()
initer.instancify()
initer.update()
initer.cloudify().run('consume_data',
initer.consume_data,
@ -145,7 +145,7 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
initer.read_cfg()
initer.initialize()
initer.fetch()
_iid = initer.instancify()
initer.instancify()
initer.update()
initer.cloudify().run('consume_data',
initer.consume_data,
@ -221,7 +221,7 @@ run:
initer.read_cfg()
initer.initialize()
initer.fetch()
_iid = initer.instancify()
initer.instancify()
initer.update()
initer.cloudify().run('consume_data',
initer.consume_data,
@ -256,7 +256,7 @@ vendor_data:
initer.read_cfg()
initer.initialize()
initer.fetch()
_iid = initer.instancify()
initer.instancify()
initer.update()
initer.cloudify().run('consume_data',
initer.consume_data,
@ -264,7 +264,6 @@ vendor_data:
freq=PER_INSTANCE)
mods = stages.Modules(initer)
(_which_ran, _failures) = mods.run_section('cloud_init_modules')
_cfg = mods.cfg
vendor_script = initer.paths.get_ipath_cur('vendor_scripts')
vendor_script_fns = "%s%s/part-001" % (new_root, vendor_script)
self.assertTrue(os.path.exists(vendor_script_fns))

View File

@ -57,7 +57,6 @@ class TestNoCloudDataSource(MockerTestCase):
pass
def my_find_devs_with(*args, **kwargs):
_f = (args, kwargs)
raise PsuedoException
self.apply_patches([(util, 'find_devs_with', my_find_devs_with)])

View File

@ -33,7 +33,7 @@ class TestMergeRun(helpers.FilesystemMockingTestCase):
initer.initialize()
initer.fetch()
initer.datasource.userdata_raw = ud
_iid = initer.instancify()
initer.instancify()
initer.update()
initer.cloudify().run('consume_data',
initer.consume_data,