Пример #1
0
def main():
    parser = argparse.ArgumentParser(description='Transfer files from S3 to Ovation')
    parser.add_argument('-u', '--user', help='Ovation user email')
    parser.add_argument('-p', '--password', help='Ovation password')
    parser.add_argument('-t', '--token', help='Ovation user token')
    parser.add_argument('parent', help='Project or Folder UUID that will receive transferred files')
    parser.add_argument('source_bucket', help='Source S3 Bucket')
    parser.add_argument('aws_access_key_id', help='AWS Access Key Id')
    parser.add_argument('aws_secret_access_key', help='AWS Secret Key')

    args = parser.parse_args()

    token = args.token
    if token is None:
        user = args.user
        if user is None:
            user = input('Email: ')

        session = connect(user, password=args.password)

    else:
        session = Session(token)

    aws_secret_access_key = args.aws_secret_access_key

    logging.basicConfig(level=logging.INFO, filename='ovation_transfer.log')

    copy_bucket_contents(session,
                         project=args.parent,
                         aws_access_key_id=args.aws_access_key_id,
                         aws_secret_access_key=aws_secret_access_key,
                         source_s3_bucket=args.source_bucket,
                         destination_s3_bucket='users.ovation.io',
                         checkpoint='.transfer_checkpoint.csv', copy_file_fn=copy_file)
def process_open_activities(user_name):
    s = session.connect(user_name)
    open_activities = _filter_open_activities(s, _find_activities(s))
    for activity in open_activities:
        print("Processing {}".format(activity.attributes.name))
        _process_activity(s, activity)
        print("Finished processing {}".format(activity.attributes.name))