use better defaults for dtc auto-curate options #23
1 changed files with 12 additions and 5 deletions
|
|
@ -44,17 +44,17 @@ stl_info = False
|
|||
@click.option(
|
||||
'--destination-service-url',
|
||||
metavar='DEST_SERVICE_URL',
|
||||
help='select a different dump-thing-service, i.e. not SERVICE_URL, as destination for auto-curated records',
|
||||
help='select a different dump-thing-service, i.e. not SERVICE_URL, as destination for auto-curated records (the default is SERVICE_URL)',
|
||||
)
|
||||
@click.option(
|
||||
'--destination-collection',
|
||||
metavar='DEST_COLLECTION',
|
||||
help='select a different collection, i.e. not the COLLECTION of SERVICE_URL, as destination for auto-curated records',
|
||||
help='select a different collection, i.e. not COLLECTION, as destination for auto-curated records',
|
||||
)
|
||||
@click.option(
|
||||
'--destination-token',
|
||||
metavar='DEST_TOKEN',
|
||||
help='if provided, this token will be used the authenticate again DEST_SERVICE_URL, otherwise the token for SERVICE_URL will be used',
|
||||
help='if provided, this token will be used the authenticate against DEST_SERVICE_URL, which defaults to SERVICE_URL (the default is the token provided via --token)',
|
||||
)
|
||||
@click.option(
|
||||
'--pid', '-p',
|
||||
|
|
@ -154,6 +154,12 @@ def auto_curate(
|
|||
console.print(f'[red]Error[/red]: no token was provided (use --token or DTC_TOKEN environment variable)')
|
||||
return 1
|
||||
|
||||
if destination_service_url is None:
|
||||
destination_service_url = service_url
|
||||
|
||||
if destination_token is None:
|
||||
destination_token = curator_token
|
||||
|
||||
output = None
|
||||
|
||||
# If --list-labels and --list-records are provided, keep only the latter,
|
||||
|
|
@ -257,7 +263,8 @@ def auto_curate(
|
|||
collection=destination_collection,
|
||||
class_name=class_name,
|
||||
record=record,
|
||||
token=destination_token)
|
||||
token=destination_token,
|
||||
)
|
||||
except HTTPError as e:
|
||||
console.print(
|
||||
f'[red]Error[/red]: writing record with pid {record["pid"]} failed: {e}: {e.response.text}',
|
||||
|
|
@ -271,7 +278,7 @@ def auto_curate(
|
|||
collection=collection,
|
||||
label=label,
|
||||
pid=record['pid'],
|
||||
token=obj,
|
||||
token=curator_token,
|
||||
)
|
||||
except HTTPError as e:
|
||||
console.print(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue