diff --git a/internetarchive/cli/ia_upload.py b/internetarchive/cli/ia_upload.py index aeaa0e2f..283fd03e 100644 --- a/internetarchive/cli/ia_upload.py +++ b/internetarchive/cli/ia_upload.py @@ -61,12 +61,13 @@ import six from docopt import docopt, printable_usage -from requests.exceptions import HTTPError +from requests.exceptions import HTTPError, ConnectionError from schema import Schema, Use, Or, And, SchemaError from internetarchive.cli.argparser import get_args_dict, convert_str_list_to_unicode from internetarchive.session import ArchiveSession from internetarchive.utils import validate_ia_identifier, get_s3_xml_text +from internetarchive import get_item # Only import backports.csv for Python2 (in support of FreeBSD port). PY2 = sys.version_info[0] == 2 @@ -87,6 +88,10 @@ def _upload_files(item, files, upload_kwargs, prev_identifier=None, archive_sess responses += response except HTTPError as exc: responses += [exc.response] + except ConnectionError as exc: + print("Received ConnectionError while uploading. If this happens consistently,", + " the item you're uploading to might be full. Run --status-check!") + raise finally: # Debug mode. if upload_kwargs['debug']: @@ -176,6 +181,10 @@ def main(argv, session): 'Expect 503 SlowDown errors.'.format(args['']), file=sys.stderr) sys.exit(1) + elif get_item('{0}'.format(args[''])).item_size >= 1099511627776: + print('warning: {0} is full and cannot accept uploads.'.format(args['']), + file=sys.stderr) + sys.exit(1) else: print('success: {0} is accepting requests.'.format(args[''])) sys.exit()