=== modified file 'README'
@@ -36,6 +36,7 @@
- apt-utils
- pep8
- python-mock
+ - python-commandnotfound (as of Ubuntu 12.10)
Also consider installing pyflakes, which is optional but will enable more
tests.
@@ -50,7 +51,8 @@
$ sudo apt-get install testrepository python-testtools python-debian \
python-argparse dpkg-dev python-parted dbus udisks python-dbus \
- python-apt qemu-kvm util-linux apt-utils pep8 pyflakes
+ python-apt qemu-kvm util-linux apt-utils pep8 pyflakes \
+ python-commandnotfound
To initialized testsuite, run the following command:
=== modified file 'linaro-media-create'
@@ -98,8 +98,13 @@
required_commands.append('mkfs.%s' % args.rootfs)
else:
raise AssertionError('Unsupported rootfs type %s' % args.rootfs)
+
for command in required_commands:
- ensure_command(command)
+ try:
+ ensure_command(command)
+ except UnableToFindPackageProvidingCommand:
+ logger.error("Could not look up command %s. Please ensure that command %s is installed." % (command, command))
+ raise
if __name__ == '__main__':
@@ -177,7 +182,10 @@
ROOTFS_DIR = os.path.join(BIN_DIR, filesystem_dir)
- ensure_required_commands(args)
+ try:
+ ensure_required_commands(args)
+ except UnableToFindPackageProvidingCommand:
+ sys.exit(1)
sig_file_list = args.hwpacksigs[:]
if args.binarysig is not None:
=== modified file 'linaro_image_tools/tests/test_utils.py'
@@ -47,6 +47,7 @@
path_in_tarfile_exists,
preferred_tools_dir,
prep_media_path,
+ try_import,
verify_file_integrity,
)
@@ -270,11 +271,17 @@
StringIO('Y')))
fixture = self.useFixture(
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)
+
+ try:
+ install_package_providing('mkfs.vfat')
+ except UnableToFindPackageProvidingCommand as inst:
+ self.assertEqual("CommandNotFound python module does not exist.",
+ inst.args[0])
+ else:
+ self.assertEqual(
+ ['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,
@@ -286,7 +293,15 @@
'stdin',
StringIO('n')))
self.useFixture(MockCmdRunnerPopenFixture(self.output_string))
- self.assertRaises(SystemExit, install_package_providing, 'mkfs.vfat')
+
+ CommandNotFound = try_import('CommandNotFound.CommandNotFound')
+
+ if CommandNotFound is None:
+ self.assertRaises(UnableToFindPackageProvidingCommand,
+ install_package_providing, 'mkfs.vfat')
+ else:
+ self.assertRaises(SystemExit, install_package_providing,
+ 'mkfs.vfat')
def test_not_found_package(self):
self.assertRaises(UnableToFindPackageProvidingCommand,
=== modified file 'linaro_image_tools/utils.py'
@@ -186,7 +186,7 @@
if CommandNotFound is None:
raise UnableToFindPackageProvidingCommand(
- "Cannot lookup a package which provides %s" % command)
+ "CommandNotFound python module does not exist.")
packages = CommandNotFound().getPackages(command)
if len(packages) == 0: