Skip to content

Commit

Permalink
Merge pull request #135 from galaxyproject/imporve_registry_import_lo…
Browse files Browse the repository at this point in the history
…gging

Improve logging when importing registries
  • Loading branch information
nuwang committed Oct 23, 2020
2 parents d404627 + 07e14b4 commit 5b2e9c4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cloudman/helmsman/management/commands/add_template_registry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.core.management import call_command
from django.core.management.base import BaseCommand

import logging as log
import requests
import yaml

from django.core.management import call_command
from django.core.management.base import BaseCommand

from helmsman import helpers


Expand All @@ -19,10 +20,16 @@ def handle(self, *args, **options):

@staticmethod
def add_template_registry(name, url):
with requests.get(url) as r:
registry = yaml.safe_load(r.content)
if registry.get('install_templates'):
Command.process_install_templates(registry.get('install_templates'))
print(f"Importing template registry: {name} from: {url}")
try:
with requests.get(url) as r:
registry = yaml.safe_load(r.content)
if registry.get('install_templates'):
Command.process_install_templates(registry.get('install_templates'))
except Exception as e:
log.exception(f"An error occurred while importing registry '{name}':", e)
print(f"An error occurred while importing registry '{name}':", str(e))
raise e

@staticmethod
def process_install_templates(install_templates):
Expand Down

0 comments on commit 5b2e9c4

Please sign in to comment.