Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
1.1 kB
1
Indexable
Never
def lambda_handler(event, context):
    
    grapql_token=get_secret()
    configuration=run_query(query,json.loads(grapql_token),event)
    BUCKET = "githubdata"
    s3 = boto3.resource('s3')
    if(configuration["date"]==""):
        current_time = datetime.datetime.now()
        current_time=current_time.strftime("%d-%m-%Y %H:%M:%S")
        
        s3.Bucket(BUCKET).upload_file("/tmp/{organization}.json".format(organization=configuration["name_organization"]), 
        "repositories/{organization}/{time}/file_{count_order}.json".format(organization=configuration["name_organization"]
        ,time=current_time,count_order=configuration["count"]))
        configuration["date"]=current_time
    else:
        s3.Bucket(BUCKET).upload_file("/tmp/{organization}.json".format(organization=configuration["name_organization"]), 
        "repositories/{organization}/{time}/file_{count_order}.json".format(organization=configuration["name_organization"]
        ,time=configuration["date"],count_order=configuration["count"]))
    return configuration