AC-596 Fix for inventory import traceback.

This commit is contained in:
Chris Church
2013-10-31 15:04:57 -04:00
parent 9e9d696c79
commit 15f337d183
2 changed files with 3 additions and 3 deletions

View File

@@ -363,7 +363,7 @@ def load_inventory_source(source, all_group=None):
logger.debug('Analyzing type of source: %s', source)
original_all_group = all_group
if not os.path.exists(source):
raise CommandError('Source does not exist: %s' % source)
raise IOError('Source does not exist: %s' % source)
if os.path.isdir(source):
all_group = all_group or MemGroup('all', source)
for filename in glob.glob(os.path.join(source, '*')):
@@ -421,7 +421,7 @@ class Command(NoArgsCommand):
class Formatter(logging.Formatter):
def format(self, record):
record.relativeSeconds = record.relativeCreated / 1000.0
return super(Formatter, self).format(record)
return logging.Formatter.format(self, record)
formatter = Formatter('%(relativeSeconds)9.3f %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
self.logger.addHandler(handler)

View File

@@ -514,7 +514,7 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest):
result, stdout, stderr = self.run_command('inventory_import',
inventory_id=inventory_id,
source=invalid_source)
self.assertTrue(isinstance(result, CommandError), result)
self.assertTrue(isinstance(result, IOError), result)
self.assertTrue('not exist' in str(result))
# Invalid inventory ID.
invalid_id = Inventory.objects.order_by('-pk')[0].pk + 1