Change logic to prevent sys.exit from stopping script processing

This commit is contained in:
Hank Preston 2020-05-06 13:25:09 -04:00
parent 5769684c98
commit 5292afaae0
28 changed files with 544 additions and 572 deletions

View file

@ -6,18 +6,17 @@ import sys
rack_roles = load_yaml('/opt/netbox/initializers/rack_roles.yml')
if rack_roles is None:
sys.exit()
if not rack_roles is None:
for params in rack_roles:
if 'color' in params:
color = params.pop('color')
for params in rack_roles:
if 'color' in params:
color = params.pop('color')
for color_tpl in COLOR_CHOICES:
if color in color_tpl:
params['color'] = color_tpl[0]
for color_tpl in COLOR_CHOICES:
if color in color_tpl:
params['color'] = color_tpl[0]
rack_role, created = RackRole.objects.get_or_create(**params)
rack_role, created = RackRole.objects.get_or_create(**params)
if created:
print("🎨 Created rack role", rack_role.name)
if created:
print("🎨 Created rack role", rack_role.name)