-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZoneHelper.py
61 lines (56 loc) · 2.16 KB
/
ZoneHelper.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Kyle R Fogerty
#Zone Helper: Helper Functions such as print, tweet
from Tweeter import sendTweet
def fixZoneName(zone_name):
if zone_name == "europe":
return "Europe"
elif zone_name == "northamerica":
return "North America"
elif zone_name == "southamerica":
return "South America"
elif zone_name == "oceania":
return "Oceania"
elif zone_name == "asia":
return "Asia"
elif zone_name == "africa":
return "Africa"
elif zone_name == "atlantic":
return "Atlantic"
elif zone_name == "maldives":
return "Maldives"
elif zone_name == "northatlantic":
return "North Atlantic"
else:
return zone_name
def printFlightLogs(zone_name, logs):
if len(logs) > 0:
print(fixZoneName(zone_name) + ":")
print("")
for flight in logs:
print(flight.full_name if flight.full_name != None else "Currently Unavailable")
print(flight.aircraft_name if flight.aircraft_name != None else "Currently Unavailable")
print(flight.flight.registration)
print("")
print("")
print("")
def tweetFlightLogs(zone_name, logs):
if len(logs) > 0:
for flight in logs:
with open('temp_tweet.txt', 'w') as f:
f.write(fixZoneName(zone_name) + ":" + "\n" + "\n")
f.write(flight.flight.callsign if flight.flight.callsign != None else "Currently Unavailable")
f.write("\n")
f.write(flight.full_name if flight.full_name != None else "Currently Unavailable")
f.write("\n")
f.write(flight.aircraft_name if flight.aircraft_name != None else "Currently Unavailable")
f.write("\n")
f.write("Coord: " + str(flight.logs[-1].getCoordinates()))
f.write(" | Altitude: " + str(flight.logs[-1].getAltitude()))
f.write(" | Heading: " + str(flight.logs[-1].getHeading()))
f.write("\n")
f.write("Registration: " + flight.flight.registration)
f.close()
sendTweet()
return True
else:
return False