Commit 5382b56d authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Merge branch 'v0-hotfixes' into 'v0.10.9'

Merge v0-hotfixes into v0.10.9

See merge request !449
parents 00e1ed8c 0a238314
Pipeline #114692 passed with stages
in 26 minutes and 59 seconds
...@@ -91,22 +91,17 @@ response_types = [ ...@@ -91,22 +91,17 @@ response_types = [
def rdf_respose(g: Graph) -> Response: def rdf_respose(g: Graph) -> Response:
args = arg_parser.parse_args() args = arg_parser.parse_args()
format_ = args.get('format') format_ = args.get('format')
accept_header = None
if format_ is None: if format_ is None:
accept_header = request.headers.get('Accept', None) accept_header = request.headers.get('Accept', None)
if accept_header is not None: if accept_header is not None:
format_ = all_repsonse_types.get(accept_header, 'pretty-xml') format_ = all_repsonse_types.get(accept_header, 'pretty-xml')
else: else:
accept_header = None
format_ = 'pretty-xml' format_ = 'pretty-xml'
if accept_header is not None: try:
content_type = accept_header content_type = next(key for key, value in all_repsonse_types.items() if value == format_)
else: except StopIteration:
try: content_type = 'application/xml' if format in ['xml', 'pretty-xml'] else 'text/%s' % format_
content_type = next(key for key, value in all_repsonse_types.items() if value == format_)
except StopIteration:
content_type = 'application/xml' if format in ['xml', 'pretty-xml'] else 'text/%s' % format_
return Response( return Response(
g.serialize(format=format_).decode('utf-8'), 200, g.serialize(format=format_).decode('utf-8'), 200,
......
...@@ -404,8 +404,9 @@ def re_pack(ctx, uploads, parallel: int): ...@@ -404,8 +404,9 @@ def re_pack(ctx, uploads, parallel: int):
@uploads.command(help='Prepares files for being used in the upcoming NOMAD v1.0.') @uploads.command(help='Prepares files for being used in the upcoming NOMAD v1.0.')
@click.argument('UPLOADS', nargs=-1) @click.argument('UPLOADS', nargs=-1)
@click.option('--dry', is_flag=True, help='Just check, do nothing.') @click.option('--dry', is_flag=True, help='Just check, do nothing.')
@click.option('-f', '--force', is_flag=True, help='Ignore warnings and perform the operation regardless.')
@click.pass_context @click.pass_context
def prepare_migration(ctx, uploads, dry): def prepare_migration(ctx, uploads, dry, force):
''' '''
Removes one of the raw files, either public or restricted depending on the embargo. Removes one of the raw files, either public or restricted depending on the embargo.
Files that need to be removed are saved as `quarantined` in the upload folder. Files that need to be removed are saved as `quarantined` in the upload folder.
...@@ -446,7 +447,7 @@ def prepare_migration(ctx, uploads, dry): ...@@ -446,7 +447,7 @@ def prepare_migration(ctx, uploads, dry):
if not to_move.exists(): if not to_move.exists():
print(' obsolute raw.zip was already removed', upload.upload_id, to_move.os_path) print(' obsolute raw.zip was already removed', upload.upload_id, to_move.os_path)
elif to_stay.size < to_move.size: elif to_stay.size < to_move.size and not force:
print(' !!! likely inconsistent pack !!!') print(' !!! likely inconsistent pack !!!')
elif to_move.size == 22: elif to_move.size == 22:
...@@ -454,7 +455,7 @@ def prepare_migration(ctx, uploads, dry): ...@@ -454,7 +455,7 @@ def prepare_migration(ctx, uploads, dry):
to_move.delete() to_move.delete()
print(' removed empty zip', upload.upload_id, to_move.os_path) print(' removed empty zip', upload.upload_id, to_move.os_path)
elif with_embargo: elif with_embargo and not force:
print(' !!! embargo upload with non empty public file !!!') print(' !!! embargo upload with non empty public file !!!')
else: else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment