-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.py
37 lines (26 loc) · 1.16 KB
/
handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import pandas as pd
from helper import get_existing_file, get_traffic, sent_notification
pd.options.display.max_colwidth = 230
def mrt_traffic_file_list(event, context):
event['mrt-traffic-file-dt'] = get_existing_file()
return event
def mrt_traffic(event, context):
try:
result_list = get_traffic(data_dt=event['mrt-traffic-file-dt'])
event['number_of_downloaded_files'] = len(result_list)
event['date_of_downloaded_files'] = ','.join(result_list)
event['company_type'] = 'traffic'
event['company'] = os.environ['company']
event['remaining_time_sec'] = context.get_remaining_time_in_millis()/1000
return event
except Exception as e:
print(e)
event['number_of_downloaded_files'] = 'function_error'
event['date_of_downloaded_files'] = 'function_error'
event['company_type'] = 'traffic'
event['company'] = os.environ['company']
event['remaining_time_sec'] = context.get_remaining_time_in_millis()/1000
return event
def email_notification(event, context):
return sent_notification(input_event=event)