script uses pieces of that.
    """
    if sys.version_info >= (3, 0):
        raise IOError(
            "Incompatible Python version. This script requires Python 2.x, you are using {0}.".format(
                sys.version_info[:2]
            )
        )

    if len(sys.argv) < 2:
        print("Usage: python upload_with_authentication.py path")
        raise IOError("Bad input parameters.")
    path = sys.argv[1]

    # if no success/failed folders, create them
    create_dirs()

    # get env variables
    try:
        MAPILLARY_USERNAME = os.environ["MAPILLARY_USERNAME"]
        MAPILLARY_PERMISSION_HASH = os.environ["MAPILLARY_PERMISSION_HASH"]
        MAPILLARY_SIGNATURE_HASH = os.environ["MAPILLARY_SIGNATURE_HASH"]
    except KeyError:
        print(
            "You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_PERMISSION_HASH or MAPILLARY_SIGNATURE_HASH. These are required."
        )
        sys.exit()

    # generate a sequence UUID
    sequence_id = uuid.uuid4()
    You also need upload.py in the same folder or in your PYTHONPATH since this
    script uses pieces of that.
    '''
    if sys.version_info >= (3, 0):
        raise IOError("Incompatible Python version. This script requires Python 2.x, you are using {0}.".format(sys.version_info[:2]))

    parser = argparse.ArgumentParser(description='Upload images with authentication')
    parser.add_argument('path', help='path to your photos')
    parser.add_argument('--upload_subfolders', help='option to upload subfolders', action='store_true')
    args = parser.parse_args()

    path = sys.argv[1]
    skip_subfolders = not args.upload_subfolders

    # if no success/failed folders, create them
    create_dirs()

    # get env variables
    try:
        MAPILLARY_USERNAME = os.environ['MAPILLARY_USERNAME']
        MAPILLARY_PERMISSION_HASH = os.environ['MAPILLARY_PERMISSION_HASH']
        MAPILLARY_SIGNATURE_HASH = os.environ['MAPILLARY_SIGNATURE_HASH']
    except KeyError:
        print("You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_PERMISSION_HASH or MAPILLARY_SIGNATURE_HASH. These are required.")
        sys.exit()

    # generate a sequence UUID
    sequence_id = uuid.uuid4()

    # S3 bucket
    s3_bucket = MAPILLARY_USERNAME+"/"+str(sequence_id)+"/"
    parser.add_argument('--upload_subfolders', help='option to upload subfolders', action='store_true')
    parser.add_argument('--delete_after_upload', help='option to upload subfolders', action='store_true')
    parser.add_argument('--auto_done', help='option to send DONE file without user confirmation', action='store_true')

    args = parser.parse_args()

    path = args.path
    skip_subfolders = not args.upload_subfolders
    auto_done = args.auto_done
    if args.delete_after_upload is True:
        delete_after_upload = 1;
    else:
        delete_after_upload = 0;

    # if no success/failed folders, create them
    create_dirs('', delete_after_upload)

    # get env variables
    try:
        MAPILLARY_USERNAME = os.environ['MAPILLARY_USERNAME']
        MAPILLARY_PERMISSION_HASH = os.environ['MAPILLARY_PERMISSION_HASH']
        MAPILLARY_SIGNATURE_HASH = os.environ['MAPILLARY_SIGNATURE_HASH']
    except KeyError:
        print("You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_PERMISSION_HASH or MAPILLARY_SIGNATURE_HASH. These are required.")
        sys.exit()

    # generate a sequence UUID
    sequence_id = uuid.uuid4()

    # S3 bucket
    s3_bucket = MAPILLARY_USERNAME+"/"+str(sequence_id)+"/"
Exemple #4
0
        '--auto_done',
        help='option to send DONE file without user confirmation',
        action='store_true')

    args = parser.parse_args()

    path = args.path
    skip_subfolders = not args.upload_subfolders
    auto_done = args.auto_done
    if args.delete_after_upload is True:
        delete_after_upload = 1
    else:
        delete_after_upload = 0

    # if no success/failed folders, create them
    create_dirs('', delete_after_upload)

    # get env variables
    try:
        MAPILLARY_USERNAME = os.environ['MAPILLARY_USERNAME']
        MAPILLARY_PERMISSION_HASH = os.environ['MAPILLARY_PERMISSION_HASH']
        MAPILLARY_SIGNATURE_HASH = os.environ['MAPILLARY_SIGNATURE_HASH']
    except KeyError:
        print(
            "You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_PERMISSION_HASH or MAPILLARY_SIGNATURE_HASH. These are required."
        )
        sys.exit()

    # generate a sequence UUID
    sequence_id = uuid.uuid4()