in cloudformation-templates/cdk.out/asset.34e613cbed9fe6d92140a799a0714c454ff967fe816d79cb9e5cef24fdb8ad22/flight.py [0:0]
def scanflights(dest, dynamodb=None):
if not dynamodb:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Flights')
response = table.query(
KeyConditionExpression=Key('arr_iata').eq(dest)
)
for scan in response['Items']:
format = '%Y-%m-%d %H:%M'
datetimer = datetime.datetime.strptime(scan['dep_time'], format)
currenttime = int(time.time())-10800
difftime = datetimer.timestamp() - currenttime
takeoffin = int(difftime / 60)
if 0 < difftime < 36000:
nextflight = "THE NEXT FLIGHT TO %s leaves in %s minutes. Flight number is %s at %s and leaves from terminal %s gate %s" %(scan['arr_iata'], takeoffin, scan['flight_number'], scan['dep_time'], scan['dep_terminal'], scan['dep_gate'])
return nextflight