-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- mode: python -*- | ||
"""Script entry points for neurobank | ||
Copyright (C) 2013 Dan Meliza <[email protected]> | ||
Copyright (C) 2013-2024 Dan Meliza <[email protected]> | ||
Created Tue Nov 26 22:48:58 2013 | ||
""" | ||
import argparse | ||
|
@@ -30,19 +30,6 @@ def setup_log(log, debug=False): | |
log.addHandler(ch) | ||
|
||
|
||
def log_error(err): | ||
"""Writes error message from server to log. Reraises errors where code != 400""" | ||
if err.response.status_code == 400: | ||
data = err.response.json() | ||
for k, v in data.items(): | ||
for vv in v: | ||
log.error(" registry error: %s: %s", k, vv) | ||
elif err.response.status_code == 415: | ||
log.error(" registry error: %s", err.response.reason) | ||
else: | ||
raise err | ||
|
||
|
||
def userpwd(arg): | ||
"""If arg is of the form username:password, returns them as a tuple. Otherwise None.""" | ||
ret = arg.split(":") | ||
|
@@ -313,7 +300,7 @@ def main(argv=None): | |
" Or, you may not have permission for this operation." | ||
) | ||
else: | ||
log_error(e) | ||
registry.log_error(e) | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
|
@@ -343,7 +330,7 @@ def init_archive(args): | |
r = httpx.post(url, json=params, auth=args.auth) | ||
r.raise_for_status() | ||
except httpx.HTTPStatusError as e: | ||
log_error(e) | ||
registry.log_error(e) | ||
else: | ||
log.info("registered '%s' as archive '%s'", args.directory, args.name) | ||
archive.create(args.directory, args.registry_url, args.umask) | ||
|
@@ -405,7 +392,7 @@ def locate_resources(args): | |
if e.response.status_code == 404: | ||
log.error("%s: not found", id) | ||
else: | ||
log_error(e) | ||
registry.log_error(e) | ||
|
||
|
||
def search_resources(args): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters