def main()

in utils/wheel_feeder.py [0:0]


def main():
    print("Initializing the Wheel Feeder...")
    parser = argparse.ArgumentParser(
        description=DESCRIPTION,
        formatter_class=argparse.RawTextHelpFormatter
    )

    parser.add_argument(
        '-u', '--wheel-url',
        help='Full URL of the Wheel\'s API Gateway endpoint and stage. \n'
        'Example: https://<API_ID>.execute-api.us-west-2.amazonaws.com/app'
    )
    parser.add_argument(
        '-w', '--wheel-id',
        help='UUID of the Wheel which you want to feed. Alternatively you can use --wheel-name and --stack-name\n'
        'Example: 57709419-17c9-4b77-ac99-77fb0d7c7c51'
    )
    parser.add_argument(
        '-c', '--csv-file-path', required=True,
        help='Path to the CSV file. \n'
        'Example: /home/foo/participants.csv'
    )
    parser.add_argument(
        '-p', '--cognito-user-pool-id',
        help='Cognito User Pool Id. \n'
        'Example: us-west-2_K4oiNOTREAL'
    )
    parser.add_argument(
        '-i', '--cognito-client-id',
        help='Cognito Client Id (get it by visiting your Cognito User Pool). \n'
        'Example: 6e6p1k4qaNOTREAL'
    )
    parser.add_argument(
        '-sn', '--stack-name',
        help='Cloudformation stack name used during initial Wheel creation'
    )
    parser.add_argument(
        '-wn', '--wheel-name',
        help='Wheel name.  An alternative to wheel-id but requires you also specify the stack_name parameter'
    )
    parser.add_argument(
        '-r', '--region',
        help='Region the stack is deployed in.  E.G: us-east-1.  '
             'Defaults to the default region in your boto/awscli configuration'
    )
    args = parser.parse_args()
    if args.stack_name:
        cf_client = boto3.client('cloudformation', region_name=args.region)
        stack = cf_client.describe_stacks(StackName=args.stack_name)['Stacks'][0]
        stack_outputs = {output['OutputKey']: output['OutputValue'] for output in stack['Outputs']}
        args.cognito_client_id = args.cognito_client_id or stack_outputs['CognitoUserPoolClient']
        args.cognito_user_pool_id = args.cognito_user_pool_id or stack_outputs['CognitoUserPool']
        args.wheel_url = args.wheel_url or stack_outputs['Endpoint']

        if args.wheel_name:
            ddb_client = boto3.resource('dynamodb', region_name=args.region)
            for item in ddb_client.Table(stack_outputs['wheelDynamoDBTable']).scan()['Items']:
                if item['name'] == args.wheel_name:
                    args.wheel_id = item['id']
                    break
            else:
                raise SystemExit("ERROR: Could not find a wheel with the name '%s'" % args.wheel_name)

    if not (args.wheel_url and args.wheel_id and args.cognito_user_pool_id and args.cognito_client_id):
        raise SystemExit("Error:  You must specify either --stack-name and --wheel-name parameters or "
                         "--wheel-url, --wheel-id, --cognito-user-pool-id, and --cognito-client-id parameters")

    # Initialize the Feeder and execute it.
    wheel_feeder = WheelFeeder(
        args.wheel_url,
        args.wheel_id,
        args.csv_file_path,
        args.cognito_user_pool_id,
        args.cognito_client_id,
        region_name=args.region
    )
    wheel_feeder.execute()