Skip to content

Commit

Permalink
cleanup cli script
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 26, 2024
1 parent 7ed5cbb commit 4779cf0
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions ckanext/dcor_schemas/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,30 +198,31 @@ def run_jobs_dcor_schemas(modified_days=-1):
past_str = time.strftime("%Y-%m-%d", past.timetuple())
datasets = datasets.filter(model.Package.metadata_modified >= past_str)

job_list = jobs.RQJob.get_all_job_methods_in_order(
ckanext="dcor_schemas")

nl = False # new line character
for dataset in datasets:
try:
nl = False
click.echo(f"Checking dataset {dataset.id}\r", nl=False)

job_list = jobs.RQJob.get_all_job_methods_in_order(
ckanext="dcor_schemas")

for resource in dataset.resources:
res_dict = resource.as_dict()
nl = False
click.echo(f"Checking dataset {dataset.id}\r", nl=False)

for resource in dataset.resources:
res_dict = resource.as_dict()
try:
for job in job_list:
if job.method(res_dict):
if not nl:
click.echo("")
nl = True
click.echo(f"OK: {job.title} for {resource.name}")

except BaseException as e:
click.echo(
f"\nEncountered {e.__class__.__name__} for {dataset.id}!",
err=True)
click.echo(traceback.format_exc(), err=True)
except KeyboardInterrupt:
raise
except BaseException as e:
click.echo(
f"\n{e.__class__.__name__} for {res_dict['name']}!",
err=True)
click.echo(traceback.format_exc(), err=True)
nl = True
if not nl:
click.echo("")
click.echo("Done!")
Expand Down

0 comments on commit 4779cf0

Please sign in to comment.