=== modified file 'linaro_image_tools/hwpack/builder.py'
@@ -38,7 +38,7 @@
FetchedPackage,
LocalArchiveMaker,
PackageFetcher,
- )
+)
from linaro_image_tools.hwpack.hwpack_fields import (
PACKAGE_FIELD,
@@ -124,8 +124,8 @@
wanted_package = package
break
else:
- raise AssertionError("Package '%s' was not fetched." % \
- wanted_package_name)
+ raise AssertionError("Package '%s' was not fetched." %
+ wanted_package_name)
return wanted_package
def add_file_to_hwpack(self, package, wanted_file, target_path):
@@ -167,8 +167,8 @@
base_dest_path = os.path.join(base_dest_path, self.config.bootloader)
# Extract bootloader file
if self.config.bootloader_package and self.config.bootloader_file:
- dest_path = os.path.join(base_dest_path,
- os.path.dirname(self.config.bootloader_file))
+ dest_path = os.path.join(
+ base_dest_path, os.path.dirname(self.config.bootloader_file))
self.do_extract_file(self.config.bootloader_package,
self.config.bootloader_file,
dest_path)
@@ -176,7 +176,7 @@
# Extract SPL file
if self.config.spl_package and self.config.spl_file:
dest_path = os.path.join(base_dest_path,
- os.path.dirname(self.config.spl_file))
+ os.path.dirname(self.config.spl_file))
self.do_extract_file(self.config.spl_package,
self.config.spl_file,
dest_path)
@@ -241,10 +241,10 @@
if self.format.format_as_string == '3.0':
if self.config.bootloaders is not None:
self.packages.extend(self.find_bootloader_packages(
- self.config.bootloaders))
+ self.config.bootloaders))
if self.config.boards is not None:
self.packages.extend(self.find_bootloader_packages(
- self.config.boards))
+ self.config.boards))
self.packages.extend(self.find_copy_files_packages())
else:
@@ -316,12 +316,12 @@
if self.config.bootloader_file is not None:
assert(self.config.bootloader_package is not None)
bootloader_package = self.find_fetched_package(
- self.packages,
- self.config.bootloader_package)
+ self.packages,
+ self.config.bootloader_package)
self.hwpack.metadata.u_boot = self.add_file_to_hwpack(
- bootloader_package,
- self.config.bootloader_file,
- self.hwpack.U_BOOT_DIR)
+ bootloader_package,
+ self.config.bootloader_file,
+ self.hwpack.U_BOOT_DIR)
spl_package = None
if self.config.spl_file is not None:
@@ -329,13 +329,13 @@
spl_package = self.find_fetched_package(self.packages,
self.config.spl_package)
self.hwpack.metadata.spl = self.add_file_to_hwpack(
- spl_package,
- self.config.spl_file,
- self.hwpack.SPL_DIR)
+ spl_package,
+ self.config.spl_file,
+ self.hwpack.SPL_DIR)
# bootloader_package and spl_package can be identical
if (bootloader_package is not None and
- bootloader_package in self.packages):
+ bootloader_package in self.packages):
self.packages.remove(bootloader_package)
if (spl_package is not None and spl_package in self.packages):
self.packages.remove(spl_package)
@@ -351,7 +351,7 @@
for local_package in local_packages:
if local_package not in self.packages:
logger.warning("Local package '%s' not included",
- local_package.name)
+ local_package.name)
self.hwpack.add_dependency_package(self.config.packages)
def _extract_build_info(self, cache_dir, out_name, manifest_name):
=== modified file 'linaro_image_tools/hwpack/config.py'
@@ -30,7 +30,7 @@
HardwarePackFormatV1,
HardwarePackFormatV2,
HardwarePackFormatV3,
- )
+)
from hwpack_fields import (
ARCHITECTURES_FIELD,
@@ -180,7 +180,7 @@
self.parser = yaml.safe_load(fp)
except yaml.YAMLError, e:
obfuscated_yaml_e = re.sub(r"([^ ]https://).+?(@)",
- r"\1***\2", str(e))
+ r"\1***\2", str(e))
else:
# If YAML parsed OK, we don't have an error.
obfuscated_e = None
@@ -333,7 +333,7 @@
return HardwarePackFormatV3()
else:
raise HwpackConfigError("Format version '%s' is not supported." %
- format_string)
+ format_string)
@property
def name(self):
@@ -348,7 +348,7 @@
def include_debs(self):
"""Whether the hardware pack should contain .debs. A bool."""
try:
- if self._get_option(self.INCLUDE_DEBS_KEY) == None:
+ if self._get_option(self.INCLUDE_DEBS_KEY) is None:
return True
try:
return self._get_option_bool(self.INCLUDE_DEBS_KEY)
@@ -419,7 +419,7 @@
else:
if len(value.keys()) > 1:
raise HwpackConfigError("copy_files entry found with"
- "more than one destination")
+ "more than one destination")
source_path = value.keys()[0]
dest_path = value[source_path]
@@ -427,7 +427,8 @@
# Target path should be relative, or start with /boot - we
# don't support to copying to anywhere other than /boot.
if dest_path[0] == "/":
- raise HwpackConfigError("copy_files destinations must"
+ raise HwpackConfigError(
+ "copy_files destinations must"
"be relative to /boot or start with /boot.")
dest_path = os.path.join("/boot", dest_path)
@@ -553,11 +554,11 @@
result = self._get_v3_option([BOARDS_FIELD, self.board] + keys)
# If a board specific value isn't found, look for a global one
- if result == None:
+ if result is None:
result = self._get_v3_option(keys)
# If no value is found, bail early (return None)
- if result == None:
+ if result is None:
return None
# <v3 compatibility: Lists of items can be converted to strings
@@ -951,8 +952,8 @@
if not format:
raise HwpackConfigError("Empty value for format")
if not format.is_supported:
- raise HwpackConfigError("Format version '%s' is not supported." % \
- format)
+ raise HwpackConfigError("Format version '%s' is not supported." %
+ format)
def _assert_matches_pattern(self, regex, config_item, error_message):
if re.match(regex, config_item) is None:
@@ -1066,7 +1067,7 @@
raise HwpackConfigError("Invalid %s address: %s" %
(name, self._get_option(key)))
- if addr == None:
+ if addr is None:
return
if not re.match(r"^0x[a-fA-F0-9]{8}$", addr):
@@ -1109,8 +1110,8 @@
mmc_id = self.mmc_id
if not mmc_id:
raise HwpackConfigError(
- "No mmc_id in the [%s] section" % \
- self.MAIN_SECTION)
+ "No mmc_id in the [%s] section" %
+ self.MAIN_SECTION)
else:
self._assert_matches_pattern(
r"[0-9]:[0-9]", mmc_id, "Invalid mmc_id %s" % mmc_id)
=== modified file 'linaro_image_tools/hwpack/handler.py'
@@ -232,12 +232,12 @@
if name != pkg_name:
continue
- if version != None and str(version) != pkg_version:
- continue
- if revision != None and str(revision) != pkg_revision:
- continue
- if (architecture != None and
- str(architecture) != pkg_architecture):
+ if version is not None and str(version) != pkg_version:
+ continue
+ if revision is not None and str(revision) != pkg_revision:
+ continue
+ if (architecture is not None and
+ str(architecture) != pkg_architecture):
continue
# Got a matching package - return its path inside the tarball
=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
@@ -28,7 +28,7 @@
FetchedPackage,
get_packages_file,
PackageMaker,
- )
+)
from linaro_image_tools.hwpack.hardwarepack_format import (
HardwarePackFormatV1,
)
@@ -238,11 +238,11 @@
spl_in_boot_part=config.spl_in_boot_part,
uboot_dd=config.bootloader_dd,
bootloader_file_in_boot_part=config.
- bootloader_file_in_boot_part,
+ bootloader_file_in_boot_part,
vmlinuz=config.vmlinuz,
wired_interfaces=config.wired_interfaces,
wireless_interfaces=config.wireless_interfaces,
- )
+ )
if config.format.format_as_string == '3.0':
metadata.add_v3_config(boards=config.boards,
bootloaders=config.bootloaders,
@@ -327,11 +327,11 @@
else:
extra_serial_options = self.extra_serial_options
metadata += dump({
- EXTRA_SERIAL_OPTIONS_FIELD:
- extra_serial_options})
+ EXTRA_SERIAL_OPTIONS_FIELD:
+ extra_serial_options})
if self.snowball_startup_files_config is not None:
metadata += dump({SNOWBALL_STARTUP_FILES_CONFIG_FIELD:
- self.snowball_startup_files_config})
+ self.snowball_startup_files_config})
if self.samsung_bl1_start is not None:
metadata += dump({SAMSUNG_BL1_START_FIELD: self.samsung_bl1_start})
if self.samsung_bl1_len is not None:
=== modified file 'linaro_image_tools/hwpack/hardwarepack_format.py'
@@ -36,9 +36,9 @@
if self.format_as_string is None:
raise NotImplementedError()
if self.is_deprecated:
- logger.warning("The format '%s' is deprecated, please update " \
- "your hardware pack configuration." % \
- self.format_as_string)
+ logger.warning("The format '%s' is deprecated, please update "
+ "your hardware pack configuration." %
+ self.format_as_string)
return self.format_as_string
=== modified file 'linaro_image_tools/hwpack/hwpack_convert.py'
@@ -69,7 +69,7 @@
UBOOT_DD_KEY = 'u_boot_dd'
# All the u_boot defined keys in a list.
UBOOT_KEYS = [UBOOT_PACKAGE_KEY, UBOOT_FILE_KEY, UBOOT_IN_BOOT_PART_KEY,
- UBOOT_DD_KEY]
+ UBOOT_DD_KEY]
# Old field, the only one with a dash: since the format is new, convert it.
ASSUME_INSTALLED_OLD = 'assume-installed'
@@ -150,26 +150,28 @@
elif re.match("[Nn]o", value):
value = False
if key == ARCHITECTURES_FIELD:
- self.parse_list_string(self.architectures,
- value)
+ self.parse_list_string(
+ self.architectures,
+ value)
continue
elif key == EXTRA_BOOT_OPTIONS_FIELD:
- self.parse_list_string(self.extra_boot_options,
- value)
+ self.parse_list_string(
+ self.extra_boot_options,
+ value)
continue
elif key == EXTRA_SERIAL_OPTIONS_FIELD:
self.parse_list_string(
- self.extra_serial_options,
- value)
+ self.extra_serial_options,
+ value)
continue
elif key == WIRED_INTERFACES_FIELD:
self.parse_list_string(self.wired_interfaces,
- value)
+ value)
continue
elif key == WIRELESS_INTERFACES_FIELD:
self.parse_list_string(
- self.wireless_interfaces,
- value)
+ self.wireless_interfaces,
+ value)
continue
elif key in SPL_KEYS:
self.spl[key] = value
@@ -185,8 +187,8 @@
# Create list.
elif key == ASSUME_INSTALLED_OLD:
self.parse_list_string(
- self.assume_installed,
- value)
+ self.assume_installed,
+ value)
continue
elif key == DTB_FILE_FIELD:
self.dtb_files.append({DEFAULT_DTB_NAME:
@@ -226,7 +228,7 @@
"""
if not isinstance(store, list):
raise HwpackConverterException("Can use this method only with "
- "list.")
+ "list.")
store.extend(string.split(" "))
def _to_file(self):
@@ -256,7 +258,7 @@
converted += dump(installed)
if self.extra_serial_options:
serial_options = {EXTRA_SERIAL_OPTIONS_FIELD:
- self.extra_serial_options}
+ self.extra_serial_options}
converted += dump(serial_options)
if self.packages:
packages = {PACKAGES_FIELD: self.packages}
@@ -282,7 +284,7 @@
nested_value[key] = value
if self.extra_boot_options:
nested_value[EXTRA_BOOT_OPTIONS_FIELD] = \
- self.extra_boot_options
+ self.extra_boot_options
if self.spl:
for key, value in self.spl.iteritems():
nested_value[key] = value
@@ -309,12 +311,12 @@
output_file = args.out
if not os.path.exists(input_file) or not os.path.isfile(input_file):
raise HwpackConverterException("The configuration file '%s' is not a "
- "regular file." % input_file)
+ "regular file." % input_file)
if output_file is not None:
if os.path.exists(output_file) or os.path.isdir(output_file):
raise HwpackConverterException("The output file name provided "
- "'%s' already exists, or is a "
- "directory." % output_file)
+ "'%s' already exists, or is a "
+ "directory." % output_file)
elif not os.path.isabs(output_file):
# If we output file is just a name, write it in the current dir.
output_file = os.path.join(os.getcwd(), output_file)
=== modified file 'linaro_image_tools/hwpack/hwpack_fields.py'
@@ -96,7 +96,7 @@
BOOTFS16,
BOOTFS,
RESERVED_BOOTFS,
- ]
+]
# Supported bootloaders
U_BOOT = 'u_boot'
@@ -150,7 +150,8 @@
SNOWBALL_STARTUP_FILES_CONFIG_FIELD: None,
SOURCES_FIELD: None,
BOOTLOADERS_FIELD: {
- "*": {
+ "*":
+ {
PACKAGE_FIELD: None,
FILE_FIELD: None,
IN_BOOT_PART_FIELD: None,
@@ -162,7 +163,7 @@
SPL_IN_BOOT_PART_FIELD: None,
SPL_DD_FIELD: None,
ENV_DD_FIELD: None,
- }
+ }
},
BOARDS_FIELD: "root",
}
=== modified file 'linaro_image_tools/hwpack/hwpack_reader.py'
@@ -95,9 +95,9 @@
equal = False
if isinstance(other, Hwpack):
equal = (self.name == other.name and
- self.boards == other.boards and
- self.hwpack == other.hwpack and
- self.bootloaders == other.bootloaders)
+ self.boards == other.boards and
+ self.hwpack == other.hwpack and
+ self.bootloaders == other.bootloaders)
return equal
def __hash__(self):
@@ -123,20 +123,20 @@
supported_bootloaders = bootloaders.keys()
else:
supported_bootloaders = self.bootloaders.keys()
- string += ELEMENT_FORMAT.format(key,
- ",".join(supported_bootloaders))
+ string += ELEMENT_FORMAT.format(
+ key, ",".join(supported_bootloaders))
string += LINE_SEP
else:
# If we pass a converted file with just a single board, we do not
# have the boards section, and we default to the name of the hwpack
if self.bootloaders:
supported_bootloaders = self.bootloaders.keys()
- string += ELEMENT_FORMAT.format(self.name,
- ",".join(supported_bootloaders))
+ string += ELEMENT_FORMAT.format(
+ self.name, ",".join(supported_bootloaders))
string += LINE_SEP
else:
string += CENTER_ALIGN.format("No supported boards and "
- "bootloaders")
+ "bootloaders")
string += LINE_SEP
string += FORMAT.format(SEPARATOR)
return string + LINE_SEP
@@ -169,7 +169,7 @@
local_hwpack.setname(handler.get_field(NAME_FIELD)[0])
local_hwpack.setboards(handler.get_field(BOARDS_FIELD)[0])
local_hwpack.setbootloaders(
- handler.get_field(BOOTLOADERS_FIELD)[0])
+ handler.get_field(BOOTLOADERS_FIELD)[0])
self.supported_elements.append(local_hwpack)
else:
raise HwpackReaderError("Hardwarepack '%s' cannot be "
=== modified file 'linaro_image_tools/hwpack/packages.py'
@@ -241,7 +241,7 @@
name=name,
relationships=''.join(relationship_strs),
version=version,
- )
+ )
control_file_text = self.control_file_template.safe_substitute(
subst_vars)
@@ -253,7 +253,7 @@
new_file.write(name + " " + file_path)
with open(os.path.join(
- packaging_dir, 'DEBIAN', 'control'), 'w') as control_file:
+ packaging_dir, 'DEBIAN', 'control'), 'w') as control_file:
control_file.write(control_file_text)
env = os.environ
env['LC_ALL'] = 'C'
@@ -494,7 +494,7 @@
"etc/apt/sources.list.d",
"var/cache/apt/archives/partial",
"var/lib/apt/lists/partial",
- ]
+ ]
for d in dirs:
os.makedirs(os.path.join(self.tempdir, d))
self.set_installed_packages([], reopen=False)
@@ -575,7 +575,7 @@
is reopened.
"""
with open(
- os.path.join(self.tempdir, "var/lib/dpkg/status"), "w") as f:
+ os.path.join(self.tempdir, "var/lib/dpkg/status"), "w") as f:
f.write(
get_packages_file(
packages, extra_text="Status: install ok installed"))
@@ -658,7 +658,7 @@
raise DependencyNotSatisfied(
"Unable to satisfy dependencies of %s" %
", ".join([p.name for p in self.cache.cache
- if p.is_inst_broken]))
+ if p.is_inst_broken]))
installed = []
for package in self.cache.cache.get_changes():
candidate = package.candidate
@@ -673,7 +673,7 @@
logger.debug("Ignored %s" % package.name)
self.cache.set_installed_packages(installed)
broken = [p.name for p in self.cache.cache
- if p.is_inst_broken or p.is_now_broken]
+ if p.is_inst_broken or p.is_now_broken]
if broken:
# If this happens then there is a bug, as we should have
# caught this problem earlier
@@ -728,7 +728,7 @@
raise DependencyNotSatisfied(
"Unable to satisfy dependencies of %s" %
", ".join([p.name for p in self.cache.cache
- if p.is_inst_broken]))
+ if p.is_inst_broken]))
for package in packages:
try:
@@ -750,7 +750,7 @@
acqfiles = []
# re to remove the repo private key
deb_url_auth_re = re.compile(
- r"(?P<transport>.*://)(?P<user>.*):.*@(?P<path>.*$)")
+ r"(?P<transport>.*://)(?P<user>.*):.*@(?P<path>.*$)")
for package in self.cache.cache.get_changes():
if (package.marked_delete or package.marked_keep):
continue
=== modified file 'linaro_image_tools/hwpack/tarfile_matchers.py'
@@ -149,9 +149,8 @@
if self.path not in tarball.getnames():
return TarfileMissingPathMismatch(tarball, self.path)
info = tarball.getmember(self.path)
- for attr in (
- "type", "size", "mode", "linkname", "uid", "gid",
- "uname", "gname"):
+ for attr in ("type", "size", "mode", "linkname",
+ "uid", "gid", "uname", "gname"):
expected = getattr(self, attr, None)
if expected is not None:
actual = getattr(info, attr)
@@ -170,7 +169,7 @@
for name in tarball.getnames():
name_frags = name.split('/')
if (len(name_frags) == len(path_frags) + 1 and
- name_frags[:-1] == path_frags):
+ name_frags[:-1] == path_frags):
contents.append(name_frags[-1])
content_mismatch = self.content_matcher.match(contents)
if content_mismatch:
=== modified file 'linaro_image_tools/hwpack/testing.py'
@@ -39,7 +39,7 @@
from linaro_image_tools.hwpack.packages import (
get_packages_file,
FetchedPackage,
- )
+)
@contextmanager
@@ -150,8 +150,7 @@
def setUp(self):
self.rootdir = tempfile.mkdtemp(prefix="hwpack-apt-source-")
for package in self.packages:
- with open(
- os.path.join(self.rootdir, package.filename), 'wb') as f:
+ with open(os.path.join(self.rootdir, package.filename), 'wb') as f:
f.write(package.content.read())
with open(os.path.join(self.rootdir, "Packages"), 'wb') as f:
f.write(get_packages_file(self.packages))
@@ -365,13 +364,13 @@
MatchesSetwise(*map(Equals, manifest_lines)))))
matchers.append(HardwarePackHasFile("pkgs", type=tarfile.DIRTYPE))
packages_with_content = [p for p in self.packages
- if p not in self.packages_without_content]
+ if p not in self.packages_without_content]
for package in packages_with_content:
matchers.append(HardwarePackHasFile(
"pkgs/%s" % package.filename,
content=package.content.read()))
package_matchers = [
- MatchesPackage(p) for p in packages_with_content]
+ MatchesPackage(p) for p in packages_with_content]
dep_package_matcher = MatchesStructure(
name=Equals('hwpack-' + self.metadata.name),
version=Equals(self.metadata.version),
@@ -548,7 +547,7 @@
msg += ': ' + str(extra_values)
return Annotate(
msg, EachOf(remaining_matchers[:common_length])
- ).match(not_matched[:common_length])
+ ).match(not_matched[:common_length])
def parse_packages_file_content(file_content):
=== modified file 'linaro_image_tools/hwpack/tests/__init__.py'
@@ -35,7 +35,7 @@
'linaro_image_tools.hwpack.tests.test_script',
'linaro_image_tools.hwpack.tests.test_tarfile_matchers',
'linaro_image_tools.hwpack.tests.test_testing',
- ]
+ ]
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(module_names)
return suite
=== modified file 'linaro_image_tools/hwpack/tests/test_builder.py'
@@ -30,13 +30,13 @@
PackageUnpacker,
HardwarePackBuilder,
logger as builder_logger,
- )
+)
from linaro_image_tools.hwpack.config import HwpackConfigError
from linaro_image_tools.hwpack.hardwarepack import Metadata
from linaro_image_tools.hwpack.packages import (
FetchedPackage,
PackageMaker,
- )
+)
from linaro_image_tools.hwpack.tarfile_matchers import TarfileHasFile
from linaro_image_tools.hwpack.testing import (
AppendingHandler,
@@ -49,12 +49,12 @@
IsHardwarePack,
MatchesStructure,
Not,
- )
+)
from linaro_image_tools.testing import TestCaseWithFixtures
from linaro_image_tools.tests.fixtures import (
MockSomethingFixture,
MockCmdRunnerPopenFixture,
- )
+)
class ConfigFileMissingTests(TestCase):
@@ -93,19 +93,20 @@
file = 'dummyfile'
with PackageUnpacker() as package_unpacker:
self.useFixture(MockSomethingFixture(
- package_unpacker, 'unpack_package', lambda package: None))
+ package_unpacker, 'unpack_package', lambda package: None))
self.useFixture(MockSomethingFixture(
- os.path, 'exists', lambda file: True))
+ os.path, 'exists', lambda file: True))
tempfile = package_unpacker.get_file(package, file)
self.assertEquals(tempfile,
- os.path.join(package_unpacker.get_path(package), file))
+ os.path.join(package_unpacker.get_path(package),
+ file))
def test_get_file_raises(self):
package = 'package'
file = 'dummyfile'
with PackageUnpacker() as package_unpacker:
self.useFixture(MockSomethingFixture(
- package_unpacker, 'unpack_package', lambda package: None))
+ package_unpacker, 'unpack_package', lambda package: None))
self.assertRaises(AssertionError, package_unpacker.get_file,
package, file)
@@ -118,9 +119,9 @@
file = 'dummyfile'
with PackageUnpacker() as package_unpacker:
self.useFixture(MockSomethingFixture(
- package_unpacker, 'unpack_package', lambda package: None))
+ package_unpacker, 'unpack_package', lambda package: None))
self.useFixture(MockSomethingFixture(
- os.path, 'exists', lambda file: True))
+ os.path, 'exists', lambda file: True))
tempfile1 = package_unpacker.get_file(package1, file)
tempfile2 = package_unpacker.get_file(package2, file)
self.assertNotEquals(tempfile1, tempfile2)
@@ -128,20 +129,20 @@
class HardwarePackBuilderTests(TestCaseWithFixtures):
config_v3 = "\n".join(["format: 3.0",
- "name: ahwpack",
- "architectures: armel",
- "serial_tty: ttySAC1",
- "partition_layout:",
- " - bootfs_rootfs",
- "boot_script: boot.scr",
- "mmc_id: 0:1",
- "kernel_file: boot/vmlinuz-*-linaro-omap",
- "initrd_file: boot/initrd.img-*-linaro-omap",
- "dtb_file: boot/dt-*-linaro-omap/omap4-panda.dtb",
- "packages:",
- " - %s",
- " - %s",
- ""])
+ "name: ahwpack",
+ "architectures: armel",
+ "serial_tty: ttySAC1",
+ "partition_layout:",
+ " - bootfs_rootfs",
+ "boot_script: boot.scr",
+ "mmc_id: 0:1",
+ "kernel_file: boot/vmlinuz-*-linaro-omap",
+ "initrd_file: boot/initrd.img-*-linaro-omap",
+ "dtb_file: boot/dt-*-linaro-omap/omap4-panda.dtb",
+ "packages:",
+ " - %s",
+ " - %s",
+ ""])
bootloader_config = "\n".join([" package: %s",
" in_boot_part: %s",
""])
@@ -273,7 +274,7 @@
builder = HardwarePackBuilder(config.filename, metadata.version, [])
builder.build()
hwpack_filename = "hwpack_%s_%s_%s.tar.gz" % (
- metadata.name, metadata.version, metadata.architecture)
+ metadata.name, metadata.version, metadata.architecture)
self.assertThat(
hwpack_filename,
IsHardwarePack(
@@ -433,11 +434,11 @@
package_names = ['package0', 'package1', 'package2', 'package3']
files = {
package_names[0]:
- ["usr/lib/u-boot/omap4_panda/u-boot.img",
- "usr/share/doc/u-boot-linaro-omap4-panda/copyright"],
+ ["usr/lib/u-boot/omap4_panda/u-boot.img",
+ "usr/share/doc/u-boot-linaro-omap4-panda/copyright"],
package_names[1]:
- ["usr/lib/u-boot/omap4_panda/u-boot.img",
- "some/path/file"],
+ ["usr/lib/u-boot/omap4_panda/u-boot.img",
+ "some/path/file"],
package_names[2]: [],
package_names[3]: [],
}
=== modified file 'linaro_image_tools/hwpack/tests/test_config.py'
@@ -87,54 +87,54 @@
def test_validate_invalid_include_debs(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\n"
- "include-debs = if you don't mind\n")
+ "[hwpack]\nname = ahwpack\n"
+ "include-debs = if you don't mind\n")
self.assertValidationError(
"Invalid value for include-debs: Not a boolean: if you don't mind",
config)
def test_validate_invalid_supported(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\nsupport = if you pay us\n")
+ "[hwpack]\nname = ahwpack\nsupport = if you pay us\n")
self.assertValidationError(
"Invalid value for support: if you pay us", config)
def test_validate_no_packages(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\n\n")
+ "[hwpack]\nname = ahwpack\n\n")
self.assertValidationError(
"No packages in the [hwpack] section", config)
def test_validate_empty_packages(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\npackages = \n")
+ "[hwpack]\nname = ahwpack\npackages = \n")
self.assertValidationError(
"No packages in the [hwpack] section", config)
def test_validate_invalid_package_name(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\npackages = foo ~~ bar\n")
+ "[hwpack]\nname = ahwpack\npackages = foo ~~ bar\n")
self.assertValidationError(
"Invalid value in packages in the [hwpack] section: ~~",
config)
def test_validate_no_architectures(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\npackages = foo\n")
+ "[hwpack]\nname = ahwpack\npackages = foo\n")
self.assertValidationError(
"No architectures in the [hwpack] section", config)
def test_validate_empty_architectures(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\npackages = foo\n"
- "architectures = \n")
+ "[hwpack]\nname = ahwpack\npackages = foo\n"
+ "architectures = \n")
self.assertValidationError(
"No architectures in the [hwpack] section", config)
def test_validate_invalid_package_name_in_assume_installed(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\npackages = foo\n"
- "architectures = armel\nassume-installed = bar ~~\n")
+ "[hwpack]\nname = ahwpack\npackages = foo\n"
+ "architectures = armel\nassume-installed = bar ~~\n")
self.assertValidationError(
"Invalid value in assume-installed in the [hwpack] section: ~~",
config)
@@ -151,48 +151,48 @@
def test_validate_other_section_empty_sources_entry(self):
config = self.get_config(
- self.valid_start + "\n[ubuntu]\nsources-entry = \n")
+ self.valid_start + "\n[ubuntu]\nsources-entry = \n")
self.assertValidationError(
"The sources-entry in the [ubuntu] section is missing the URI",
config)
def test_validate_other_section_only_uri_in_sources_entry(self):
config = self.get_config(
- self.valid_start + "\n[ubuntu]\nsources-entry = foo\n")
+ self.valid_start + "\n[ubuntu]\nsources-entry = foo\n")
self.assertValidationError(
"The sources-entry in the [ubuntu] section is missing the "
"distribution", config)
def test_validate_other_section_sources_entry_starting_with_deb(self):
config = self.get_config(
- self.valid_start
- + "\n[ubuntu]\nsources-entry = deb http://example.org/ "
- "foo main\n")
+ self.valid_start
+ + "\n[ubuntu]\nsources-entry = deb http://example.org/ "
+ "foo main\n")
self.assertValidationError(
"The sources-entry in the [ubuntu] section shouldn't start "
"with 'deb'", config)
def test_validate_other_section_sources_entry_starting_with_deb_src(self):
config = self.get_config(
- self.valid_start
- + "\n[ubuntu]\nsources-entry = deb-src http://example.org/ "
- "foo main\n")
+ self.valid_start
+ + "\n[ubuntu]\nsources-entry = deb-src http://example.org/ "
+ "foo main\n")
self.assertValidationError(
"The sources-entry in the [ubuntu] section shouldn't start "
"with 'deb'", config)
def test_validate_valid_config(self):
config = self.get_config(
- self.valid_start
- + "\n[ubuntu]\nsources-entry = foo bar\n")
+ self.valid_start
+ + "\n[ubuntu]\nsources-entry = foo bar\n")
self.assertEqual(None, config.validate())
def test_validate_valid_config_with_dash_in_package_name(self):
config = self.get_config(
- "[hwpack]\nname = ahwpack\n"
- "packages = u-boot\n"
- "architectures = armel\n\n"
- "[ubuntu]\nsources-entry = foo bar\n")
+ "[hwpack]\nname = ahwpack\n"
+ "packages = u-boot\n"
+ "architectures = armel\n\n"
+ "[ubuntu]\nsources-entry = foo bar\n")
self.assertEqual(None, config.validate())
def test_validate_supported_format(self):
@@ -202,91 +202,91 @@
def test_validate_invalid_u_boot_package_name(self):
config = self.get_config(
- self.valid_start_v2 + "u_boot_package = ~~\n")
+ self.valid_start_v2 + "u_boot_package = ~~\n")
self.assertValidationError(
"Invalid value in u_boot_package in the [hwpack] section: ~~",
config)
def test_validate_invalid_u_boot_file(self):
config = self.get_config(self.valid_start_v2 +
- "u_boot_package = u-boot-linaro-s5pv310\n" \
- "u_boot_file = ~~\n")
+ "u_boot_package = u-boot-linaro-s5pv310\n"
+ "u_boot_file = ~~\n")
self.assertValidationError("Invalid path: ~~", config)
def test_validate_invalid_kernel_file(self):
config = self.get_config(self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = ~~\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = ~~\n")
self.assertValidationError("Invalid path: ~~", config,
"_validate_vmlinuz")
def test_validate_empty_kernel_file(self):
config = self.get_config(self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n"
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = \n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = \n")
self.assertValidationError("No kernel_file in the [hwpack] section",
config, "_validate_vmlinuz")
def test_validate_invalid_initrd_file(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = ~~\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = ~~\n")
self.assertValidationError("Invalid path: ~~", config,
"_validate_initrd")
def test_validate_empty_initrd_file(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n"
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = \n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = \n")
self.assertValidationError("No initrd_file in the [hwpack] section",
config, "_validate_initrd")
def test_validate_invalid_boot_script(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "mmc_id = 0:1\n"\
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\
- "u_boot_in_boot_part = No\n"\
- "boot_script = ~~\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "mmc_id = 0:1\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"
+ "u_boot_in_boot_part = No\n"
+ "boot_script = ~~\n")
self.assertValidationError("Invalid path: ~~", config)
def test_validate_invalid_dtb_file(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\
- "boot_script = boot.scr\n"\
- "u_boot_in_boot_part = No\n"\
- "mmc_id = 0:1\n"\
- "dtb_file = ~~\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"
+ "boot_script = boot.scr\n"
+ "u_boot_in_boot_part = No\n"
+ "mmc_id = 0:1\n"
+ "dtb_file = ~~\n")
self.assertValidationError("Invalid path: ~~", config)
def test_validate_invalid_spl_package_name(self):
config = self.get_config(
- self.valid_start_v2 + "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = usr/bin/version/MLO\n" \
- "partition_layout = bootfs_rootfs\n"\
- "mmc_id = 0:1\n"\
- "spl_package = ~~\n")
+ self.valid_start_v2 + "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = usr/bin/version/MLO\n"
+ "partition_layout = bootfs_rootfs\n"
+ "mmc_id = 0:1\n"
+ "spl_package = ~~\n")
self.assertValidationError(
"Invalid value in spl_package in the [hwpack] section: ~~",
config)
@@ -294,18 +294,18 @@
def test_validate_invalid_spl_file(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = usr/bin/version/MLO\n" \
- "partition_layout = bootfs_rootfs\n" \
- "spl_package = x-loader--linaro-s5pv310\n" \
- "spl_file = ~~\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = usr/bin/version/MLO\n"
+ "partition_layout = bootfs_rootfs\n"
+ "spl_package = x-loader--linaro-s5pv310\n"
+ "spl_file = ~~\n")
self.assertValidationError("Invalid path: ~~", config)
def test_validate_partition_layout(self):
partition_layout = 'apafs_bananfs'
- config = self.get_config(self.valid_start_v2 + "u_boot_package = " \
- "u-boot-linaro-s5pv310\nu_boot_file = " \
- "u-boot.bin\npartition_layout = %s\n" % \
+ config = self.get_config(self.valid_start_v2 + "u_boot_package = "
+ "u-boot-linaro-s5pv310\nu_boot_file = "
+ "u-boot.bin\npartition_layout = %s\n" %
partition_layout)
self.assertValidationError(
"Undefined partition layout %s in the [%s] section. "
@@ -323,43 +323,43 @@
def test_validate_u_boot_in_boot_part(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\
- "boot_script = boot.scr\n"\
- "mmc_id = 0:1\n"\
- "u_boot_in_boot_part = Nope\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"
+ "boot_script = boot.scr\n"
+ "mmc_id = 0:1\n"
+ "u_boot_in_boot_part = Nope\n")
self.assertValidationError(
"Invalid value for u_boot_in_boot_part: Nope", config)
def test_validate_u_boot_in_boot_part_bool(self):
config = self.get_config(
self.valid_start_v2 +
- "u-boot-package = u-boot-linaro-s5pv310\n" \
- "u-boot-file = u-boot.bin\n" \
- "partition_layout = bootfs_rootfs\n"\
- "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\
- "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\
- "boot_script = boot.scr\n"\
- "mmc_id = 0:1\n"\
- "u_boot_in_boot_part = True\n")
+ "u-boot-package = u-boot-linaro-s5pv310\n"
+ "u-boot-file = u-boot.bin\n"
+ "partition_layout = bootfs_rootfs\n"
+ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"
+ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"
+ "boot_script = boot.scr\n"
+ "mmc_id = 0:1\n"
+ "u_boot_in_boot_part = True\n")
self.assertValidationError(
"Invalid value for u_boot_in_boot_part: True", config)
def test_validate_serial_tty(self):
config = self.get_config(
self.valid_start_v2 +
- "u_boot_package = u-boot-linaro-s5pv310\n" \
- "u_boot_file = u-boot.bin\nserial_tty=tty\n")
+ "u_boot_package = u-boot-linaro-s5pv310\n"
+ "u_boot_file = u-boot.bin\nserial_tty=tty\n")
self.assertValidationError("Invalid serial tty: tty", config,
"_validate_serial_tty")
config = self.get_config(
self.valid_start_v2 +
- "u_boot_package = u-boot-linaro-s5pv310\n" \
- "u_boot_file = u-boot.bin\n" \
- "serial_tty=ttxSAC1\n")
+ "u_boot_package = u-boot-linaro-s5pv310\n"
+ "u_boot_file = u-boot.bin\n"
+ "serial_tty=ttxSAC1\n")
self.assertValidationError("Invalid serial tty: ttxSAC1", config,
"_validate_serial_tty")
=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
@@ -41,32 +41,32 @@
"name: ahwpack\npackages: foo\narchitectures: armel\n")
valid_start_v3 = valid_start + "format: 3.0\n"
valid_complete_v3 = (valid_start_v3 +
- "serial_tty: ttySAC1\n"
- "partition_layout:\n"
- " - bootfs_rootfs\n"
- "boot_script: boot.scr\n"
- "extra_serial_options:\n"
- " - console=tty0\n"
- " - console=ttyO2,115200n8\n"
- "mmc_id: 0:1\n"
- "kernel_file: boot/vmlinuz-*-linaro-omap\n"
- "initrd_file: boot/initrd.img-*-linaro-omap\n"
- "dtb_file: boot/dt-*-linaro-omap/omap4-panda.dtb\n"
- "bootloaders:\n"
- " u_boot:\n"
- " package: u-boot-linaro-s5pv310\n"
- " file: usr/lib/u-boot/smdkv310/u-boot.bin\n"
- " spl_package: x-loader-omap4-panda\n"
- " spl_file: usr/lib/x-loader/omap4430panda/MLO\n"
- " in_boot_part: True\n"
- " extra_boot_options:\n"
- " - earlyprintk\n"
- " - fixrtc\n"
- " - nocompcache\n"
- " - vram=48M\n"
- " - omapfb.vram=0:24M\n"
- " - mem=456M@0x80000000\n"
- " - mem=512M@0xA0000000\n")
+ "serial_tty: ttySAC1\n"
+ "partition_layout:\n"
+ " - bootfs_rootfs\n"
+ "boot_script: boot.scr\n"
+ "extra_serial_options:\n"
+ " - console=tty0\n"
+ " - console=ttyO2,115200n8\n"
+ "mmc_id: 0:1\n"
+ "kernel_file: boot/vmlinuz-*-linaro-omap\n"
+ "initrd_file: boot/initrd.img-*-linaro-omap\n"
+ "dtb_file: boot/dt-*-linaro-omap/omap4-panda.dtb\n"
+ "bootloaders:\n"
+ " u_boot:\n"
+ " package: u-boot-linaro-s5pv310\n"
+ " file: usr/lib/u-boot/smdkv310/u-boot.bin\n"
+ " spl_package: x-loader-omap4-panda\n"
+ " spl_file: usr/lib/x-loader/omap4430panda/MLO\n"
+ " in_boot_part: True\n"
+ " extra_boot_options:\n"
+ " - earlyprintk\n"
+ " - fixrtc\n"
+ " - nocompcache\n"
+ " - vram=48M\n"
+ " - omapfb.vram=0:24M\n"
+ " - mem=456M@0x80000000\n"
+ " - mem=512M@0xA0000000\n")
valid_end = "sources:\n sources-entry: foo bar\n"
def test_create(self):
@@ -97,64 +97,64 @@
def test_validate_invalid_include_debs(self):
config = self.get_config(
- "name: ahwpack\n"
- "include_debs: if you don't mind\n")
+ "name: ahwpack\n"
+ "include_debs: if you don't mind\n")
self.assertValidationError(
"Invalid value for include-debs: if you don't mind",
config._validate_include_debs)
def test_validate_invalid_supported(self):
config = self.get_config(
- "name: ahwpack\nsupport: if you pay us\n")
+ "name: ahwpack\nsupport: if you pay us\n")
self.assertValidationError(
"Invalid value for support: if you pay us",
config._validate_support)
def test_validate_no_packages(self):
config = self.get_config(
- "name: ahwpack\n\n")
+ "name: ahwpack\n\n")
self.assertValidationError(
"No packages found in the metadata", config._validate_packages)
def test_validate_empty_packages(self):
config = self.get_config(
- "name: ahwpack\npackages: \n")
+ "name: ahwpack\npackages: \n")
self.assertValidationError(
"No packages found in the metadata", config._validate_packages)
def test_validate_invalid_package_name(self):
config = self.get_config(
- "name: ahwpack\npackages: foo ~~ bar\n")
+ "name: ahwpack\npackages: foo ~~ bar\n")
self.assertValidationError(
"Invalid value in packages in the metadata: ~~",
config._validate_packages)
def test_validate_no_architectures(self):
config = self.get_config(
- "name: ahwpack\npackages: foo\n")
+ "name: ahwpack\npackages: foo\n")
self.assertValidationError(
"No architectures found in the metadata",
config._validate_architectures)
def test_validate_empty_architectures(self):
config = self.get_config(
- "name: ahwpack\npackages: foo\n"
- "architectures: \n")
+ "name: ahwpack\npackages: foo\n"
+ "architectures: \n")
self.assertValidationError(
"No architectures found in the metadata",
config._validate_architectures)
def test_validate_invalid_package_name_in_assume_installed(self):
config = self.get_config(
- "name: ahwpack\npackages: foo\n"
- "architectures: armel\nassume_installed:\n - bar\n - ~~\n")
+ "name: ahwpack\npackages: foo\n"
+ "architectures: armel\nassume_installed:\n - bar\n - ~~\n")
self.assertValidationError(
"Invalid value in assume-installed in the metadata: ~~",
config._validate_assume_installed)
def test_validate_other_section_empty_sources_entry(self):
config = self.get_config(
- self.valid_start + "sources:\n ubuntu: \n")
+ self.valid_start + "sources:\n ubuntu: \n")
self.assertValidationError(
"The sources-entry, ubuntu is missing the URI",
config._validate_sources)
@@ -167,14 +167,16 @@
config._validate_sources)
def test_validate_other_section_sources_entry_starting_with_deb(self):
- config = self.get_config(self.valid_start +
- "sources:\n ubuntu: deb http://example.org/ foo main\n")
+ config = self.get_config(
+ self.valid_start +
+ "sources:\n ubuntu: deb http://example.org/ foo main\n")
self.assertValidationError(
"The sources-entry, ubuntu shouldn't start with 'deb'",
config._validate_sources)
def test_validate_other_section_sources_entry_starting_with_deb_src(self):
- config = self.get_config(self.valid_start +
+ config = self.get_config(
+ self.valid_start +
"sources:\n ubuntu: deb-src http://example.org/ foo main\n")
self.assertValidationError(
"The sources-entry, ubuntu shouldn't start with 'deb'",
=== modified file 'linaro_image_tools/hwpack/tests/test_hardwarepack.py'
@@ -36,12 +36,12 @@
MatchesPackageRelationshipList,
MatchesStructure,
Not,
- )
+)
from linaro_image_tools.hwpack.hardwarepack_format import (
HardwarePackFormatV1,
HardwarePackFormatV2,
HardwarePackFormatV3,
- )
+)
class MetadataTests(TestCase):
@@ -287,7 +287,7 @@
def test_format(self):
metadata = Metadata("ahwpack", "4", "armel",
- format=HardwarePackFormatV3())
+ format=HardwarePackFormatV3())
# Need to call also this one!
metadata.add_v2_config()
metadata.add_v3_config(bootloaders=None)
@@ -298,7 +298,7 @@
def test_section_bootloaders(self):
bootloaders = {'u_boot': {'file': 'a_file'}}
metadata = Metadata("ahwpack", "4", "armel",
- format=HardwarePackFormatV3())
+ format=HardwarePackFormatV3())
# Need to call also this one!
metadata.add_v2_config()
metadata.add_v3_config(bootloaders=bootloaders)
@@ -309,7 +309,7 @@
def test_section_wireless(self):
metadata = Metadata("ahwpack", "4", "armel",
- format=HardwarePackFormatV3())
+ format=HardwarePackFormatV3())
wireless_list = ['wlan0', 'wl0']
# Need to call also this one!
metadata.add_v2_config(wireless_interfaces=wireless_list)
@@ -321,7 +321,7 @@
def test_section_wired(self):
metadata = Metadata("ahwpack", "4", "armel",
- format=HardwarePackFormatV3())
+ format=HardwarePackFormatV3())
wired_list = ['eth0', 'usb0']
# Need to call also this one!
metadata.add_v2_config(wired_interfaces=wired_list)
@@ -332,7 +332,7 @@
def test_section_extra_serial_options(self):
metadata = Metadata("ahwpack", "4", "armel",
- format=HardwarePackFormatV3())
+ format=HardwarePackFormatV3())
options = ['option1', 'option2,option3']
# Need to call also this one!
metadata.add_v2_config(extra_serial_options=options)
@@ -388,7 +388,7 @@
self.assertThat(
tf,
HardwarePackHasFile("FORMAT",
- content=hwpack.format.__str__() + "\n"))
+ content=hwpack.format.__str__() + "\n"))
def test_creates_metadata_file(self):
metadata = Metadata(
@@ -432,7 +432,7 @@
self.assertThat(
tf,
HardwarePackHasFile("pkgs/%s" % package.filename,
- content=package.content.read()))
+ content=package.content.read()))
def test_adds_multiple_packages_at_once(self):
package1 = DummyFetchedPackage("foo", "1.1")
@@ -443,11 +443,11 @@
self.assertThat(
tf,
HardwarePackHasFile("pkgs/%s" % package1.filename,
- content=package1.content.read()))
+ content=package1.content.read()))
self.assertThat(
tf,
HardwarePackHasFile("pkgs/%s" % package2.filename,
- content=package2.content.read()))
+ content=package2.content.read()))
def test_adds_multiple_in_multiple_steps(self):
package1 = DummyFetchedPackage("foo", "1.1")
@@ -459,11 +459,11 @@
self.assertThat(
tf,
HardwarePackHasFile("pkgs/%s" % package1.filename,
- content=package1.content.read()))
+ content=package1.content.read()))
self.assertThat(
tf,
HardwarePackHasFile("pkgs/%s" % package2.filename,
- content=package2.content.read()))
+ content=package2.content.read()))
def test_add_packages_without_content_leaves_out_debs(self):
package1 = DummyFetchedPackage("foo", "1.1", no_content=True)
@@ -582,7 +582,7 @@
tf = self.get_tarfile(hwpack)
self.assertThat(
tf, HardwarePackHasFile("sources.list.d/ubuntu.list",
- content="deb " + source + "\n"))
+ content="deb " + source + "\n"))
def test_adds_multiple_sources_list_files(self):
hwpack = HardwarePack(self.metadata)
@@ -592,10 +592,10 @@
tf = self.get_tarfile(hwpack)
self.assertThat(
tf, HardwarePackHasFile("sources.list.d/ubuntu.list",
- content="deb " + source1 + "\n"))
+ content="deb " + source1 + "\n"))
self.assertThat(
tf, HardwarePackHasFile("sources.list.d/linaro.list",
- content="deb " + source2 + "\n"))
+ content="deb " + source2 + "\n"))
def test_overwrites_sources_list_file(self):
hwpack = HardwarePack(self.metadata)
@@ -606,7 +606,7 @@
tf = self.get_tarfile(hwpack)
self.assertThat(
tf, HardwarePackHasFile("sources.list.d/ubuntu.list",
- content="deb " + new_source + "\n"))
+ content="deb " + new_source + "\n"))
def test_creates_sources_list_gpg_dir(self):
hwpack = HardwarePack(self.metadata)
=== modified file 'linaro_image_tools/hwpack/tests/test_hwpack_converter.py'
@@ -24,13 +24,13 @@
from linaro_image_tools.tests.fixtures import (
CreateTempDirFixture,
CreateTempFileFixture,
- )
+)
from linaro_image_tools.hwpack.hwpack_convert import (
HwpackConverter,
HwpackConverterException,
check_and_validate_args,
- )
+)
class Args():
@@ -71,8 +71,8 @@
def test_basic_parse(self):
ini_format = '[hwpack]\nformat=2.0\nsupport=supported'
output_format = "format: '3.0'\nsupport: supported\n"
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -84,8 +84,8 @@
"""
ini_format = '[hwpack]\nformat=2.0\narchitectures=armhf armel'
output_format = "format: '3.0'\narchitectures:\n- armhf\n- armel\n"
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -94,13 +94,13 @@
def test_bootloaders(self):
"""Tests the correct creation of the bootloaders part."""
ini_format = ("[hwpack]\nformat=2.0\nu_boot_package=a_package\n"
- "u_boot_file=a_file\nu_boot_in_boot_part=Yes\n"
- "u_boot_dd=33")
+ "u_boot_file=a_file\nu_boot_in_boot_part=Yes\n"
+ "u_boot_dd=33")
out_format = ("format: '3.0'\nbootloaders:\n u_boot:\n dd: '33'"
- "\n file: a_file\n in_boot_part: true\n"
- " package: a_package\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ "\n file: a_file\n in_boot_part: true\n"
+ " package: a_package\n")
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -109,12 +109,12 @@
def test_extra_boot_options(self):
"""Tests the correct creation of the extra_boot_options part."""
ini_format = ("[hwpack]\nformat=2.0\nu_boot_package=a_package\n"
- "extra_boot_options=opt1 opt2")
+ "extra_boot_options=opt1 opt2")
out_format = ("format: '3.0'\nbootloaders:\n u_boot:\n "
- " extra_boot_options:\n - opt1\n "
- "- opt2\n package: a_package\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ " extra_boot_options:\n - opt1\n "
+ "- opt2\n package: a_package\n")
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -124,8 +124,8 @@
"""Tests the correct creation of the extra_serial_options part."""
ini_format = ("[hwpack]\nformat=2.0\nextra_serial_options=opt1 opt2")
out_format = ("format: '3.0'\nextra_serial_options:\n- opt1\n- opt2\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -134,11 +134,11 @@
def test_assume_installed(self):
"""Tests the correct creation of the extra_serial_options part."""
ini_format = ("[hwpack]\nformat=2.0\nassume-installed=install1 "
- "install2")
+ "install2")
out_format = ("format: '3.0'\nassume_installed:\n- install1\n- "
- "install2\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ "install2\n")
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -148,8 +148,8 @@
"""Tests the correct creation of the extra_serial_options part."""
ini_format = ("[hwpack]\nformat=2.0\ninclude-debs=yes")
out_format = ("format: '3.0'\ninclude_debs: true\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -160,8 +160,8 @@
ini_format = ("[hwpack]\nformat=2.0\ndtb_file=boot/a-*-path/file.dtb")
out_format = ("format: '3.0'\ndtb_files:\n- board.dtb: "
"boot/a-*-path/file.dtb\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
@@ -175,8 +175,8 @@
not a string."""
ini_format = ("[hwpack]\nformat=2.0\nmmc_id=1:1")
out_format = ("format: '3.0'\nmmc_id: '1:1'\n")
- input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
- get_file_name()
+ input_file = self.useFixture(
+ CreateTempFileFixture(ini_format)).get_file_name()
output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
converter = HwpackConverter(input_file, output_file)
converter._parse()
=== modified file 'linaro_image_tools/hwpack/tests/test_hwpack_reader.py'
@@ -22,17 +22,17 @@
from linaro_image_tools.testing import TestCaseWithFixtures
from linaro_image_tools.tests.fixtures import (
CreateTempDirFixture,
- )
+)
from linaro_image_tools.media_create.tests.fixtures import (
CreateTarballFixture,
- )
+)
from linaro_image_tools.hwpack.hwpack_reader import (
Hwpack,
HwpackReader,
HwpackReaderError,
- )
+)
class HwpackReaderTests(TestCaseWithFixtures):
@@ -41,13 +41,13 @@
def setUp(self):
super(HwpackReaderTests, self).setUp()
self.metadata = ("format: 3.0\nversion: '1'\nname: test-hwpack\n"
- "architecture: armel\norigin: Linaro")
+ "architecture: armel\norigin: Linaro")
self.hwpack = Hwpack()
self.hwpack.setname('test-hwpack')
self.tar_dir_fixture = CreateTempDirFixture()
self.useFixture(self.tar_dir_fixture)
self.tarball_fixture = CreateTarballFixture(
- self.tar_dir_fixture.get_temp_dir())
+ self.tar_dir_fixture.get_temp_dir())
self.useFixture(self.tarball_fixture)
def tearDown(self):
@@ -104,11 +104,11 @@
def test_hwpack_metadata_read_with_bootloaders(self):
self.metadata += ("\nboards:\n panda:\n support: supported\n "
- "bootloaders:\n u_boot:\n file: a_file\n")
+ "bootloaders:\n u_boot:\n file: a_file\n")
tarball = self.add_to_tarball([('metadata', self.metadata)])
reader = HwpackReader([tarball])
reader._read_hwpacks_metadata()
self.hwpack.sethwpack(tarball)
self.hwpack.setboards({'panda': {'support': 'supported', 'bootloaders':
- {'u_boot': {'file': 'a_file'}}}})
+ {'u_boot': {'file': 'a_file'}}}})
self.assertEqual(self.hwpack, reader.supported_elements[0])
=== modified file 'linaro_image_tools/hwpack/tests/test_packages.py'
@@ -44,13 +44,13 @@
PackageMaker,
stringify_relationship,
TemporaryDirectoryManager,
- )
+)
from linaro_image_tools.hwpack.testing import (
AptSourceFixture,
ContextManagerFixture,
DummyFetchedPackage,
MatchesPackage,
- )
+)
from linaro_image_tools.testing import TestCaseWithFixtures
@@ -65,11 +65,10 @@
Size: %(size)d
Architecture: armel
MD5sum: %(md5)s
- \n""" % {
- 'filename': package.filename,
- 'size': package.size,
- 'md5': package.md5,
- }), get_packages_file([package]))
+ \n""" % {'filename': package.filename,
+ 'size': package.size,
+ 'md5': package.md5,
+ }), get_packages_file([package]))
def test_two_stanzas(self):
package1 = DummyFetchedPackage("foo", "1.1")
@@ -88,7 +87,7 @@
""" % {
'filename': package.filename,
'size': package.size,
- })
+ })
stanza += relationships
stanza += "MD5sum: %s\n\n" % package.md5
return stanza
@@ -145,11 +144,11 @@
Size: %(size)d
Architecture: all
MD5sum: %(md5)s
- \n""" % {
- 'filename': package.filename,
- 'size': package.size,
- 'md5': package.md5,
- }), get_packages_file([package], extra_text="Status: bar"))
+ \n""" % {'filename': package.filename,
+ 'size': package.size,
+ 'md5': package.md5,
+ }), get_packages_file([package],
+ extra_text="Status: bar"))
class StringifyRelationshipTests(TestCaseWithFixtures):
@@ -404,7 +403,7 @@
'Provides': 'bar, baz (= 1.0)',
'Replaces': 'bar, baz (>= 1.0)',
'Breaks': 'bar, baz (>= 1.0)',
- })
+ })
def test_unknown_field_name_fails(self):
maker = PackageMaker()
@@ -706,7 +705,7 @@
self.assertEqual(target_package, created_package)
def create_package_and_assert_from_apt_translates_relationship(
- self, relationship):
+ self, relationship):
kwargs = {}
kwargs[relationship] = "bar | baz (>= 1.0), zap"
target_package = DummyFetchedPackage("foo", "1.0", **kwargs)
@@ -771,7 +770,7 @@
self.assertEqual(target_package, created_package)
def create_package_and_assert_from_deb_translates_relationships(
- self, relationships):
+ self, relationships):
maker = PackageMaker()
self.useFixture(ContextManagerFixture(maker))
deb_file_path = maker.make_package('foo', '1.0', relationships)
=== modified file 'linaro_image_tools/hwpack/tests/test_script.py'
@@ -30,7 +30,7 @@
ConfigFileFixture,
DummyFetchedPackage,
IsHardwarePack,
- )
+)
from linaro_image_tools.hwpack.config import Config
from linaro_image_tools.testing import TestCaseWithFixtures
from linaro_image_tools.utils import find_command
=== modified file 'linaro_image_tools/hwpack/tests/test_tarfile_matchers.py'
@@ -27,7 +27,7 @@
TarfileHasFile,
TarfileMissingPathMismatch,
TarfileWrongValueMismatch,
- )
+)
from linaro_image_tools.hwpack.testing import test_tarfile
@@ -182,7 +182,7 @@
def test_mismatches_wrong_uname(self):
with test_tarfile(
- contents=[("foo", "")], default_uname="someuser") as tf:
+ contents=[("foo", "")], default_uname="someuser") as tf:
matcher = TarfileHasFile("foo", uname="otheruser")
mismatch = matcher.match(tf)
self.assertValueMismatch(
@@ -190,7 +190,7 @@
def test_mismatches_wrong_gname(self):
with test_tarfile(
- contents=[("foo", "")], default_gname="somegroup") as tf:
+ contents=[("foo", "")], default_gname="somegroup") as tf:
matcher = TarfileHasFile("foo", gname="othergroup")
mismatch = matcher.match(tf)
self.assertValueMismatch(
=== modified file 'linaro_image_tools/hwpack/tests/test_testing.py'
@@ -30,7 +30,7 @@
Equals,
Mismatch,
NotEquals,
- )
+)
from linaro_image_tools.hwpack.testing import (
DummyFetchedPackage,
EachOf,
@@ -40,10 +40,10 @@
MatchesStructure,
MatchesSetwise,
parse_packages_file_content,
- )
+)
from linaro_image_tools.hwpack.packages import (
get_packages_file,
- )
+)
def run_doctest(obj, name):
@@ -117,7 +117,7 @@
observed = DummyFetchedPackage("foo", "1.1", depends="bar")
expected = DummyFetchedPackage("foo", "1.1", depends="baz")
self.assertRaises(AssertionError, self.assertThat, observed,
- MatchesPackage(expected))
+ MatchesPackage(expected))
def test_skip_one_attribute(self):
observed = DummyFetchedPackage("foo", "1.1", depends="bar")
=== modified file 'linaro_image_tools/media_create/__init__.py'
@@ -98,7 +98,7 @@
parser.add_argument(
'--read-hwpack', dest='readhwpack', action='store_true',
help=('Read the hardware pack and print information about the '
- 'supported boards and bootloaders.'))
+ 'supported boards and bootloaders.'))
parser.add_argument(
'--dev', dest='dev', choices=KNOWN_BOARDS,
help='Generate an SD card or image for the given board.')
=== modified file 'linaro_image_tools/media_create/android_boards.py'
@@ -51,7 +51,7 @@
align_up,
install_mx5_boot_loader,
make_boot_script,
- )
+)
from linaro_image_tools.utils import DEFAULT_LOGGER_NAME
logger = logging.getLogger(DEFAULT_LOGGER_NAME)
@@ -108,7 +108,7 @@
self._extra_serial_options = value
extra_serial_options = property(_get_extra_serial_options,
- _set_extra_serial_options)
+ _set_extra_serial_options)
def _get_live_serial_options(self):
serial_options = self._live_serial_options
@@ -180,7 +180,7 @@
return (
"%(serial_options)s "
"%(boot_args_options)s"
- % replacements)
+ % replacements)
def _get_boot_env(self, consoles):
"""Get the boot environment for this board.
@@ -205,7 +205,7 @@
# TODO: Use partition_mounted() here to make sure the partition is
# always umounted after we're done.
cmd_runner.run(['mount', boot_partition, boot_disk],
- as_root=True).wait()
+ as_root=True).wait()
boot_env = self._get_boot_env(consoles)
cmdline_filepath = os.path.join(boot_disk, "cmdline")
@@ -260,13 +260,13 @@
# If extra_part is True an extra primary partition will be added.
# Due to a maximum of 4 primary partitions cache data will be placed in
# a extended partition
- if extra_part == True:
- assert start_addr > 0, ("Not possible to add extra partition" \
+ if extra_part is True:
+ assert start_addr > 0, ("Not possible to add extra partition"
"when boot partition starts at '0'")
return '%s,%s,%s,*\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,%s,L\n%s,,,-' % (
- boot_start, boot_len, partition_type, system_start, _system_len,
- cache_start, cache_start, _cache_len, userdata_start,
- _userdata_len, sdcard_start)
+ boot_start, boot_len, partition_type, system_start,
+ _system_len, cache_start, cache_start, _cache_len,
+ userdata_start, _userdata_len, sdcard_start)
return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,,,-' % (
boot_start, boot_len, partition_type, system_start, _system_len,
@@ -403,7 +403,7 @@
self._extra_serial_options = value
extra_serial_options = property(_get_extra_serial_options,
- _set_extra_serial_options)
+ _set_extra_serial_options)
def _get_android_specific_args(self):
android_args = self._android_specific_args
@@ -452,7 +452,7 @@
class AndroidSamsungConfig(AndroidBoardConfig):
def get_sfdisk_cmd(self, should_align_boot_part=False):
loaders_min_len = (self.samsung_bl1_start + self.samsung_bl1_len +
- self.samsung_bl2_len + self.samsung_env_len)
+ self.samsung_bl2_len + self.samsung_env_len)
loader_start, loader_end, loader_len = align_partition(
1, loaders_min_len, 1, PART_ALIGN_S)
@@ -515,7 +515,7 @@
'snowball_sd': AndroidSnowballSdConfig,
'vexpress': AndroidVexpressConfig,
'vexpress-a9': AndroidVexpressConfig,
- }
+}
def get_board_config(board):
=== modified file 'linaro_image_tools/media_create/boards.py'
@@ -42,7 +42,7 @@
SECTOR_SIZE,
partition_mounted,
register_loopback,
- )
+)
from linaro_image_tools.hwpack.hwpack_fields import (
BOOTFS,
@@ -76,7 +76,7 @@
SPL_IN_BOOT_PART_FIELD,
WIRED_INTERFACES_FIELD,
WIRELESS_INTERFACES_FIELD,
- )
+)
logger = logging.getLogger(__name__)
@@ -253,7 +253,7 @@
def set_metadata(self, hwpacks, bootloader=None, board=None):
self.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
- board)
+ board)
with self.hardwarepack_handler:
self.hwpack_format = self.hardwarepack_handler.get_format()
if (self.hwpack_format == self.hardwarepack_handler.FORMAT_1):
@@ -318,8 +318,8 @@
elif self.partition_layout == BOOTFS16:
self.fat_size = 16
else:
- raise AssertionError("Unknown partition layout '%s'." % \
- self.partition_layout)
+ raise AssertionError("Unknown partition layout '%s'." %
+ self.partition_layout)
self.mmc_option = self.get_metadata_field(MMC_ID_FIELD)
if self.mmc_option:
@@ -330,11 +330,11 @@
boot_min_size = self.get_metadata_field(BOOT_MIN_SIZE_FIELD)
if boot_min_size:
self.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2,
- SECTOR_SIZE) / SECTOR_SIZE
+ SECTOR_SIZE) / SECTOR_SIZE
root_min_size = self.get_metadata_field(ROOT_MIN_SIZE_FIELD)
if root_min_size:
self.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2,
- SECTOR_SIZE) / SECTOR_SIZE
+ SECTOR_SIZE) / SECTOR_SIZE
loader_min_size = self.get_metadata_field(LOADER_MIN_SIZE_FIELD)
if loader_min_size:
self.LOADER_MIN_SIZE_S = (
@@ -496,11 +496,11 @@
boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
- loader_start, loader_len, boot_start, boot_len, root_start)
+ loader_start, loader_len, boot_start, boot_len, root_start)
def get_sfdisk_cmd(self, should_align_boot_part=False):
if (self.partition_layout in ['bootfs_rootfs', 'bootfs16_rootfs'] or
- self.board == 'snowball_sd'):
+ self.board == 'snowball_sd'):
return self.get_normal_sfdisk_cmd(should_align_boot_part)
elif self.partition_layout in ['reserved_bootfs_rootfs']:
return self.get_reserved_sfdisk_cmd(should_align_boot_part)
@@ -524,8 +524,8 @@
"%(uimage_path)suImage; ")) % replacements
if i_img_data is not None:
boot_script += (
- ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +
- "%(uimage_path)suInitrd; ")) % replacements
+ ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +
+ "%(uimage_path)suInitrd; ")) % replacements
if d_img_data is not None:
assert self.dtb_addr is not None, (
"Need a dtb_addr when passing d_img_data")
@@ -605,7 +605,7 @@
(k_img_data, i_img_data, d_img_data) = self._get_kflavor_files(
parts_dir)
boot_env = self._get_boot_env(is_live, is_lowmem, consoles, rootfs_id,
- i_img_data, d_img_data)
+ i_img_data, d_img_data)
if self.hwpack_format == HardwarepackHandler.FORMAT_1:
self._make_boot_files(
@@ -665,22 +665,22 @@
assert from_file is not None, "No source file name given."
if max_size is not None:
assert os.path.getsize(from_file) <= max_size, (
- "'%s' is larger than %s" % (from_file, max_size))
+ "'%s' is larger than %s" % (from_file, max_size))
logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek))
_dd(from_file, to_file, seek=seek)
def install_samsung_boot_loader(self, samsung_spl_file, bootloader_file,
boot_device_or_file):
self._dd_file(samsung_spl_file, boot_device_or_file,
- self.samsung_bl1_start,
- self.samsung_bl1_len * SECTOR_SIZE)
+ self.samsung_bl1_start,
+ self.samsung_bl1_len * SECTOR_SIZE)
self._dd_file(bootloader_file, boot_device_or_file,
- self.samsung_bl2_start,
- self.samsung_bl2_len * SECTOR_SIZE)
+ self.samsung_bl2_start,
+ self.samsung_bl2_len * SECTOR_SIZE)
def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
- boot_device_or_file, k_img_data, i_img_data,
- d_img_data):
+ boot_device_or_file, k_img_data, i_img_data,
+ d_img_data):
with self.hardwarepack_handler:
spl_file = self.get_file('spl_file')
if self.spl_in_boot_part:
@@ -699,7 +699,7 @@
bootloader_file = self.get_file('bootloader_file')
if self.bootloader_dd:
self._dd_file(bootloader_file, boot_device_or_file,
- self.bootloader_dd)
+ self.bootloader_dd)
make_uImage(self.load_addr, k_img_data, boot_dir)
@@ -717,7 +717,7 @@
make_boot_ini(boot_script_path, boot_dir)
if (self.snowball_startup_files_config is not None and
- self.board != 'snowball_sd'):
+ self.board != 'snowball_sd'):
self.populate_raw_partition(boot_device_or_file, chroot_dir)
if self.env_dd:
@@ -728,7 +728,7 @@
env_size = self.samsung_env_len * SECTOR_SIZE
env_file = make_flashable_env(boot_env, env_size)
self._dd_file(env_file, boot_device_or_file,
- self.samsung_env_start)
+ self.samsung_env_start)
def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
boot_device_or_file, k_img_data, i_img_data,
@@ -857,8 +857,8 @@
if not self.dtb_file or not dtb:
logger.warn("Could not find a valid dtb file, skipping it.")
- logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \
- (kernel, initrd, dtb))
+ logger.info("Will use kernel=%s, initrd=%s, dtb=%s." %
+ (kernel, initrd, dtb))
return (kernel, initrd, dtb)
def populate_raw_partition(self, media, boot_dir):
@@ -1117,7 +1117,7 @@
boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
- loader_start, loader_len, boot_start, boot_len, root_start)
+ loader_start, loader_len, boot_start, boot_len, root_start)
def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
boot_device_or_file, k_img_data, i_img_data,
@@ -1137,9 +1137,9 @@
with open(toc_filename, 'wb') as toc:
self.create_toc(toc, new_files)
self.install_snowball_boot_loader(toc_filename, new_files,
- boot_device_or_file,
- self.SNOWBALL_LOADER_START_S,
- self.delete_startupfiles)
+ boot_device_or_file,
+ self.SNOWBALL_LOADER_START_S,
+ self.delete_startupfiles)
self.delete_file(toc_filename)
if self.delete_startupfiles:
self.delete_file(os.path.join(config_files_dir,
@@ -1286,7 +1286,8 @@
# XXX: delete this method when hwpacks V1 can die
assert self.hwpack_format == HardwarepackHandler.FORMAT_1
with self.hardwarepack_handler:
- bootloader_file = self.get_file('bootloader_file',
+ bootloader_file = self.get_file(
+ 'bootloader_file',
default=os.path.join(
chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor,
'u-boot.imx'))
@@ -1392,18 +1393,18 @@
return ""
def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
- boot_device_or_file, k_img_data, i_img_data,
- d_img_data):
+ boot_device_or_file, k_img_data, i_img_data,
+ d_img_data):
output_dir = os.path.dirname(boot_device_or_file)
# There are 2 kinds of models now, VE and Foundation
bw_ve = _get_file_matching("%s/boot/img.axf" % chroot_dir)
bw_foundation = _get_file_matching("%s/boot/img-foundation.axf" %
- chroot_dir)
+ chroot_dir)
for filename in (bw_ve, bw_foundation, k_img_data,
i_img_data, d_img_data):
- if filename != None:
+ if filename is not None:
copy_drop(filename, output_dir)
@@ -1415,7 +1416,7 @@
def get_v1_sfdisk_cmd(self, should_align_boot_part=False):
# bootloaders partition needs to hold BL1, U-Boot environment, and BL2
loaders_min_len = (self.samsung_bl1_start + self.samsung_bl1_len +
- self.samsung_bl2_len + self.samsung_env_len)
+ self.samsung_bl2_len + self.samsung_env_len)
# bootloaders partition
loaders_start, loaders_end, loaders_len = align_partition(
@@ -1440,7 +1441,8 @@
d_img_data):
# XXX: delete this method when hwpacks V1 can die
assert self.hwpack_format == HardwarepackHandler.FORMAT_1
- self.install_samsung_boot_loader(self._get_samsung_spl(chroot_dir),
+ self.install_samsung_boot_loader(
+ self._get_samsung_spl(chroot_dir),
self._get_samsung_bootloader(chroot_dir), boot_device_or_file)
env_size = self.samsung_env_len * SECTOR_SIZE
env_file = make_flashable_env(boot_env, env_size)
@@ -1504,12 +1506,12 @@
spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
assert os.path.getsize(spl_file) <= (
self.samsung_bl1_len * SECTOR_SIZE), (
- "%s is larger than Samsung BL1 size" % spl_file)
+ "%s is larger than Samsung BL1 size" % spl_file)
_dd(spl_file, boot_device_or_file, seek=self.samsung_bl1_start)
uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
assert os.path.getsize(uboot_file) <= (
self.samsung_bl2_len * SECTOR_SIZE), (
- "%s is larger than Samsung BL2 size" % uboot_file)
+ "%s is larger than Samsung BL2 size" % uboot_file)
_dd(uboot_file, boot_device_or_file, seek=self.samsung_bl2_start)
@@ -1684,21 +1686,25 @@
img_loop = register_loopback(boot_device_or_file, 0, img_size)
# install bootloader
- cmd_runner.run([self.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir,
- '--modules', 'part_msdos', img_loop],
- as_root=True).wait()
+ cmd_runner.run([self.BOOTLOADER_CMD,
+ '--boot-directory=%s' % boot_dir,
+ '--modules', 'part_msdos', img_loop],
+ as_root=True).wait()
# generate loader config file
loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data),
- self.extra_serial_options, os.path.basename(i_img_data))
+ self.extra_serial_options,
+ os.path.basename(i_img_data))
_, tmpfile = tempfile.mkstemp()
atexit.register(os.unlink, tmpfile)
with open(tmpfile, 'w') as fd:
fd.write(loader_config)
- cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir,
- self.BOOTLOADER_CFG_FILE)], as_root=True).wait()
+ cmd_runner.run(['cp', tmpfile,
+ os.path.join(
+ boot_dir,
+ self.BOOTLOADER_CFG_FILE)], as_root=True).wait()
def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
boot_device_or_file, k_img_data, i_img_data,
@@ -1734,7 +1740,7 @@
'ux500': Ux500Config,
'vexpress': VexpressConfig,
'vexpress-a9': VexpressA9Config,
- }
+}
def get_board_config(board):
=== modified file 'linaro_image_tools/media_create/check_device.py'
@@ -111,8 +111,8 @@
def confirm_device_selection_and_ensure_it_is_ready(
- device,
- yes_to_mmc_selection=False):
+ device,
+ yes_to_mmc_selection=False):
"""Confirm this is the device to use and ensure it's ready.
If the device exists, the user is asked to confirm that this is the
=== modified file 'linaro_image_tools/media_create/chroot_utils.py'
@@ -24,7 +24,7 @@
from linaro_image_tools.utils import (
is_arm_host,
find_command,
- )
+)
from linaro_image_tools.hwpack.handler import HardwarepackHandler
# It'd be nice if we could use atexit here, but all the things we need to undo
@@ -45,8 +45,8 @@
def install_hwpacks(
- rootfs_dir, tmp_dir, tools_dir, hwpack_force_yes, verified_files,
- extract_kpkgs=False, *hwpack_files):
+ rootfs_dir, tmp_dir, tools_dir, hwpack_force_yes, verified_files,
+ extract_kpkgs=False, *hwpack_files):
"""Install the given hwpacks onto the given rootfs."""
# In case we just want to extract the kernel packages, don't force qemu
=== modified file 'linaro_image_tools/media_create/partitions.py'
@@ -32,7 +32,7 @@
Disk,
PARTITION_NORMAL,
PARTITION_EXTENDED,
- )
+)
from linaro_image_tools import cmd_runner
@@ -54,7 +54,8 @@
def setup_android_partitions(board_config, media, image_size, bootfs_label,
- should_create_partitions, should_align_boot_part=False):
+ should_create_partitions,
+ should_align_boot_part=False):
cylinders = None
if not media.is_block_device:
image_size_in_bytes = get_partition_size_in_bytes(image_size)
@@ -304,7 +305,7 @@
for partition in disk.partitions:
assert partition.type == PARTITION_NORMAL, (
"Parted should only return normal partitions but got type %i" %
- partition.type)
+ partition.type)
if 'boot' in partition.getFlagsAsString():
geometry = partition.geometry
vfat_offset = geometry.start * SECTOR_SIZE
=== modified file 'linaro_image_tools/media_create/rootfs.py'
@@ -65,7 +65,7 @@
mount_options = rootfs_mount_options(rootfs_type)
fstab_additions = ["%s / %s %s 0 1" % (
- rootfs_id, rootfs_type, mount_options)]
+ rootfs_id, rootfs_type, mount_options)]
if should_create_swap:
print "\nCreating SWAP File\n"
if has_space_left_for_swap(root_disk, swap_size):
@@ -88,7 +88,7 @@
print "\nCreating /etc/flash-kernel.conf\n"
create_flash_kernel_config(
- root_disk, mmc_device_id, 1 + partition_offset)
+ root_disk, mmc_device_id, 1 + partition_offset)
if board_config is not None:
print "\nUpdating /etc/network/interfaces\n"
@@ -123,7 +123,7 @@
Uses the given partition number to figure out the boot partition.
"""
target_boot_dev = '/dev/mmcblk%dp%s' % (
- mmc_device_id, boot_partition_number)
+ mmc_device_id, boot_partition_number)
flash_kernel = os.path.join(root_disk, 'etc', 'flash-kernel.conf')
write_data_to_protected_file(
flash_kernel, "UBOOT_PART=%s\n" % target_boot_dev)
=== modified file 'linaro_image_tools/media_create/tests/__init__.py'
@@ -22,7 +22,7 @@
module_names = [
'linaro_image_tools.media_create.tests.test_media_create',
'linaro_image_tools.media_create.tests.test_android_boards',
- ]
+ ]
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(module_names)
return suite
=== modified file 'linaro_image_tools/media_create/tests/test_android_boards.py'
@@ -21,12 +21,12 @@
from linaro_image_tools.media_create.boards import (
BoardConfigException,
- )
+)
from linaro_image_tools.media_create.android_boards import (
AndroidBeagleConfig,
get_board_config,
- )
+)
from linaro_image_tools.testing import TestCaseWithFixtures
from linaro_image_tools.tests.fixtures import CreateTempFileFixture
@@ -80,18 +80,18 @@
hwpack_format + hwpack_android_args + hwpack_bootloader_flavor +
hwpack_dtb_addr + hwpack_dtb_name + hwpack_extra_boot +
hwpack_extra_serial
- )
+ )
android_hwpack_mx6 = (
android_hwpack_panda + hwpack_initrd_addr + hwpack_kernel_addr +
hwpack_load_addr
- )
+ )
android_hwpack_snowball_sd = (
hwpack_android_args + hwpack_boot_script + hwpack_dtb_addr +
hwpack_dtb_name + hwpack_extra_boot + hwpack_extra_serial +
hwpack_fdt_high + hwpack_format + hwpack_initrd_addr
- )
+ )
android_hwpack_snowball_emmc = (
android_hwpack_snowball_sd + hwpack_initrd_high + hwpack_mmc_option)
@@ -156,10 +156,11 @@
def test_extra_boot_args_options(self):
"""The field extra_boot_args_options should be a concatenated string.
Testing presence of a field defined in the parent class."""
- values = {'dtb_name': 'a_name',
- 'extra_boot_args_options': ['earlyprintk', 'mem=128M@0',
- 'mali.mali_mem=64M@128M']
- }
+ values = {
+ 'dtb_name': 'a_name',
+ 'extra_boot_args_options': ['earlyprintk', 'mem=128M@0',
+ 'mali.mali_mem=64M@128M']
+ }
yaml_conf = self.android_hwpack_extra_boot % values
name = self._get_tmp_file_name(yaml_conf)
self.config.from_file(name)
@@ -179,7 +180,7 @@
"initrd_addr": '0x12000000',
"kernel_addr": '0x10000000',
"load_addr": '0x10008000',
- }
+ }
expected = {
'bootargs': 'console=ttymxc0,115200n8 '
'rootwait ro earlyprintk rootdelay=1 fixrtc '
@@ -222,7 +223,7 @@
"mem=456M@0x80000000",
"mem=512M@0xA0000000"],
"extra_serial_options": ["console=ttyO2,115200n8"],
- }
+ }
expected = {
'bootargs': 'console=ttyO2,115200n8 '
'rootwait ro earlyprintk fixrtc '
@@ -270,7 +271,7 @@
"fdt_high": '0x05000000',
"initrd_addr": '0x05000000',
"initrd_high": '0x06000000',
- }
+ }
expected = {
'bootargs': 'console=ttyAMA2,115200n8 '
'rootwait ro earlyprintk '
@@ -319,7 +320,7 @@
"initrd_addr": '0x05000000',
"initrd_high": '0x06000000',
"mmc_option": '0:2'
- }
+ }
expected = {
'bootargs': 'console=ttyAMA2,115200n8 '
'rootwait ro earlyprintk '
@@ -353,8 +354,10 @@
def test_android_origen(self):
values = {
- "extra_serial_options": ["console=tty0", "console=ttySAC2,115200n8"],
- "android_specific_args": ["init=/init", "androidboot.console=ttySAC2"]
+ "extra_serial_options": ["console=tty0",
+ "console=ttySAC2,115200n8"],
+ "android_specific_args": ["init=/init",
+ "androidboot.console=ttySAC2"]
}
expected = {
'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
@@ -462,7 +465,7 @@
'initrd_high': '0xffffffff'}
config = ((self.hwpack_format + self.hwpack_extra_boot +
self.hwpack_extra_serial + self.hwpack_android_args) %
- values)
+ values)
self.assertBootEnv(expected, config=config, board='mx53loco')
def test_android_mx5_old(self):
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
@@ -47,7 +47,7 @@
check_device,
partitions,
rootfs,
- )
+)
from linaro_image_tools.media_create.boards import (
SECTOR_SIZE,
align_up,
@@ -65,10 +65,10 @@
_run_mkimage,
BoardConfig,
get_board_config,
- )
+)
from linaro_image_tools.media_create.android_boards import (
AndroidSnowballEmmcConfig,
- )
+)
from linaro_image_tools.media_create.chroot_utils import (
copy_file,
install_hwpack,
@@ -78,7 +78,7 @@
prepare_chroot,
run_local_atexit_funcs,
temporarily_overwrite_file_on_dir,
- )
+)
from linaro_image_tools.media_create.partitions import (
HEADS,
MIN_IMAGE_SIZE,
@@ -100,7 +100,7 @@
run_sfdisk_commands,
setup_partitions,
wait_partition_to_settle,
- )
+)
from linaro_image_tools.media_create.rootfs import (
append_to_fstab,
create_flash_kernel_config,
@@ -110,20 +110,20 @@
rootfs_mount_options,
update_network_interfaces,
write_data_to_protected_file,
- )
+)
from linaro_image_tools.media_create.tests.fixtures import (
CreateTarballFixture,
MockRunSfdiskCommandsFixture,
- )
+)
from linaro_image_tools.media_create.unpack_binary_tarball import (
unpack_binary_tarball,
- )
+)
from linaro_image_tools.testing import TestCaseWithFixtures
from linaro_image_tools.tests.fixtures import (
CreateTempDirFixture,
MockCmdRunnerPopenFixture,
MockSomethingFixture,
- )
+)
from linaro_image_tools.utils import find_command, preferred_tools_dir
from linaro_image_tools.hwpack.testing import ContextManagerFixture
@@ -149,7 +149,7 @@
metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: "
"armel\norigin: linaro\n")
metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: "
- "b_file\n")
+ "b_file\n")
data = '3.0'
format = "%s\n" % data
tarball = self.add_to_tarball(
@@ -162,9 +162,9 @@
metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: "
"armel\norigin: linaro\n")
metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: "
- "b_file\n")
+ "b_file\n")
metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n "
- "file: panda_file")
+ "file: panda_file")
data = '3.0'
format = "%s\n" % data
tarball = self.add_to_tarball(
@@ -177,12 +177,12 @@
metadata = ("format: 3.0\nname: ahwpack\nversion: 4\narchitecture: "
"armel\norigin: linaro\n")
metadata += ("bootloaders:\n u_boot:\n file: a_file\n uefi:\n file: "
- "b_file\n")
+ "b_file\n")
metadata += ("boards:\n panda:\n bootloaders:\n u_boot:\n "
- "file: panda_file\n uefi:\n file: "
- "uefi_panda_file\n")
+ "file: panda_file\n uefi:\n file: "
+ "uefi_panda_file\n")
metadata += (" panda-lt:\n bootloaders:\n u_boot:\n "
- "file: panda_lt_file")
+ "file: panda_lt_file")
data = '3.0'
format = "%s\n" % data
tarball = self.add_to_tarball(
@@ -190,7 +190,7 @@
hp = HardwarepackHandler([tarball], board='panda', bootloader='uefi')
with hp:
self.assertEquals(hp.get_field('bootloader_file')[0],
- 'uefi_panda_file')
+ 'uefi_panda_file')
def add_to_tarball(self, files, tarball=None):
if tarball is None:
@@ -368,13 +368,14 @@
format = "3.0\n"
names = ['package0', 'package1', 'package2']
- files = {names[0]:
- ["usr/lib/u-boot/omap4_panda/u-boot.img",
- "usr/share/doc/u-boot-linaro-omap4-panda/copyright"],
- names[1]: ["usr/lib/u-boot/omap4_panda/u-boot2.img",
- "foo/bar",
- "flim/flam"],
- names[2]: ["some/path/config"]}
+ files = {
+ names[0]:
+ ["usr/lib/u-boot/omap4_panda/u-boot.img",
+ "usr/share/doc/u-boot-linaro-omap4-panda/copyright"],
+ names[1]: ["usr/lib/u-boot/omap4_panda/u-boot2.img",
+ "foo/bar",
+ "flim/flam"],
+ names[2]: ["some/path/config"]}
# Generate some test packages
maker = PackageMaker()
@@ -425,8 +426,8 @@
def test_does_not_set_if_old_format(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -434,13 +435,13 @@
def test_sets_kernel_addr(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'kernel_addr'
data_to_set = '0x8123ABCD'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -448,13 +449,13 @@
def test_sets_initrd_addr(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'initrd_addr'
data_to_set = '0x8123ABCD'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -462,13 +463,13 @@
def test_sets_load_addr(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'load_addr'
data_to_set = '0x8123ABCD'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -476,13 +477,13 @@
def test_sets_serial_tty(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'serial_tty'
data_to_set = 'ttyAA'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -490,13 +491,13 @@
def test_sets_wired_interfaces(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'wired_interfaces'
data_to_set = 'eth0 eth1'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -504,13 +505,13 @@
def test_sets_wireless_interfaces(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'wireless_interfaces'
data_to_set = 'wlan0 wl1'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -518,13 +519,13 @@
def test_sets_mmc_id(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'mmc_id'
data_to_set = '0:1'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -534,15 +535,15 @@
def test_sets_boot_min_size(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'boot_min_size'
data_to_set = '100'
expected = align_up(int(data_to_set) * 1024 * 1024,
SECTOR_SIZE) / SECTOR_SIZE
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -550,15 +551,15 @@
def test_sets_root_min_size(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'root_min_size'
data_to_set = '3'
expected = align_up(int(data_to_set) * 1024 * 1024,
SECTOR_SIZE) / SECTOR_SIZE
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -566,15 +567,15 @@
def test_sets_loader_min_size(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'loader_min_size'
data_to_set = '2'
expected = align_up(int(data_to_set) * 1024 * 1024,
SECTOR_SIZE) / SECTOR_SIZE
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -582,13 +583,13 @@
def test_sets_partition_layout_32(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'partition_layout'
data_to_set = 'bootfs_rootfs'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -596,13 +597,13 @@
def test_sets_partition_layout_16(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'partition_layout'
data_to_set = 'bootfs16_rootfs'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -610,13 +611,13 @@
def test_sets_partition_layout_raises(self):
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards, 'HardwarepackHandler',
- self.MockHardwarepackHandler))
+ linaro_image_tools.media_create.boards, 'HardwarepackHandler',
+ self.MockHardwarepackHandler))
field_to_test = 'partition_layout'
data_to_set = 'bootfs_bogus_rootfs'
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
self.assertRaises(
@@ -628,11 +629,11 @@
self.MockHardwarepackHandler))
field_to_test = 'bootloader_copy_files'
data_to_set = {'package':
- [{"source1": "dest1"},
- {"source2": "dest2"}]}
+ [{"source1": "dest1"},
+ {"source2": "dest2"}]}
self.MockHardwarepackHandler.metadata_dict = {
field_to_test: data_to_set,
- }
+ }
board_conf = BoardConfig()
board_conf.set_metadata('ahwpack.tar.gz')
@@ -867,14 +868,14 @@
#Create the test's input data structures
zero = '\x00\x00\x00\x00'
line1 = zero + zero + zero + zero + zero + 'b' + zero + zero + \
- '\x00\x00\x00'
+ '\x00\x00\x00'
maxint = '\xFF\xFF\xFF\x7F'
minint = '\xFF\xFF\xFF\xFF'
line2 = maxint + maxint + zero + minint + minint + \
- 'hello' + zero + '\x00\x00\x00'
+ 'hello' + zero + '\x00\x00\x00'
line3 = '\x01\x00\x00\x00' '\x64\x00\x00\x00' + zero + \
- '\x05\x00\x00\x00' '\x05\x00\x00\x00' \
- 'hello' + zero + '\x00\x00\x00'
+ '\x05\x00\x00\x00' '\x05\x00\x00\x00' \
+ 'hello' + zero + '\x00\x00\x00'
self.expected = line1 + line2 + line3
self.board_conf = boards.SnowballEmmcConfig()
@@ -884,11 +885,11 @@
files = []
for line in src_data:
files.append({'section_name': line[5],
- 'filename': 'N/A',
- 'align': line[3],
- 'offset': line[0],
- 'size': line[1],
- 'load_adress': 'N/A'})
+ 'filename': 'N/A',
+ 'align': line[3],
+ 'offset': line[0],
+ 'size': line[1],
+ 'load_adress': 'N/A'})
return files
def test_create_toc_normal_case(self):
@@ -905,7 +906,8 @@
actual = f.read()
self.assertEquals(96, len(actual))
for i in range(len(actual)):
- self.assertEquals(self.expected[i], actual[i], 'Mismatch at ix' \
+ self.assertEquals(
+ self.expected[i], actual[i], 'Mismatch at ix'
' %d, ref=%c, actual=%c' % (i, self.expected[i], actual[i]))
def test_create_toc_error_too_large_section_name(self):
@@ -990,7 +992,7 @@
ofs = [self.snowball_config.TOC_SIZE,
self.snowball_config.TOC_SIZE + len('ISSW'), 0x160000,
0x170000, 0xBA0000, 0xC1F000]
- size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \
+ size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'),
len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')]
i = 0
for line in src_data:
@@ -1006,8 +1008,9 @@
def test_get_file_info_relative_path(self):
# Create a config file
- cfg_file = os.path.join(self.temp_bootdir_path,
- self.snowball_config.snowball_startup_files_config)
+ cfg_file = os.path.join(
+ self.temp_bootdir_path,
+ self.snowball_config.snowball_startup_files_config)
uboot_file = 'u-boot.bin'
with open(cfg_file, 'w') as f:
f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
@@ -1020,8 +1023,9 @@
def test_get_file_info_abs_path(self):
# Create a config file
- cfg_file = os.path.join(self.temp_bootdir_path,
- self.snowball_config.snowball_startup_files_config)
+ cfg_file = os.path.join(
+ self.temp_bootdir_path,
+ self.snowball_config.snowball_startup_files_config)
uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
uboot_relative_file = uboot_file.replace(self.tempdir, '')
@@ -1035,8 +1039,9 @@
def test_get_file_info_raises(self):
# Create a config file
- cfg_file = os.path.join(self.temp_bootdir_path,
- self.snowball_config.snowball_startup_files_config)
+ cfg_file = os.path.join(
+ self.temp_bootdir_path,
+ self.snowball_config.snowball_startup_files_config)
with open(cfg_file, 'w') as f:
f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
0xBA0000, '9'))
@@ -1055,7 +1060,8 @@
tmpfile.write(filedata)
tmpfile.close()
files = self.setupFiles()
- self.assertRaises(AssertionError,
+ self.assertRaises(
+ AssertionError,
self.snowball_config.install_snowball_boot_loader,
toc_filename, files, "boot_device_or_file",
self.snowball_config.SNOWBALL_LOADER_START_S)
@@ -1064,23 +1070,24 @@
fixture = self.useFixture(MockCmdRunnerPopenFixture())
toc_filename = self.createTempFileAsFixture()
files = self.setupFiles()
- self.snowball_config.install_snowball_boot_loader(toc_filename,
+ self.snowball_config.install_snowball_boot_loader(
+ toc_filename,
files, "boot_device_or_file",
self.snowball_config.SNOWBALL_LOADER_START_S)
expected = [
- '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
+ '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc'
' seek=%s' % (sudo_args, toc_filename,
self.snowball_config.SNOWBALL_LOADER_START_S),
- '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file'
' bs=1 conv=notrunc seek=131588'
% (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3072' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3200' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=24064' % (sudo_args, self.temp_bootdir_path),
'%s dd if=%s/u-boot-env.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=25080' % (sudo_args, self.temp_bootdir_path)]
@@ -1091,30 +1098,31 @@
fixture = self.useFixture(MockCmdRunnerPopenFixture())
toc_filename = self.createTempFileAsFixture()
files = self.setupFiles()
- self.snowball_config.install_snowball_boot_loader(toc_filename,
+ self.snowball_config.install_snowball_boot_loader(
+ toc_filename,
files, "boot_device_or_file",
self.snowball_config.SNOWBALL_LOADER_START_S, True)
expected = [
- '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
+ '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc'
' seek=%s' % (sudo_args, toc_filename,
self.snowball_config.SNOWBALL_LOADER_START_S),
- '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
'%s rm %s/boot_image_issw.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file'
' bs=1 conv=notrunc seek=131588'
% (sudo_args, self.temp_bootdir_path),
'%s rm %s/boot_image_x-loader.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3072' % (sudo_args, self.temp_bootdir_path),
'%s rm %s/mem_init.bin' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3200' % (sudo_args, self.temp_bootdir_path),
'%s rm %s/power_management.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=24064' % (sudo_args, self.temp_bootdir_path),
'%s rm %s/u-boot.bin' % (sudo_args, self.temp_bootdir_path),
'%s dd if=%s/u-boot-env.bin of=boot_device_or_file bs=512'
@@ -1132,19 +1140,19 @@
toc_filename, files, "boot_device_or_file",
board_conf.SNOWBALL_LOADER_START_S)
expected = [
- '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
+ '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc'
' seek=%s' % (sudo_args, toc_filename,
board_conf.SNOWBALL_LOADER_START_S),
- '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file'
' bs=1 conv=notrunc seek=131588'
% (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/mem_init.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3072' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/power_management.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3200' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/u-boot.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=24064' % (sudo_args, self.temp_bootdir_path),
'%s dd if=%s/u-boot-env.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=25080' % (sudo_args, self.temp_bootdir_path)]
@@ -1153,8 +1161,10 @@
def test_snowball_make_boot_files(self):
fixture = self.useFixture(MockCmdRunnerPopenFixture())
- self.useFixture(MockSomethingFixture(tempfile, 'mkstemp',
- lambda: (-1, '/tmp/temp_snowball_make_boot_files')))
+ self.useFixture(
+ MockSomethingFixture(tempfile, 'mkstemp',
+ lambda:
+ (-1, '/tmp/temp_snowball_make_boot_files')))
self.setupFiles()
k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500')
i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500')
@@ -1164,39 +1174,40 @@
rootfs_id="UUID=test_boot_env_uuid",
i_img_data=None, d_img_data=None)
self.snowball_config._make_boot_files(boot_env, self.tempdir,
- self.temp_bootdir_path, 'boot_device_or_file', k_img_file,
- i_img_file, None)
+ self.temp_bootdir_path,
+ 'boot_device_or_file',
+ k_img_file, i_img_file, None)
expected = [
- '%s mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e' \
+ '%s mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e'
' 0x00008000 -n Linux -d %s %s/boot/uImage' % (sudo_args,
k_img_file, self.tempdir),
'%s cp /tmp/temp_snowball_make_boot_files %s/boot/boot.txt'
% (sudo_args, self.tempdir),
- '%s mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n boot' \
+ '%s mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n boot'
' script -d %s/boot/boot.txt %s/boot/flash.scr'
% (sudo_args, self.tempdir, self.tempdir),
- '%s dd if=/tmp/temp_snowball_make_boot_files' \
+ '%s dd if=/tmp/temp_snowball_make_boot_files'
' of=boot_device_or_file bs=512 conv=notrunc seek=256'
% (sudo_args),
- '%s dd if=%s/boot/boot_image_issw.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot/boot_image_issw.bin of=boot_device_or_file'
' bs=512 conv=notrunc seek=257' % (sudo_args, self.tempdir),
'%s rm %s/boot_image_issw.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/boot/boot_image_x-loader.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot/boot_image_x-loader.bin of=boot_device_or_file'
' bs=1 conv=notrunc seek=131588' % (sudo_args, self.tempdir),
'%s rm %s/boot_image_x-loader.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/boot/mem_init.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot/mem_init.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=3072' % (sudo_args, self.tempdir),
'%s rm %s/mem_init.bin' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/boot/power_management.bin of=boot_device_or_file' \
+ '%s dd if=%s/boot/power_management.bin of=boot_device_or_file'
' bs=512 conv=notrunc seek=3200' % (sudo_args, self.tempdir),
'%s rm %s/power_management.bin' % (sudo_args,
self.temp_bootdir_path),
- '%s dd if=%s/boot/u-boot.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot/u-boot.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=24064' % (sudo_args, self.tempdir),
'%s rm %s/u-boot.bin' % (sudo_args, self.temp_bootdir_path),
- '%s dd if=%s/boot/u-boot-env.bin of=boot_device_or_file bs=512' \
+ '%s dd if=%s/boot/u-boot-env.bin of=boot_device_or_file bs=512'
' conv=notrunc seek=25080' % (sudo_args, self.tempdir),
'%s rm %s/u-boot-env.bin' % (sudo_args, self.temp_bootdir_path),
'%s rm /tmp/temp_snowball_make_boot_files' % (sudo_args),
@@ -1232,7 +1243,7 @@
for name in dir(boards):
attr = getattr(boards, name)
- if type(attr) == types.FunctionType:
+ if isinstance(attr, types.FunctionType):
self.useFixture(MockSomethingFixture(
linaro_image_tools.media_create.boards, name,
mock_func_creator(name)))
@@ -1347,7 +1358,7 @@
self.funcs_calls.append('install_samsung_boot_loader')
self.useFixture(MockSomethingFixture(os.path, 'exists',
- lambda file: True))
+ lambda file: True))
board_conf.hardwarepack_handler = (
TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
board_conf.hardwarepack_handler.get_format = (
@@ -1428,7 +1439,7 @@
for name in dir(boards):
attr = getattr(boards, name)
- if type(attr) == types.FunctionType:
+ if isinstance(attr, types.FunctionType):
self.useFixture(MockSomethingFixture(
linaro_image_tools.media_create.boards, name,
mock_func_creator(name)))
@@ -1461,21 +1472,21 @@
lambda *args, **kwargs: self.funcs_calls.append(name))
self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards.SnowballEmmcConfig,
- 'get_file_info',
- mock_func_creator('get_file_info')))
- self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards.SnowballEmmcConfig,
- 'create_toc',
- mock_func_creator('create_toc')))
- self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards.SnowballEmmcConfig,
- 'install_snowball_boot_loader',
- mock_func_creator('install_snowball_boot_loader')))
- self.useFixture(MockSomethingFixture(
- linaro_image_tools.media_create.boards.SnowballEmmcConfig,
- 'delete_file',
- mock_func_creator('delete_file')))
+ linaro_image_tools.media_create.boards.SnowballEmmcConfig,
+ 'get_file_info',
+ mock_func_creator('get_file_info')))
+ self.useFixture(MockSomethingFixture(
+ linaro_image_tools.media_create.boards.SnowballEmmcConfig,
+ 'create_toc',
+ mock_func_creator('create_toc')))
+ self.useFixture(MockSomethingFixture(
+ linaro_image_tools.media_create.boards.SnowballEmmcConfig,
+ 'install_snowball_boot_loader',
+ mock_func_creator('install_snowball_boot_loader')))
+ self.useFixture(MockSomethingFixture(
+ linaro_image_tools.media_create.boards.SnowballEmmcConfig,
+ 'delete_file',
+ mock_func_creator('delete_file')))
self.populate_raw_partition(boards.SnowballEmmcConfig())
expected = ['get_file_info', 'create_toc',
'install_snowball_boot_loader', 'delete_file',
@@ -1515,7 +1526,7 @@
def test_arndale_raw(self):
self.useFixture(MockSomethingFixture(os.path, 'getsize',
- lambda file: 1))
+ lambda file: 1))
self.populate_raw_partition(boards.ArndaleConfig())
expected = ['_dd', '_dd', '_dd']
@@ -1563,24 +1574,24 @@
expected_commands = ['sudo -E cp boot/u-boot.bin ./startupfiles']
self.useFixture(MockSomethingFixture(
- android_boards.AndroidSnowballEmmcConfig,
- 'get_file_info',
- mock_func_creator('get_file_info')))
- self.useFixture(MockSomethingFixture(
- android_boards.AndroidSnowballEmmcConfig,
- 'create_toc',
- mock_func_creator('create_toc')))
- self.useFixture(MockSomethingFixture(
- android_boards.AndroidSnowballEmmcConfig,
- 'install_snowball_boot_loader',
- mock_func_creator('install_snowball_boot_loader')))
- self.useFixture(MockSomethingFixture(
- android_boards.AndroidSnowballEmmcConfig,
- 'delete_file',
- mock_func_creator('delete_file')))
+ android_boards.AndroidSnowballEmmcConfig,
+ 'get_file_info',
+ mock_func_creator('get_file_info')))
+ self.useFixture(MockSomethingFixture(
+ android_boards.AndroidSnowballEmmcConfig,
+ 'create_toc',
+ mock_func_creator('create_toc')))
+ self.useFixture(MockSomethingFixture(
+ android_boards.AndroidSnowballEmmcConfig,
+ 'install_snowball_boot_loader',
+ mock_func_creator('install_snowball_boot_loader')))
+ self.useFixture(MockSomethingFixture(
+ android_boards.AndroidSnowballEmmcConfig,
+ 'delete_file',
+ mock_func_creator('delete_file')))
self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig())
expected_calls = ['get_file_info', 'create_toc',
- 'install_snowball_boot_loader', 'delete_file']
+ 'install_snowball_boot_loader', 'delete_file']
# Test that we copy the u-boot files to the local startupfiles dir.
self.assertEqual(expected_commands, fixture.mock.commands_executed)
# Test that we run the Snowball populate_raw_partition() and only
@@ -1664,12 +1675,13 @@
def test_align_partition_4_mib_4_mib(self):
expected = (4 * 1024 * 1024, 8 * 1024 * 1024 - 1, 4 * 1024 * 1024)
self.assertEqual(expected,
- align_partition(1, 1, 4 * 1024 * 1024, 4 * 1024 * 1024))
+ align_partition(1, 1,
+ 4 * 1024 * 1024, 4 * 1024 * 1024))
def test_align_partition_none_4_mib(self):
expected = (1, 4 * 1024 * 1024 - 1, 4 * 1024 * 1024 - 1)
self.assertEqual(expected,
- align_partition(1, 1, 1, 4 * 1024 * 1024))
+ align_partition(1, 1, 1, 4 * 1024 * 1024))
class TestFixForBug697824(TestCaseWithFixtures):
@@ -1686,7 +1698,7 @@
config._make_boot_files = MagicMock()
config._make_boot_files_v2 = MagicMock()
config.set_appropriate_serial_tty = MagicMock(
- side_effect=set_appropriate_serial_tty_mock)
+ side_effect=set_appropriate_serial_tty_mock)
def test_omap_make_boot_files(self):
self.set_appropriate_serial_tty_called = False
@@ -1900,10 +1912,10 @@
board_conf = get_board_config('origen')
board_conf.partition_layout = 'reserved_bootfs_rootfs'
board_conf.LOADER_MIN_SIZE_S = (
- board_conf.samsung_bl1_start +
- board_conf.samsung_bl1_len +
- board_conf.samsung_bl2_len +
- board_conf.samsung_env_len)
+ board_conf.samsung_bl1_start +
+ board_conf.samsung_bl1_len +
+ board_conf.samsung_bl2_len +
+ board_conf.samsung_env_len)
self.assertEquals(
'1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
board_conf.get_sfdisk_cmd())
@@ -1912,10 +1924,10 @@
board_conf = get_board_config('origen_quad')
board_conf.partition_layout = 'reserved_bootfs_rootfs'
board_conf.LOADER_MIN_SIZE_S = (
- board_conf.samsung_bl1_start +
- board_conf.samsung_bl1_len +
- board_conf.samsung_bl2_len +
- board_conf.samsung_env_len)
+ board_conf.samsung_bl1_start +
+ board_conf.samsung_bl1_len +
+ board_conf.samsung_bl2_len +
+ board_conf.samsung_env_len)
self.assertEquals(
'1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
board_conf.get_sfdisk_cmd())
@@ -1989,12 +2001,12 @@
rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
expected = {
'bootargs': 'console=ttySAC1,115200n8 root=UUID=deadbeef '
- 'rootwait ro',
- 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
- 'fatload mmc 0:2 0x42000000 uInitrd; '
- 'bootm 0x40007000 0x42000000',
- 'ethact': 'smc911x-0',
- 'ethaddr': '00:40:5c:26:0a:5b',
+ 'rootwait ro',
+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
+ 'fatload mmc 0:2 0x42000000 uInitrd; '
+ 'bootm 0x40007000 0x42000000',
+ 'ethact': 'smc911x-0',
+ 'ethaddr': '00:40:5c:26:0a:5b',
'fdt_high': '0xffffffff',
'initrd_high': '0xffffffff'}
self.assertEqual(expected, boot_commands)
@@ -2006,10 +2018,10 @@
rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
expected = {
'bootargs': 'console=ttySAC2,115200n8 root=UUID=deadbeef '
- 'rootwait ro',
- 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
- 'fatload mmc 0:2 0x42000000 uInitrd; '
- 'bootm 0x40007000 0x42000000',
+ 'rootwait ro',
+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
+ 'fatload mmc 0:2 0x42000000 uInitrd; '
+ 'bootm 0x40007000 0x42000000',
'fdt_high': '0xffffffff',
'initrd_high': '0xffffffff'}
self.assertEqual(expected, boot_commands)
@@ -2022,9 +2034,9 @@
expected = {
'bootargs': 'console=ttySAC2,115200n8 root=UUID=deadbeef '
'rootwait ro',
- 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
- 'fatload mmc 0:2 0x42000000 uInitrd; '
- 'bootm 0x40007000 0x42000000',
+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
+ 'fatload mmc 0:2 0x42000000 uInitrd; '
+ 'bootm 0x40007000 0x42000000',
'fdt_high': '0xffffffff',
'initrd_high': '0xffffffff'}
self.assertEqual(expected, boot_commands)
@@ -2037,12 +2049,12 @@
expected = {
'bootargs': 'root=UUID=deadbeef rootwait ro',
'bootcmd': 'fatload mmc 0:2 None uImage; '
- 'fatload mmc 0:2 None uInitrd; '
- 'bootm None None',
- 'ethact': 'smc911x-0',
- 'ethaddr': '00:40:5c:26:0a:5b',
- 'fdt_high': '0xffffffff',
- 'initrd_high': '0xffffffff'}
+ 'fatload mmc 0:2 None uInitrd; '
+ 'bootm None None',
+ 'ethact': 'smc911x-0',
+ 'ethaddr': '00:40:5c:26:0a:5b',
+ 'fdt_high': '0xffffffff',
+ 'initrd_high': '0xffffffff'}
self.assertEqual(expected, boot_commands)
def test_ux500(self):
@@ -2360,9 +2372,10 @@
self.useFixture(MockSomethingFixture(
os.path, "getsize",
lambda s: (BoardConfig.LOADER_MIN_SIZE_S - 1) * SECTOR_SIZE + 1))
- self.assertRaises(AssertionError,
+ self.assertRaises(
+ AssertionError,
install_mx5_boot_loader, "imx_file", "boot_device_or_file",
- BoardConfig.LOADER_MIN_SIZE_S)
+ BoardConfig.LOADER_MIN_SIZE_S)
def test_install_omap_boot_loader(self):
fixture = self._mock_Popen()
@@ -2409,10 +2422,12 @@
chroot_dir_value = 'chroot_dir'
board_conf._get_samsung_spl = MagicMock()
board_conf._get_samsung_spl.return_value = ("%s/%s/SPL" %
- (chroot_dir_value, bootloader_flavor))
+ (chroot_dir_value,
+ bootloader_flavor))
board_conf._get_samsung_bootloader = MagicMock()
board_conf._get_samsung_bootloader.return_value = ("%s/%s/uboot" %
- (chroot_dir_value, bootloader_flavor))
+ (chroot_dir_value,
+ bootloader_flavor))
board_conf.hardwarepack_handler = (
TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
board_conf.hardwarepack_handler.get_format = (
@@ -2462,7 +2477,7 @@
board_conf, bootloader_flavor, chroot_dir_value = \
self._set_up_board_config('arndale')
self.useFixture(MockSomethingFixture(os.path, 'getsize',
- lambda file: 1))
+ lambda file: 1))
board_conf.install_samsung_boot_loader(
board_conf._get_samsung_spl(chroot_dir_value),
board_conf._get_samsung_bootloader(chroot_dir_value),
@@ -2843,9 +2858,9 @@
self.assertEqual(0, wait_partition_to_settle(media))
def test_wait_partitions_to_settle_raises_SubcommandNonZeroReturnValue(
- self):
+ self):
def mock_run(args, as_root=False, chroot=None, stdin=None, stdout=None,
- stderr=None, cwd=None):
+ stderr=None, cwd=None):
raise cmd_runner.SubcommandNonZeroReturnValue(args, 1)
self.useFixture(MockSomethingFixture(
@@ -2857,8 +2872,8 @@
media.is_block_device = True
self.assertRaises(cmd_runner.SubcommandNonZeroReturnValue,
- wait_partition_to_settle,
- media)
+ wait_partition_to_settle,
+ media)
class TestPartitionSetup(TestCaseWithFixtures):
@@ -2873,7 +2888,7 @@
(16384 * SECTOR_SIZE, 15746 * SECTOR_SIZE),
(32768 * SECTOR_SIZE, (self.linux_image_size -
32768 * SECTOR_SIZE))
- ]
+ ]
self.android_image_size = 256 * 1024 ** 2
# Extended partition info takes 32 sectors from the first ext partition
ext_part_size = 32
@@ -2885,7 +2900,7 @@
(131072 - ext_part_size) * SECTOR_SIZE),
((426047 + ext_part_size) * SECTOR_SIZE,
self.android_image_size - (426047 + ext_part_size) * SECTOR_SIZE)
- ]
+ ]
self.android_snowball_offsets_and_sizes = [
(8192 * SECTOR_SIZE, 24639 * SECTOR_SIZE),
@@ -2895,7 +2910,7 @@
(294975 * SECTOR_SIZE, 131072 * SECTOR_SIZE),
((426047 + ext_part_size) * SECTOR_SIZE,
self.android_image_size - (426047 + ext_part_size) * SECTOR_SIZE)
- ]
+ ]
def tearDown(self):
super(TestPartitionSetup, self).tearDown()
@@ -2909,14 +2924,14 @@
def _create_android_tmpfile(self):
# boot, system, cache, (extended), userdata and sdcard partitions
return self._create_qemu_img_with_partitions(
- '63,32768,0x0C,*\n32831,65536,L\n98367,65536,L\n294975,-,E\n' \
- '294975,131072,L\n426047,,,-', '%s' % self.android_image_size)
+ '63,32768,0x0C,*\n32831,65536,L\n98367,65536,L\n294975,-,E\n'
+ '294975,131072,L\n426047,,,-', '%s' % self.android_image_size)
def _create_snowball_android_tmpfile(self):
# raw, boot, system, cache, (extended), userdata and sdcard partitions
return self._create_qemu_img_with_partitions(
- '256,7936,0xDA\n8192,24639,0x0C,*\n32831,65536,L\n' \
- '98367,-,E\n98367,65536,L\n294975,131072,L\n' \
+ '256,7936,0xDA\n8192,24639,0x0C,*\n32831,65536,L\n'
+ '98367,-,E\n98367,65536,L\n294975,131072,L\n'
'426047,,,-', '%s' % self.android_image_size)
def test_check_min_size_small(self):
@@ -3144,7 +3159,7 @@
board_conf, Media(tmpfile), '2G', 'boot',
'root', 'ext3', True, True, True)
self.assertEqual(
- # This is the call that would create a 2 GiB image file.
+ # This is the call that would create a 2 GiB image file.
['dd of=%s bs=1 seek=2147483648 count=0' % tmpfile,
'%s sfdisk -l %s' % (sudo_args, tmpfile),
# This call would partition the image file.
@@ -3214,8 +3229,8 @@
media = Media(tmpfile)
media.is_block_device = True
self.assertRaises(dbus.exceptions.DBusException,
- _get_device_file_for_partition_number,
- media.path, partition)
+ _get_device_file_for_partition_number,
+ media.path, partition)
def test_get_device_file_for_partition_number(self):
class Namespace:
@@ -3357,13 +3372,13 @@
TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')
self.config.hardwarepack_handler.get_format = lambda: '3.0'
self.config.hardwarepack_handler.get_file = \
- lambda file_alias: ['file1', 'file2']
+ lambda file_alias: ['file1', 'file2']
self.config.hardwarepack_handler.get_file_from_package = \
self.get_file_from_package
self.config.bootloader_copy_files = {
"package1":
- [{"file1": "/boot/"},
- {"file2": "/boot/grub/renamed"}]}
+ [{"file1": "/boot/"},
+ {"file2": "/boot/grub/renamed"}]}
self.popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
self.useFixture(MockSomethingFixture(
@@ -3403,7 +3418,8 @@
self.config.bootloader = "u_boot"
self.call_populate_boot(self.config)
expected_calls = self.expected_calls[:]
- expected_calls.insert(2,
+ expected_calls.insert(
+ 2,
'%s cp -v chroot_dir/usr/lib/u-boot/bootloader_flavor/u-boot.bin '
'boot_disk' % sudo_args)
self.assertEquals(
@@ -3430,12 +3446,12 @@
expected_calls = self.expected_calls[:]
expected_calls.insert(2, '%s mkdir -p boot_disk/boot' % sudo_args)
expected_calls.insert(3,
- '%s cp -v file1 '
- 'boot_disk/boot/' % sudo_args)
+ '%s cp -v file1 '
+ 'boot_disk/boot/' % sudo_args)
expected_calls.insert(4, '%s mkdir -p boot_disk/boot/grub' % sudo_args)
expected_calls.insert(5,
- '%s cp -v file2 '
- 'boot_disk/boot/grub/renamed' % sudo_args)
+ '%s cp -v file2 '
+ 'boot_disk/boot/grub/renamed' % sudo_args)
self.assertEquals(
expected_calls, self.popen_fixture.mock.commands_executed)
self.assertEquals(self.expected_args, self.saved_args)
@@ -3524,7 +3540,7 @@
'%s mv %s %s %s' % (
sudo_args, contents_bin, contents_etc, root_disk),
'%s dd if=/dev/zero of=%s bs=1M count=100' % (
- sudo_args, swap_file),
+ sudo_args, swap_file),
'%s mkswap %s' % (sudo_args, swap_file),
'sync',
'%s umount %s' % (sudo_args, root_disk)]
@@ -3603,8 +3619,8 @@
def test_update_interfaces_no_interfaces_no_update(self):
self.useFixture(MockSomethingFixture(
- rootfs, 'write_data_to_protected_file',
- self.mock_write_data_to_protected_file))
+ rootfs, 'write_data_to_protected_file',
+ self.mock_write_data_to_protected_file))
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
os.makedirs(os.path.join(tempdir, 'etc', 'network'))
if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
@@ -3614,8 +3630,8 @@
def test_update_interfaces_creates_entry(self):
self.useFixture(MockSomethingFixture(
- rootfs, 'write_data_to_protected_file',
- self.mock_write_data_to_protected_file))
+ rootfs, 'write_data_to_protected_file',
+ self.mock_write_data_to_protected_file))
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
os.makedirs(os.path.join(tempdir, 'etc', 'network'))
if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
@@ -3630,8 +3646,8 @@
def test_update_interfaces_creates_entries(self):
self.useFixture(MockSomethingFixture(
- rootfs, 'write_data_to_protected_file',
- self.mock_write_data_to_protected_file))
+ rootfs, 'write_data_to_protected_file',
+ self.mock_write_data_to_protected_file))
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
os.makedirs(os.path.join(tempdir, 'etc', 'network'))
if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
@@ -3650,8 +3666,8 @@
def test_update_interfaces_leaves_original(self):
self.useFixture(MockSomethingFixture(
- rootfs, 'write_data_to_protected_file',
- self.mock_write_data_to_protected_file))
+ rootfs, 'write_data_to_protected_file',
+ self.mock_write_data_to_protected_file))
tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
os.makedirs(os.path.join(tempdir, 'etc', 'network'))
if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
@@ -3791,11 +3807,11 @@
class TestInstallHWPack(TestCaseWithFixtures):
def create_minimal_v3_hwpack(self, location, name, version, architecture):
metadata = "\n".join([
- "name: " + name,
- "version: " + version,
- "architecture: " + architecture,
- "format: 3.0"
- ])
+ "name: " + name,
+ "version: " + version,
+ "architecture: " + architecture,
+ "format: 3.0"
+ ])
print metadata
tar_file = tarfile.open(location, mode='w:gz')
tarinfo = tarfile.TarInfo("metadata")
@@ -3806,7 +3822,7 @@
def mock_prepare_chroot(self, chroot_dir, tmp_dir):
def fake_prepare_chroot(chroot_dir, tmp_dir):
cmd_runner.run(['prepare_chroot %s %s' % (chroot_dir, tmp_dir)],
- as_root=True).wait()
+ as_root=True).wait()
self.useFixture(MockSomethingFixture(
linaro_image_tools.media_create.chroot_utils, 'prepare_chroot',
fake_prepare_chroot))
=== modified file 'linaro_image_tools/tests/__init__.py'
@@ -21,7 +21,7 @@
from linaro_image_tools.hwpack.tests import test_suite as hwpack_suite
from linaro_image_tools.media_create.tests import (
test_suite as media_create_suite,
- )
+)
from linaro_image_tools.utils import has_command
@@ -29,7 +29,7 @@
module_names = [
'linaro_image_tools.tests.test_cmd_runner',
'linaro_image_tools.tests.test_utils',
- ]
+ ]
# if pyflakes is installed and we're running from a bzr checkout...
if has_command('pyflakes') and not os.path.isabs(__file__):
# ...also run the pyflakes test
=== modified file 'linaro_image_tools/tests/test_cmd_runner.py'
@@ -24,7 +24,7 @@
from linaro_image_tools.tests.fixtures import (
MockCmdRunnerPopenFixture,
MockSomethingFixture,
- )
+)
sudo_args = " ".join(cmd_runner.SUDO_ARGS)
=== modified file 'linaro_image_tools/tests/test_pep8.py'
@@ -29,10 +29,11 @@
# can be re-enabled once we drop support for natty.
ignore = ['E202']
# Ignore return code.
- proc = subprocess.Popen(['pep8',
- '--repeat',
- '--ignore=%s' % ','.join(ignore),
- '.'],
+ proc = subprocess.Popen(
+ ['pep8',
+ '--repeat',
+ '--ignore=%s' % ','.join(ignore),
+ '.'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
=== modified file 'linaro_image_tools/tests/test_pyflakes.py'
@@ -25,8 +25,8 @@
def test_pyflakes(self):
# ignore return code
proc = subprocess.Popen(['pyflakes', '.'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
self.assertEquals('', stdout)
self.assertEquals('', stderr)
=== modified file 'linaro_image_tools/tests/test_utils.py'
@@ -32,7 +32,7 @@
CreateTempDirFixture,
MockCmdRunnerPopenFixture,
MockSomethingFixture,
- )
+)
from linaro_image_tools.utils import (
IncompatibleOptions,
InvalidHwpackFile,
@@ -48,7 +48,7 @@
preferred_tools_dir,
prep_media_path,
verify_file_integrity,
- )
+)
sudo_args = " ".join(cmd_runner.SUDO_ARGS)
@@ -154,9 +154,9 @@
hash_filename = "dummy-file.txt"
signature_filename = hash_filename + ".asc"
result, verified_files = check_file_integrity_and_log_errors(
- [signature_filename],
- self.filenames_in_shafile[0],
- [self.filenames_in_shafile[1]])
+ [signature_filename],
+ self.filenames_in_shafile[0],
+ [self.filenames_in_shafile[1]])
self.assertEqual(self.filenames_in_shafile, verified_files)
# The sha1sums are faked as passing and all commands return 0, so
@@ -165,14 +165,14 @@
def test_check_file_integrity_and_print_errors_fail_sha1sum(self):
logging.getLogger().setLevel(100) # Disable logging messages to screen
- self.useFixture(MockSomethingFixture(cmd_runner, 'Popen',
- self.MockCmdRunnerPopen_sha1sum_fail()))
+ self.useFixture(MockSomethingFixture(
+ cmd_runner, 'Popen', self.MockCmdRunnerPopen_sha1sum_fail()))
hash_filename = "dummy-file.txt"
signature_filename = hash_filename + ".asc"
result, verified_files = check_file_integrity_and_log_errors(
- [signature_filename],
- self.filenames_in_shafile[0],
- [self.filenames_in_shafile[1]])
+ [signature_filename],
+ self.filenames_in_shafile[0],
+ [self.filenames_in_shafile[1]])
self.assertEqual([], verified_files)
# The sha1sums are faked as failing and all commands return 0, so
@@ -182,14 +182,14 @@
def test_check_file_integrity_and_print_errors_fail_gpg(self):
logging.getLogger().setLevel(100) # Disable logging messages to screen
- self.useFixture(MockSomethingFixture(cmd_runner, 'Popen',
- self.MockCmdRunnerPopen_wait_fails()))
+ self.useFixture(MockSomethingFixture(
+ cmd_runner, 'Popen', self.MockCmdRunnerPopen_wait_fails()))
hash_filename = "dummy-file.txt"
signature_filename = hash_filename + ".asc"
result, verified_files = check_file_integrity_and_log_errors(
- [signature_filename],
- self.filenames_in_shafile[0],
- [self.filenames_in_shafile[1]])
+ [signature_filename],
+ self.filenames_in_shafile[0],
+ [self.filenames_in_shafile[1]])
self.assertEqual([], verified_files)
# The sha1sums are faked as passing and all commands return 1, so
@@ -272,10 +272,9 @@
MockCmdRunnerPopenFixture(self.output_string))
install_package_providing('mkfs.vfat')
self.assertEqual(
- ['apt-get -s install dosfstools',
- '%s apt-get --yes install dosfstools' %
- sudo_args],
- fixture.mock.commands_executed)
+ ['apt-get -s install dosfstools',
+ '%s apt-get --yes install dosfstools' % sudo_args],
+ fixture.mock.commands_executed)
def test_package_installation_refused(self):
self.useFixture(MockSomethingFixture(sys,
=== modified file 'linaro_image_tools/utils.py'
@@ -129,11 +129,11 @@
try:
sha1sums_out, _ = cmd_runner.Popen(
- ['sha1sum', '-c', hash_file],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- cwd=sha_cwd
- ).communicate()
+ ['sha1sum', '-c', hash_file],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ cwd=sha_cwd
+ ).communicate()
except cmd_runner.SubcommandNonZeroReturnValue as inst:
sha1sums_out = inst.stdout
@@ -171,7 +171,7 @@
for verified_file in verified_files:
logger.info('Hash verification of file {0} OK.'.format(
- verified_file))
+ verified_file))
return True, verified_files
@@ -214,15 +214,15 @@
print "Package installation is necessary to continue. Exiting."
sys.exit(1)
print ("Installing required command '%s' from package '%s'..."
- % (command, package))
+ % (command, package))
cmd_runner.run(['apt-get', '--yes', 'install', package],
- as_root=True).wait()
+ as_root=True).wait()
except EOFError:
raise PackageInstallationRefused(
- "Package installation interrupted: input error.")
+ "Package installation interrupted: input error.")
except KeyboardInterrupt:
raise PackageInstallationRefused(
- "Package installation interrupted by the user.")
+ "Package installation interrupted by the user.")
def has_command(command):
=== modified file 'setup.py'
@@ -6,17 +6,17 @@
DistUtilsExtra.auto.setup(
- name="linaro-image-tools",
- version=__version__,
- description="Tools to create and write Linaro images",
- url="https://launchpad.net/linaro-image-tools",
- license="GPL v3 or later",
- author='Linaro Infrastructure team',
- author_email="linaro-dev@lists.linaro.org",
+ name="linaro-image-tools",
+ version=__version__,
+ description="Tools to create and write Linaro images",
+ url="https://launchpad.net/linaro-image-tools",
+ license="GPL v3 or later",
+ author='Linaro Infrastructure team',
+ author_email="linaro-dev@lists.linaro.org",
- scripts=[
- "initrd-do",
- "linaro-hwpack-create", "linaro-hwpack-install",
- "linaro-media-create", "linaro-android-media-create",
- "linaro-hwpack-replace"],
- )
+ scripts=[
+ "initrd-do",
+ "linaro-hwpack-create", "linaro-hwpack-install",
+ "linaro-media-create", "linaro-android-media-create",
+ "linaro-hwpack-replace"],
+)