fix pep8 and pylint
This commit is contained in:
parent
d01d493572
commit
149b2480dd
@ -59,7 +59,8 @@ def handle(_name, cfg, cloud, log, _args):
|
||||
if not isinstance(ls_cloudcfg, (dict)):
|
||||
raise RuntimeError(("'landscape' key existed in config,"
|
||||
" but not a dictionary type,"
|
||||
" is a %s instead"), type_utils.obj_name(ls_cloudcfg))
|
||||
" is a %s instead"),
|
||||
type_utils.obj_name(ls_cloudcfg))
|
||||
if not ls_cloudcfg:
|
||||
return
|
||||
|
||||
|
@ -741,7 +741,7 @@ def normalize_users_groups(cfg, distro):
|
||||
}
|
||||
if not isinstance(old_user, (dict)):
|
||||
LOG.warn(("Format for 'user' key must be a string or "
|
||||
"dictionary and not %s"), util.obj_name(old_user))
|
||||
"dictionary and not %s"), type_utils.obj_name(old_user))
|
||||
old_user = {}
|
||||
|
||||
# If no old user format, then assume the distro
|
||||
@ -767,7 +767,7 @@ def normalize_users_groups(cfg, distro):
|
||||
if not isinstance(base_users, (list, dict, str, basestring)):
|
||||
LOG.warn(("Format for 'users' key must be a comma separated string"
|
||||
" or a dictionary or a list and not %s"),
|
||||
util.obj_name(base_users))
|
||||
type_utils.obj_name(base_users))
|
||||
base_users = []
|
||||
|
||||
if old_user:
|
||||
|
@ -32,7 +32,7 @@ class UnknownMerger(object):
|
||||
# Named differently so auto-method finding
|
||||
# doesn't pick this up if there is ever a type
|
||||
# named "unknown"
|
||||
def _handle_unknown(self, meth_wanted, value, merge_with):
|
||||
def _handle_unknown(self, _meth_wanted, value, _merge_with):
|
||||
return value
|
||||
|
||||
# This merging will attempt to look for a '_on_X' method
|
||||
@ -119,7 +119,8 @@ def string_extract_mergers(merge_how):
|
||||
continue
|
||||
match = NAME_MTCH.match(m_name)
|
||||
if not match:
|
||||
msg = "Matcher identifer '%s' is not in the right format" % (m_name)
|
||||
msg = ("Matcher identifer '%s' is not in the right format" %
|
||||
(m_name))
|
||||
raise ValueError(msg)
|
||||
(m_name, m_ops) = match.groups()
|
||||
m_ops = m_ops.strip().split(",")
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
class Merger(object):
|
||||
def __init__(self, merger, opts):
|
||||
def __init__(self, _merger, opts):
|
||||
self._append = 'append' in opts
|
||||
|
||||
# On encountering a unicode object to merge value with
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
from cloudinit import log as logging
|
||||
from cloudinit import sources
|
||||
from cloudinit import util
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -24,8 +24,6 @@ class FakeModule(handlers.Handler):
|
||||
|
||||
def handle_part(self, data, ctype, filename, payload, frequency):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
class TestWalkerHandleHandler(MockerTestCase):
|
||||
|
@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from tests.unittests import helpers
|
||||
|
||||
from cloudinit import mergers
|
||||
@ -107,8 +105,10 @@ class TestSimpleRun(helpers.MockerTestCase):
|
||||
self.assertEquals(merged['a'], [1, 'b', 2, 'e', 'f', 'g'])
|
||||
self.assertEquals(merged['b'], 'blahblahmore')
|
||||
self.assertEquals(merged['c']['f'], 'bigblobofstuff')
|
||||
self.assertEquals(merged['run'], ['runme', 'runme2', 'morecmd', 'moremoremore'])
|
||||
self.assertEquals(merged['runmereally'], ['e', ['a'], 'd', 'blah', ['b'], 'e'])
|
||||
self.assertEquals(merged['run'], ['runme', 'runme2', 'morecmd',
|
||||
'moremoremore'])
|
||||
self.assertEquals(merged['runmereally'], ['e', ['a'], 'd', 'blah',
|
||||
['b'], 'e'])
|
||||
|
||||
def test_dict_overwrite_layered(self):
|
||||
source = {
|
||||
|
@ -7,8 +7,6 @@ import os
|
||||
|
||||
from email.mime.base import MIMEBase
|
||||
|
||||
from mocker import MockerTestCase
|
||||
|
||||
from cloudinit import handlers
|
||||
from cloudinit import helpers as c_helpers
|
||||
from cloudinit import log
|
||||
@ -97,14 +95,16 @@ p: 1
|
||||
new_root = self.makeDir()
|
||||
self.patchUtils(new_root)
|
||||
self.patchOS(new_root)
|
||||
cloud_cfg.handle_part(None, handlers.CONTENT_START, None, None, None, None)
|
||||
cloud_cfg.handle_part(None, handlers.CONTENT_START, None, None, None,
|
||||
None)
|
||||
for i, m in enumerate(messages):
|
||||
headers = dict(m)
|
||||
fn = "part-%s" % (i + 1)
|
||||
payload = m.get_payload(decode=True)
|
||||
cloud_cfg.handle_part(None, headers['Content-Type'],
|
||||
fn, payload, None, headers)
|
||||
cloud_cfg.handle_part(None, handlers.CONTENT_END, None, None, None, None)
|
||||
cloud_cfg.handle_part(None, handlers.CONTENT_END, None, None, None,
|
||||
None)
|
||||
contents = util.load_file(paths.get_ipath('cloud_config'))
|
||||
contents = util.load_yaml(contents)
|
||||
self.assertEquals(contents['run'], ['b', 'c', 'stuff', 'morestuff'])
|
||||
@ -118,8 +118,9 @@ p: 1
|
||||
data = "arbitrary text\n"
|
||||
ci.datasource = FakeDataSource(data)
|
||||
|
||||
self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
|
||||
self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||
passthrough=False)
|
||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
self.mocker.replay()
|
||||
|
||||
log_file = self.capture_log(logging.WARNING)
|
||||
@ -136,8 +137,9 @@ p: 1
|
||||
message.set_payload("Just text")
|
||||
ci.datasource = FakeDataSource(message.as_string())
|
||||
|
||||
self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
|
||||
self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||
passthrough=False)
|
||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
self.mocker.replay()
|
||||
|
||||
log_file = self.capture_log(logging.WARNING)
|
||||
@ -154,9 +156,10 @@ p: 1
|
||||
ci.datasource = FakeDataSource(script)
|
||||
|
||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||
self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
|
||||
self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
self.mock_write(outpath, script, 0700)
|
||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||
passthrough=False)
|
||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
mock_write(outpath, script, 0700)
|
||||
self.mocker.replay()
|
||||
|
||||
log_file = self.capture_log(logging.WARNING)
|
||||
@ -173,9 +176,10 @@ p: 1
|
||||
ci.datasource = FakeDataSource(message.as_string())
|
||||
|
||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||
self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
|
||||
self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
self.mock_write(outpath, script, 0700)
|
||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||
passthrough=False)
|
||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
mock_write(outpath, script, 0700)
|
||||
self.mocker.replay()
|
||||
|
||||
log_file = self.capture_log(logging.WARNING)
|
||||
@ -192,9 +196,10 @@ p: 1
|
||||
ci.datasource = FakeDataSource(message.as_string())
|
||||
|
||||
outpath = os.path.join(ci.paths.get_ipath_cur("scripts"), "part-001")
|
||||
self.mock_write = self.mocker.replace("cloudinit.util.write_file", passthrough=False)
|
||||
self.mock_write(outpath, script, 0700)
|
||||
self.mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
mock_write = self.mocker.replace("cloudinit.util.write_file",
|
||||
passthrough=False)
|
||||
mock_write(outpath, script, 0700)
|
||||
mock_write(ci.paths.get_ipath("cloud_config"), "", 0600)
|
||||
self.mocker.replay()
|
||||
|
||||
log_file = self.capture_log(logging.WARNING)
|
||||
|
Loading…
x
Reference in New Issue
Block a user