mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 19:21:06 -03:30
AC-596 Fix for inventory import traceback.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user