Skip to content

Commit

Permalink
Use try/except in the changeset ingestion commands (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel authored Mar 27, 2024
1 parent 61a80e8 commit d9b1beb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ def handle(self, *args, **options):
final = cl[0]
while id < final:
if id not in cl:
create_changeset(id)
try:
create_changeset(id)
except Exception as e:
self.stdout.write("Failed to import changeset {}: {}".format(id, e))
id = id + 1
9 changes: 8 additions & 1 deletion osmchadjango/changeset/management/commands/import_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
filename = options['filename'][0]
cl = ChangesetList(filename, geojson=settings.CHANGESETS_FILTER)
imported = [create_changeset(c['id']) for c in cl.changesets]
imported = []

for c in cl.changesets:
try:
create_changeset(c['id'])
imported.append(c['id'])
except Exception as e:
self.stdout.write("Failed to import changeset {}: {}".format(c["id"], e))

self.stdout.write(
'{} changesets created from {}.'.format(len(imported), filename)
Expand Down

0 comments on commit d9b1beb

Please sign in to comment.