=== modified file 'linaro_image_tools/tests/test_utils.py'
@@ -79,7 +79,7 @@
self.returncode = 0
return self
- def communicate(self, input = None):
+ def communicate(self, input=None):
self.wait()
return ': OK\n'.join(
TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n', ''
@@ -87,13 +87,12 @@
def wait(self):
return self.returncode
-
class MockCmdRunnerPopen_sha1sum_fail(object):
def __call__(self, cmd, *args, **kwargs):
self.returncode = 0
return self
- def communicate(self, input = None):
+ def communicate(self, input=None):
self.wait()
return ': ERROR\n'.join(
TestVerifyFileIntegrity.filenames_in_shafile) + ': ERROR\n', ''
@@ -101,13 +100,12 @@
def wait(self):
return self.returncode
-
class MockCmdRunnerPopen_wait_fails(object):
def __call__(self, cmd, *args, **kwargs):
self.returncode = 0
return self
- def communicate(self, input = None):
+ def communicate(self, input=None):
self.wait()
return ': OK\n'.join(
TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n', ''
@@ -196,6 +194,7 @@
self.assertFalse(result)
logging.getLogger().setLevel(logging.WARNING)
+
class TestEnsureCommand(TestCaseWithFixtures):
install_pkg_providing_called = False
@@ -238,7 +237,7 @@
if prefer_dir is None:
expected, _ = cmd_runner.run(
['which', lmc, ],
- stdout = subprocess.PIPE).communicate()
+ stdout=subprocess.PIPE).communicate()
expected = expected.strip()
else:
expected = os.path.join(prefer_dir, lmc)
@@ -279,14 +278,14 @@
self.useFixture(MockSomethingFixture(os, "makedirs", lambda x: x))
self.assertEqual("testdevice",
- prep_media_path(Args(directory = None,
- device = "testdevice",
- board = "testboard")))
+ prep_media_path(Args(directory=None,
+ device="testdevice",
+ board="testboard")))
self.assertEqual("/foo/bar/testdevice",
- prep_media_path(Args(directory = "/foo/bar",
- device = "testdevice",
- board = "testboard")))
+ prep_media_path(Args(directory="/foo/bar",
+ device="testdevice",
+ board="testboard")))
class TestPrepMediaPath(TestCaseWithFixtures):
@@ -296,15 +295,15 @@
self.useFixture(MockSomethingFixture(os, "makedirs", lambda x: x))
self.assertRaises(IncompatibleOptions, additional_option_checks,
- Args(directory = "/foo/bar",
- device = "/testdevice",
- board = "testboard"))
+ Args(directory="/foo/bar",
+ device="/testdevice",
+ board="testboard"))
sys.argv.append("--mmc")
self.assertRaises(IncompatibleOptions, additional_option_checks,
- Args(directory = "/foo/bar",
- device = "testdevice",
- board = "testboard"))
+ Args(directory="/foo/bar",
+ device="testdevice",
+ board="testboard"))
sys.argv.remove("--mmc")
@@ -321,11 +320,10 @@
try:
tmpdir = tempfile.mkdtemp()
self.assertRaises(InvalidHwpackFile, additional_option_checks,
- HwPackArgs(hwpack = tmpdir))
+ HwPackArgs(hwpack=tmpdir))
finally:
os.rmdir(tmpdir)
-
def test_hwpacks_are_files(self):
"""
=== modified file 'linaro_image_tools/utils.py'
@@ -43,8 +43,8 @@
``os.path.join``.
:param alternative: The value to return if no module can be imported.
Defaults to None.
- :param error_callback: If non-None, a callable that is passed the ImportError
- when the module cannot be loaded.
+ :param error_callback: If non-None, a callable that is passed the
+ ImportError when the module cannot be loaded.
"""
module_segments = name.split('.')
last_error = None
@@ -84,6 +84,7 @@
return False
tarinfo.close()
+
def verify_file_integrity(sig_file_list):
"""Verify a list of signature files.
@@ -104,8 +105,8 @@
tmp = tempfile.NamedTemporaryFile()
try:
- cmd_runner.run(['gpg', '--status-file={0}'.format(tmp.name),
- '--verify', sig_file]).wait()
+ cmd_runner.run(['gpg', '--status-file={0}'.format(tmp.name),
+ '--verify', sig_file]).wait()
except cmd_runner.SubcommandNonZeroReturnValue:
gpg_sig_ok = False
gpg_out = gpg_out + tmp.read()
@@ -134,6 +135,7 @@
return verified_files, gpg_sig_ok, gpg_out
+
def check_file_integrity_and_log_errors(sig_file_list, binary, hwpacks):
"""
Wrapper around verify_file_integrity that prints error messages to stderr
@@ -163,6 +165,7 @@
return True, verified_files
+
def install_package_providing(command):
"""Install a package which provides the given command.
@@ -196,6 +199,7 @@
except cmd_runner.SubcommandNonZeroReturnValue:
return False
+
def ensure_command(command):
"""Ensure the given command is available.
@@ -204,6 +208,7 @@
if not has_command(command):
install_package_providing(command)
+
def find_command(name, prefer_dir=None):
"""Finds a linaro-image-tools command.
@@ -218,7 +223,7 @@
# default to searching in current directory when running from a bzr
# checkout
- dirs = [os.getcwd(),]
+ dirs = [os.getcwd(), ]
if os.path.isabs(__file__):
dirs = os.environ["PATH"].split(os.pathsep)
# empty dir in PATH means current directory
@@ -253,7 +258,8 @@
try:
os.makedirs(loc)
except OSError:
- pass # Directory exists.
+ # Directory exists.
+ pass
path = os.path.join(loc, args.device)
else:
@@ -277,6 +283,7 @@
def __str__(self):
return repr(self.value)
+
def additional_option_checks(args):
if args.directory is not None:
# If args.device is a path to a device (/dev/) then this is an error
@@ -294,4 +301,3 @@
if not os.path.isfile(hwpack):
raise InvalidHwpackFile(
"--hwpack argument (%s) is not a regular file" % hwpack)
-