X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/55aafbb07904ca24390dd47ea960eae7cb2b909a..8f987a9271eda80697b3a8fc53e7ebb0f93816f9:/sdk/python/arvados/commands/put.py diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py index 68f63b1c26..ec4ae8fb6f 100644 --- a/sdk/python/arvados/commands/put.py +++ b/sdk/python/arvados/commands/put.py @@ -193,6 +193,11 @@ Display machine-readable progress on stderr (bytes and, if known, total data size). """) +_group.add_argument('--silent', action='store_true', + help=""" +Do not print any debug messages to console. (Any error messages will still be displayed.) +""") + _group = run_opts.add_mutually_exclusive_group() _group.add_argument('--resume', action='store_true', default=True, help=""" @@ -243,7 +248,7 @@ def parse_arguments(arguments): """) # Turn on --progress by default if stderr is a tty. - if (not (args.batch_progress or args.no_progress) + if (not (args.batch_progress or args.no_progress or args.silent) and os.isatty(sys.stderr.fileno())): args.progress = True @@ -705,6 +710,7 @@ class ArvPutUploadJob(object): elif file_in_local_collection.permission_expired(): # Permission token expired, re-upload file. This will change whenever # we have a API for refreshing tokens. + self.logger.warning("Uploaded file '{}' access token expired, will re-upload it from scratch".format(filename)) should_upload = True self._local_collection.remove(filename) elif cached_file_data['size'] == file_in_local_collection.size(): @@ -964,9 +970,12 @@ def desired_project_uuid(api_client, project_uuid, num_retries): def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr): global api_client - logger = logging.getLogger('arvados.arv_put') - logger.setLevel(logging.INFO) args = parse_arguments(arguments) + logger = logging.getLogger('arvados.arv_put') + if args.silent: + logger.setLevel(logging.WARNING) + else: + logger.setLevel(logging.INFO) status = 0 if api_client is None: api_client = arvados.api('v1') @@ -1135,7 +1144,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr): # Print the locator (uuid) of the new collection. if output is None: status = status or 1 - else: + elif not args.silent: stdout.write(output) if not output.endswith('\n'): stdout.write('\n')