01234567890123456789012345678901234567890123456789012345678901234567890123456789
334335336337338339340341342343344345346347348349350351352353 354355356357358359360361362363364365366367368369370 371372373374375376377378379380381382383384385386387388389390 394395396397398399400401402403404405406407408409410411412413 414415416417418419420421422423424425426427428429430431432433 448449450451452453454455456457458459460461462463464465466467 468469470 471472473474475476477478479480481482483484485486487488489490 63056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345 6348634963506351635263536354635563566357635863596360636163626363636463656366636763686369 637063716372 63736374 6375637663776378637963806381 63826383638463856386638763886389639063916392639363946395639663976398639964006401 | <----SKIPPED LINES----> # For displaying histograms # If a key is not present, how should it be displayed in histograms? KEY_NOT_PRESENT_STRING = 'Unknown' OTHER_STRING = 'Other' # What key strings should be listed last in sequence? # What key strings should be listed last in sequence? SORT_AT_END_STRINGS = [OTHER_STRING, KEY_NOT_PRESENT_STRING] # What is the sorted sequence of keys for days of week? DAYS_OF_WEEK = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # AIRCRAFT_LENGTH[''] = AIRCRAFT_LENGTH = {} # in meters AIRCRAFT_LENGTH['Airbus A220-100 (twin-jet)'] = 35 AIRCRAFT_LENGTH['Airbus A220-300 (twin-jet)'] = 38.71 AIRCRAFT_LENGTH['Airbus A300F4-600 (twin-jet)'] = 54.08 AIRCRAFT_LENGTH['Airbus A319 (twin-jet)'] = 33.84 AIRCRAFT_LENGTH['Airbus A320 (twin-jet)'] = 37.57 AIRCRAFT_LENGTH['Airbus A320neo (twin-jet)'] = 37.57 AIRCRAFT_LENGTH['Airbus A321 (twin-jet)'] = 44.51 AIRCRAFT_LENGTH['Airbus A321neo (twin-jet)'] = 44.51 AIRCRAFT_LENGTH['Airbus A330-200 (twin-jet)'] = 58.82 AIRCRAFT_LENGTH['Airbus A330-300 (twin-jet)'] = 63.67 AIRCRAFT_LENGTH['AIRBUS A-330-900 (twin-jet)'] = 63.66 AIRCRAFT_LENGTH['Airbus A340-300 (quad-jet)'] = 63.69 AIRCRAFT_LENGTH['Airbus A350-1000 (twin-jet)'] = 73.79 AIRCRAFT_LENGTH['Airbus A350-900 (twin-jet)'] = 66.8 AIRCRAFT_LENGTH['Airbus A380-800 (quad-jet)'] = 72.72 AIRCRAFT_LENGTH['Antonov An-124 Ruslan (quad-jet)'] = 69.1 AIRCRAFT_LENGTH['Beechcraft Beechjet (twin-jet)'] = 14.76 AIRCRAFT_LENGTH['Beechcraft Bonanza (33) (piston-single)'] = 7.65 AIRCRAFT_LENGTH['Beechcraft Bonanza (36) (piston-single)'] = 8.38 AIRCRAFT_LENGTH['Beechcraft King Air 90 (twin-turboprop)'] = 10.82 AIRCRAFT_LENGTH['Beechcraft King Air F90 (twin-turboprop)'] = 12.14 AIRCRAFT_LENGTH['Beechcraft Premier 1 (twin-jet)'] = 14.02 AIRCRAFT_LENGTH['Beechcraft Super King Air 200 (twin-turboprop)'] = 13.31 AIRCRAFT_LENGTH['Beechcraft Super King Air 350 (twin-turboprop)'] = 14.22 AIRCRAFT_LENGTH['Boeing 737-400 (twin-jet)'] = 36.4 AIRCRAFT_LENGTH['Boeing 737-700 (twin-jet)'] = 33.63 AIRCRAFT_LENGTH['Boeing 737-800 (twin-jet)'] = 39.47 AIRCRAFT_LENGTH['Boeing 737-900 (twin-jet)'] = 42.11 AIRCRAFT_LENGTH['Boeing 737 MAX 8 (twin-jet)'] = 39.47 AIRCRAFT_LENGTH['Boeing 737 MAX 9 (twin-jet)'] = 42.1 AIRCRAFT_LENGTH['Boeing 747-100 (quad-jet)'] = 70.66 AIRCRAFT_LENGTH['Boeing 747-400 (quad-jet)'] = 70.66 AIRCRAFT_LENGTH['Boeing 747-8 (quad-jet)'] = 76.25 AIRCRAFT_LENGTH['Boeing 757-200 (twin-jet)'] = 47.3 AIRCRAFT_LENGTH['Boeing 757-300 (twin-jet)'] = 54.4 AIRCRAFT_LENGTH['Boeing 767-200 (twin-jet)'] = 48.51 AIRCRAFT_LENGTH['BOEING 767-300 (twin-jet)'] = 54.94 AIRCRAFT_LENGTH['Boeing 767-300 (twin-jet)'] = 54.94 AIRCRAFT_LENGTH['BOEING 767-400 (twin-jet)'] = 61.37 AIRCRAFT_LENGTH['Boeing 777 (twin-jet)'] = (63.73 + 73.86) / 2 AIRCRAFT_LENGTH['Boeing 777-200 (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING 777-200ER (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING 777-200LR (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['Boeing 777-200LR/F (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['Boeing 777-300 (twin-jet)'] = 33.4 <----SKIPPED LINES----> AIRCRAFT_LENGTH['Boeing 787-8 (twin-jet)'] = 56.72 AIRCRAFT_LENGTH['Boeing 787-9 (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['Boeing 787-9 Dreamliner (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['BOEING 787-10 Dreamliner (twin-jet)'] = 68.28 AIRCRAFT_LENGTH['BOEING BBJ (747-8) (quad-jet)'] = 76.25 AIRCRAFT_LENGTH['BOEING BBJ (777-200LR) (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING BBJ (777-300ER) (twin-jet)'] = 73.86 AIRCRAFT_LENGTH['BOEING BBJ3 (twin-jet)'] = 42.11 AIRCRAFT_LENGTH['Boeing Dreamliner (Srs.8) (twin-jet)'] = 56.72 AIRCRAFT_LENGTH['BOEING Dreamliner (Srs.9) (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['Boeing MD-11 (tri-jet)'] = (61.2 + 61.6) / 2 AIRCRAFT_LENGTH['Bombardier Challenger 300 (twin-jet)'] = 20.92 AIRCRAFT_LENGTH['Bombardier Global 5000 (twin-jet)'] = 29.5 AIRCRAFT_LENGTH['Bombardier Global Express (twin-jet)'] = (29.5 + 30.3) / 2 AIRCRAFT_LENGTH['Bombardier Learjet 75 (twin-jet)'] = 17.7 AIRCRAFT_LENGTH['Canadair Challenger (twin-jet)'] = 20.9 AIRCRAFT_LENGTH['Canadair Challenger 350 (twin-jet)'] = 20.9 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-200 (twin-jet)'] = 26.77 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-700 (twin-jet)'] = 32.3 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-900 (twin-jet)'] = 36.2 AIRCRAFT_LENGTH['Cessna Caravan (single-turboprop)'] = 11.46 AIRCRAFT_LENGTH['Cessna Citation Bravo (twin-jet)'] = 14.54 AIRCRAFT_LENGTH['Cessna Citation CJ1 (twin-jet)'] = 12.98 AIRCRAFT_LENGTH['Cessna Citation CJ2+ (twin-jet)'] = 14.53 AIRCRAFT_LENGTH['Cessna Citation CJ3 (twin-jet)'] = 15.59 AIRCRAFT_LENGTH['Cessna Citation CJ4 (twin-jet)'] = 16.26 AIRCRAFT_LENGTH['Cessna Citation M2 (twin-jet)'] = 12.98 AIRCRAFT_LENGTH['Cessna Citation Excel/XLS (twin-jet)'] = 16.0 AIRCRAFT_LENGTH['Cessna Citation II (twin-jet)'] = 14.54 AIRCRAFT_LENGTH['Cessna Citation Latitude (twin-jet)'] = 18.97 AIRCRAFT_LENGTH['Cessna Citation Longitude (twin-jet)'] = 22.3 AIRCRAFT_LENGTH['Cessna Citation Mustang (twin-jet)'] = 12.37 AIRCRAFT_LENGTH['Cessna Citation Sovereign (twin-jet)'] = 19.35 AIRCRAFT_LENGTH['Cessna Citation V (twin-jet)'] = 14.91 AIRCRAFT_LENGTH['Cessna Citation X (twin-jet)'] = 22.04 AIRCRAFT_LENGTH['Cessna Conquest 2 (twin-turboprop)'] = 11.89 AIRCRAFT_LENGTH['Cessna Skyhawk (piston-single)'] = 8.28 AIRCRAFT_LENGTH['Cessna Skylane (piston-single)'] = 8.84 AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61 AIRCRAFT_LENGTH['Cirrus SR-20 (piston-single)'] = 7.92 <----SKIPPED LINES----> AIRCRAFT_LENGTH['Embraer Legacy 600/650 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9 AIRCRAFT_LENGTH['Eurocopter EC-635 (twin-turboshaft)'] = 10.21 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 25.32 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 27.23 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 29.39 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G650 (twin-jet)'] = 30.41 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 26.92 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream V (twin-jet)'] = 29.4 AIRCRAFT_LENGTH['Hawker Beechcraft 4000 (twin-jet)'] = 21.08 AIRCRAFT_LENGTH['Honda HondaJet (twin-jet)'] = 12.99 AIRCRAFT_LENGTH['IAI Gulfstream G100 (twin-jet)'] = 16.94 AIRCRAFT_LENGTH['IAI Gulfstream G150 (twin-jet)'] = 16.94 AIRCRAFT_LENGTH['IAI Gulfstream G200 (twin-jet)'] = 18.97 AIRCRAFT_LENGTH['IAI Gulfstream G280 (twin-jet)'] = 20.3 AIRCRAFT_LENGTH['Learjet 35 (twin-jet)'] = 14.83 AIRCRAFT_LENGTH['Learjet 40 (twin-jet)'] = 16.92 AIRCRAFT_LENGTH['Learjet 45 (twin-jet)'] = 17.68 AIRCRAFT_LENGTH['Learjet 60 (twin-jet)'] = 17.88 AIRCRAFT_LENGTH['McDonnell Douglas MD-11 (tri-jet)'] = 61.6 AIRCRAFT_LENGTH['North American Navion (piston-single)'] = 8.38 AIRCRAFT_LENGTH['Pilatus PC-12 (single-turboprop)'] = 14.4 AIRCRAFT_LENGTH['Pilatus PC-24 (twin-jet)'] = 16.85 AIRCRAFT_LENGTH['Raytheon Hawker 800 (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 800XP (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 850XP (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 1000 (twin-jet)'] = 16.08 AIRCRAFT_LENGTH['Rockwell Turbo Commander 690 (twin-turboprop)'] = 11.22 for mixed_case_plane in list(AIRCRAFT_LENGTH.keys()): # pylint: disable=C0201 AIRCRAFT_LENGTH[mixed_case_plane.upper()] = AIRCRAFT_LENGTH[mixed_case_plane] AIRCRAFT_LENGTH.pop(mixed_case_plane) # pylint: disable=line-too-long SHORTER_AIRCRAFT_NAME = {} SHORTER_AIRCRAFT_NAME['Boeing 787-9 Dreamliner (twin-jet)'] = 'Boeing 787-9 (twin-jet)' SHORTER_AIRCRAFT_NAME['BOEING 787-10 Dreamliner (twin-jet)'] = 'Boeing 787-10 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-200 (twin-jet)'] = 'Canadair CRJ-200 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-700 (twin-jet)'] = 'Canadair CRJ-700 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-900 (twin-jet)'] = 'Canadair CRJ-900 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 'Gulfstream 3 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 'Gulfstream G450 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 'Gulfstream G550 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 'Gulfstream IV (twin-jet)' <----SKIPPED LINES----> extra_characters = max(0, len(message_array) - expected_characters) if extra_characters: Log('Message "%s" is too long at %d characters (max %d characters)' % (s, len(message_array), expected_characters)) message_array = message_array[:expected_characters] message_2d_array = [] for line_num in range(SPLITFLAP_LINE_COUNT): message_2d_array.append(message_array[ line_num * SPLITFLAP_CHARS_PER_LINE : (line_num + 1)*SPLITFLAP_CHARS_PER_LINE]) return message_2d_array def PublishMessage( s, subscription_id='12fd73cd-75ef-4cae-bbbf-29b2678692c1', key='c5f62d44-e30d-4c43-a43e-d4f65f4eb399', secret='b00aeb24-72f3-467c-aad2-82ba5e5266ca', timeout=3): """Publishes a text string to a Vestaboard. The message is pushed to the vestaboard splitflap display by way of its web services; see https://docs.vestaboard.com/introduction for more details. Args: s: String to publish. subscription_id: string subscription id from Vestaboard. key: string key from Vestaboard. secret: string secret from Vestaboard. timeout: Max duration in seconds that we should wait to establish a connection. """ error_code = False curl = pycurl.Curl() # See https://stackoverflow.com/questions/31826814/ # curl-post-request-into-pycurl-code # Set URL value curl.setopt( <----SKIPPED LINES----> % subscription_id) curl.setopt(pycurl.HTTPHEADER, [ 'X-Vestaboard-Api-Key:%s' % key, 'X-Vestaboard-Api-Secret:%s' % secret]) curl.setopt(pycurl.TIMEOUT_MS, timeout*1000) curl.setopt(pycurl.POST, 1) curl.setopt(pycurl.WRITEFUNCTION, lambda x: None) # to keep stdout clean # preparing body the way pycurl.READDATA wants it body_as_dict = {'characters': StringToCharArray(s)} body_as_json_string = json.dumps(body_as_dict) # dict to json body_as_file_object = io.StringIO(body_as_json_string) # prepare and send. See also: pycurl.READFUNCTION to pass function instead curl.setopt(pycurl.READDATA, body_as_file_object) curl.setopt(pycurl.POSTFIELDSIZE, len(body_as_json_string)) failure_message = '' try: curl.perform() except pycurl.error as e: failure_message = 'curl.perform() failed with message %s' % e Log('curl.perform() failed with message %s' % e) error_code = True else: # you may want to check HTTP response code, e.g. status_code = curl.getinfo(pycurl.RESPONSE_CODE) if status_code != 200: Log('Server returned HTTP status code %d for message %s' % ( status_code, s)) error_code = True curl.close() UpdateStatusLight( GPIO_ERROR_VESTABOARD_CONNECTION, error_code, failure_message) def TruncateEscapedLine(s): """Formats a single line of the personal message for the Vestaboard. The Vestaboard has line length limitations, a limited character set, and escape characters. This function: - replaces some unsupported characters with very similar supported characters - truncates the line after the max line length, allowing for escape characters - truncates the line after an unsupported character that does not have a replacement Args: s: input string Returns: Reformatted potentially-truncated line. """ s = s.upper() character_mapping = { <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 63116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351 6354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426 | <----SKIPPED LINES----> # For displaying histograms # If a key is not present, how should it be displayed in histograms? KEY_NOT_PRESENT_STRING = 'Unknown' OTHER_STRING = 'Other' # What key strings should be listed last in sequence? # What key strings should be listed last in sequence? SORT_AT_END_STRINGS = [OTHER_STRING, KEY_NOT_PRESENT_STRING] # What is the sorted sequence of keys for days of week? DAYS_OF_WEEK = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # AIRCRAFT_LENGTH[''] = AIRCRAFT_LENGTH = {} # in meters AIRCRAFT_LENGTH['Airbus A220-100 (twin-jet)'] = 35 AIRCRAFT_LENGTH['Airbus A220-300 (twin-jet)'] = 38.71 AIRCRAFT_LENGTH['Airbus A300F4-600 (twin-jet)'] = 54.08 AIRCRAFT_LENGTH['Airbus A319 (twin-jet)'] = 33.84 AIRCRAFT_LENGTH['Airbus A320 (twin-jet)'] = 37.57 AIRCRAFT_LENGTH['Airbus A320neo (twin-jet)'] = 37.57 AIRCRAFT_LENGTH['Airbus A321 (twin-jet)'] = 44.51 AIRCRAFT_LENGTH['Airbus A321neo (twin-jet)'] = 44.51 AIRCRAFT_LENGTH['Airbus A330 (twin-jet)'] = 58.82 # assumed -200 or -300 AIRCRAFT_LENGTH['Airbus A330-200 (twin-jet)'] = 58.82 AIRCRAFT_LENGTH['Airbus A330-300 (twin-jet)'] = 63.67 AIRCRAFT_LENGTH['AIRBUS A-330-900 (twin-jet)'] = 63.66 AIRCRAFT_LENGTH['Airbus A340-300 (quad-jet)'] = 63.69 AIRCRAFT_LENGTH['Airbus A350-1000 (twin-jet)'] = 73.79 AIRCRAFT_LENGTH['Airbus A350-900 (twin-jet)'] = 66.8 AIRCRAFT_LENGTH['Airbus A380-800 (quad-jet)'] = 72.72 AIRCRAFT_LENGTH['Antonov An-124 Ruslan (quad-jet)'] = 69.1 AIRCRAFT_LENGTH['Beechcraft Beechjet (twin-jet)'] = 14.76 AIRCRAFT_LENGTH['Beechcraft Bonanza (33) (piston-single)'] = 7.65 AIRCRAFT_LENGTH['Beechcraft Bonanza (36) (piston-single)'] = 8.38 AIRCRAFT_LENGTH['Beechcraft King Air 90 (twin-turboprop)'] = 10.82 AIRCRAFT_LENGTH['Beechcraft King Air F90 (twin-turboprop)'] = 12.14 AIRCRAFT_LENGTH['Beechcraft Premier 1 (twin-jet)'] = 14.02 AIRCRAFT_LENGTH['Beechcraft Super King Air 200 (twin-turboprop)'] = 13.31 AIRCRAFT_LENGTH['Beechcraft Super King Air 350 (twin-turboprop)'] = 14.22 AIRCRAFT_LENGTH['Boeing 737-400 (twin-jet)'] = 36.4 AIRCRAFT_LENGTH['Boeing 737-500 (twin-jet)'] = 31.0 AIRCRAFT_LENGTH['Boeing 737-700 (twin-jet)'] = 33.63 AIRCRAFT_LENGTH['Boeing 737-800 (twin-jet)'] = 39.47 AIRCRAFT_LENGTH['Boeing 737-900 (twin-jet)'] = 42.11 AIRCRAFT_LENGTH['Boeing 737 MAX 8 (twin-jet)'] = 39.47 AIRCRAFT_LENGTH['Boeing 737 MAX 9 (twin-jet)'] = 42.1 AIRCRAFT_LENGTH['Boeing 747-100 (quad-jet)'] = 70.66 AIRCRAFT_LENGTH['Boeing 747-400 (quad-jet)'] = 70.66 AIRCRAFT_LENGTH['Boeing 747-8 (quad-jet)'] = 76.25 AIRCRAFT_LENGTH['Boeing 757-200 (twin-jet)'] = 47.3 AIRCRAFT_LENGTH['Boeing 757-300 (twin-jet)'] = 54.4 AIRCRAFT_LENGTH['Boeing 767-200 (twin-jet)'] = 48.51 AIRCRAFT_LENGTH['BOEING 767-300 (twin-jet)'] = 54.94 AIRCRAFT_LENGTH['Boeing 767-300 (twin-jet)'] = 54.94 AIRCRAFT_LENGTH['BOEING 767-400 (twin-jet)'] = 61.37 AIRCRAFT_LENGTH['Boeing 777 (twin-jet)'] = (63.73 + 73.86) / 2 AIRCRAFT_LENGTH['Boeing 777-200 (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING 777-200ER (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING 777-200LR (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['Boeing 777-200LR/F (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['Boeing 777-300 (twin-jet)'] = 33.4 <----SKIPPED LINES----> AIRCRAFT_LENGTH['Boeing 787-8 (twin-jet)'] = 56.72 AIRCRAFT_LENGTH['Boeing 787-9 (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['Boeing 787-9 Dreamliner (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['BOEING 787-10 Dreamliner (twin-jet)'] = 68.28 AIRCRAFT_LENGTH['BOEING BBJ (747-8) (quad-jet)'] = 76.25 AIRCRAFT_LENGTH['BOEING BBJ (777-200LR) (twin-jet)'] = 63.73 AIRCRAFT_LENGTH['BOEING BBJ (777-300ER) (twin-jet)'] = 73.86 AIRCRAFT_LENGTH['BOEING BBJ3 (twin-jet)'] = 42.11 AIRCRAFT_LENGTH['Boeing Dreamliner (Srs.8) (twin-jet)'] = 56.72 AIRCRAFT_LENGTH['BOEING Dreamliner (Srs.9) (twin-jet)'] = 62.81 AIRCRAFT_LENGTH['Boeing MD-11 (tri-jet)'] = (61.2 + 61.6) / 2 AIRCRAFT_LENGTH['Bombardier Challenger 300 (twin-jet)'] = 20.92 AIRCRAFT_LENGTH['Bombardier Global 5000 (twin-jet)'] = 29.5 AIRCRAFT_LENGTH['Bombardier Global Express (twin-jet)'] = (29.5 + 30.3) / 2 AIRCRAFT_LENGTH['Bombardier Learjet 75 (twin-jet)'] = 17.7 AIRCRAFT_LENGTH['Canadair Challenger (twin-jet)'] = 20.9 AIRCRAFT_LENGTH['Canadair Challenger 350 (twin-jet)'] = 20.9 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-200 (twin-jet)'] = 26.77 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-700 (twin-jet)'] = 32.3 AIRCRAFT_LENGTH['Canadair Regional Jet CRJ-900 (twin-jet)'] = 36.2 AIRCRAFT_LENGTH['Cessna 152 (piston-single)'] = 7.34 AIRCRAFT_LENGTH['Cessna Caravan (single-turboprop)'] = 11.46 AIRCRAFT_LENGTH['Cessna Citation Bravo (twin-jet)'] = 14.54 AIRCRAFT_LENGTH['Cessna Citation CJ1 (twin-jet)'] = 12.98 AIRCRAFT_LENGTH['Cessna Citation CJ2+ (twin-jet)'] = 14.53 AIRCRAFT_LENGTH['Cessna Citation CJ3 (twin-jet)'] = 15.59 AIRCRAFT_LENGTH['Cessna Citation CJ4 (twin-jet)'] = 16.26 AIRCRAFT_LENGTH['Cessna Citation M2 (twin-jet)'] = 12.98 AIRCRAFT_LENGTH['Cessna Citation Excel/XLS (twin-jet)'] = 16.0 AIRCRAFT_LENGTH['Cessna Citation II (twin-jet)'] = 14.54 AIRCRAFT_LENGTH['Cessna Citation Latitude (twin-jet)'] = 18.97 AIRCRAFT_LENGTH['Cessna Citation Longitude (twin-jet)'] = 22.3 AIRCRAFT_LENGTH['Cessna Citation Mustang (twin-jet)'] = 12.37 AIRCRAFT_LENGTH['Cessna Citation Sovereign (twin-jet)'] = 19.35 AIRCRAFT_LENGTH['Cessna Citation V (twin-jet)'] = 14.91 AIRCRAFT_LENGTH['Cessna Citation X (twin-jet)'] = 22.04 AIRCRAFT_LENGTH['Cessna Conquest 2 (twin-turboprop)'] = 11.89 AIRCRAFT_LENGTH['Cessna Skyhawk (piston-single)'] = 8.28 AIRCRAFT_LENGTH['Cessna Skylane (piston-single)'] = 8.84 AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61 AIRCRAFT_LENGTH['Cirrus SR-20 (piston-single)'] = 7.92 <----SKIPPED LINES----> AIRCRAFT_LENGTH['Embraer Legacy 600/650 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9 AIRCRAFT_LENGTH['Eurocopter EC-635 (twin-turboshaft)'] = 10.21 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 25.32 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 27.23 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 29.39 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G650 (twin-jet)'] = 30.41 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 26.92 AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream V (twin-jet)'] = 29.4 AIRCRAFT_LENGTH['Hawker Beechcraft 4000 (twin-jet)'] = 21.08 AIRCRAFT_LENGTH['Honda HondaJet (twin-jet)'] = 12.99 AIRCRAFT_LENGTH['IAI Gulfstream G100 (twin-jet)'] = 16.94 AIRCRAFT_LENGTH['IAI Gulfstream G150 (twin-jet)'] = 16.94 AIRCRAFT_LENGTH['IAI Gulfstream G200 (twin-jet)'] = 18.97 AIRCRAFT_LENGTH['IAI Gulfstream G280 (twin-jet)'] = 20.3 AIRCRAFT_LENGTH['Learjet 35 (twin-jet)'] = 14.83 AIRCRAFT_LENGTH['Learjet 40 (twin-jet)'] = 16.92 AIRCRAFT_LENGTH['Learjet 45 (twin-jet)'] = 17.68 AIRCRAFT_LENGTH['Learjet 60 (twin-jet)'] = 17.88 AIRCRAFT_LENGTH['McDonnell Douglas MD-11 (tri-jet)'] = 61.6 AIRCRAFT_LENGTH['McDonnell Douglas MD-83 (twin-jet)'] = 45.06 AIRCRAFT_LENGTH['Mooney M-20 (piston-single)'] = 8.13 AIRCRAFT_LENGTH['North American Navion (piston-single)'] = 8.38 AIRCRAFT_LENGTH['Pilatus PC-12 (single-turboprop)'] = 14.4 AIRCRAFT_LENGTH['Pilatus PC-24 (twin-jet)'] = 16.85 AIRCRAFT_LENGTH['Piper Cherokee (piston-single)'] = 7.10 AIRCRAFT_LENGTH['Raytheon Hawker 800 (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 800XP (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 850XP (twin-jet)'] = 15.60 AIRCRAFT_LENGTH['Raytheon Hawker 1000 (twin-jet)'] = 16.08 AIRCRAFT_LENGTH['Rockwell Turbo Commander 690 (twin-turboprop)'] = 11.22 for mixed_case_plane in list(AIRCRAFT_LENGTH.keys()): # pylint: disable=C0201 AIRCRAFT_LENGTH[mixed_case_plane.upper()] = AIRCRAFT_LENGTH[mixed_case_plane] AIRCRAFT_LENGTH.pop(mixed_case_plane) # pylint: disable=line-too-long SHORTER_AIRCRAFT_NAME = {} SHORTER_AIRCRAFT_NAME['Boeing 787-9 Dreamliner (twin-jet)'] = 'Boeing 787-9 (twin-jet)' SHORTER_AIRCRAFT_NAME['BOEING 787-10 Dreamliner (twin-jet)'] = 'Boeing 787-10 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-200 (twin-jet)'] = 'Canadair CRJ-200 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-700 (twin-jet)'] = 'Canadair CRJ-700 (twin-jet)' SHORTER_AIRCRAFT_NAME['Canadair Regional Jet CRJ-900 (twin-jet)'] = 'Canadair CRJ-900 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 'Gulfstream 3 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 'Gulfstream G450 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 'Gulfstream G550 (twin-jet)' SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 'Gulfstream IV (twin-jet)' <----SKIPPED LINES----> extra_characters = max(0, len(message_array) - expected_characters) if extra_characters: Log('Message "%s" is too long at %d characters (max %d characters)' % (s, len(message_array), expected_characters)) message_array = message_array[:expected_characters] message_2d_array = [] for line_num in range(SPLITFLAP_LINE_COUNT): message_2d_array.append(message_array[ line_num * SPLITFLAP_CHARS_PER_LINE : (line_num + 1)*SPLITFLAP_CHARS_PER_LINE]) return message_2d_array def PublishMessage( s, subscription_id='12fd73cd-75ef-4cae-bbbf-29b2678692c1', key='c5f62d44-e30d-4c43-a43e-d4f65f4eb399', secret='b00aeb24-72f3-467c-aad2-82ba5e5266ca', timeout=5): """Publishes a text string to a Vestaboard. The message is pushed to the vestaboard splitflap display by way of its web services; see https://docs.vestaboard.com/introduction for more details. Args: s: String to publish. subscription_id: string subscription id from Vestaboard. key: string key from Vestaboard. secret: string secret from Vestaboard. timeout: Max duration in seconds that we should wait to establish a connection. """ error_code = False curl = pycurl.Curl() # See https://stackoverflow.com/questions/31826814/ # curl-post-request-into-pycurl-code # Set URL value curl.setopt( <----SKIPPED LINES----> % subscription_id) curl.setopt(pycurl.HTTPHEADER, [ 'X-Vestaboard-Api-Key:%s' % key, 'X-Vestaboard-Api-Secret:%s' % secret]) curl.setopt(pycurl.TIMEOUT_MS, timeout*1000) curl.setopt(pycurl.POST, 1) curl.setopt(pycurl.WRITEFUNCTION, lambda x: None) # to keep stdout clean # preparing body the way pycurl.READDATA wants it body_as_dict = {'characters': StringToCharArray(s)} body_as_json_string = json.dumps(body_as_dict) # dict to json body_as_file_object = io.StringIO(body_as_json_string) # prepare and send. See also: pycurl.READFUNCTION to pass function instead curl.setopt(pycurl.READDATA, body_as_file_object) curl.setopt(pycurl.POSTFIELDSIZE, len(body_as_json_string)) failure_message = '' try: curl.perform() except pycurl.error as e: timing_message = CurlTimingDetailsToString(curl) failure_message = ( 'curl.perform() failed with message %s; timing details: %s' % (e, timing_message)) Log(failure_message) error_code = True else: # you may want to check HTTP response code, e.g. timing_message = CurlTimingDetailsToString(curl) status_code = curl.getinfo(pycurl.RESPONSE_CODE) if status_code != 200: Log( 'Server returned HTTP status code %d for message %s; ' 'timing details: %s' % (status_code, s, timing_message)) error_code = True curl.close() UpdateStatusLight( GPIO_ERROR_VESTABOARD_CONNECTION, error_code, failure_message) def CurlTimingDetailsToString(curl): """Extracts timing details of a curl request into a readable string.""" timing = {} timing['total-time'] = curl.getinfo(pycurl.TOTAL_TIME) timing['namelookup-time'] = curl.getinfo(pycurl.NAMELOOKUP_TIME) timing['connect-time'] = curl.getinfo(pycurl.CONNECT_TIME) timing['pretransfer-time'] = curl.getinfo(pycurl.PRETRANSFER_TIME) timing['redirect-time'] = curl.getinfo(pycurl.REDIRECT_TIME) timing['starttransfer-time'] = curl.getinfo(pycurl.STARTTRANSFER_TIME) results = [label + '=' + '%.4f' % timing[label] for label in timing] results = '; '.join(results) return results def TruncateEscapedLine(s): """Formats a single line of the personal message for the Vestaboard. The Vestaboard has line length limitations, a limited character set, and escape characters. This function: - replaces some unsupported characters with very similar supported characters - truncates the line after the max line length, allowing for escape characters - truncates the line after an unsupported character that does not have a replacement Args: s: input string Returns: Reformatted potentially-truncated line. """ s = s.upper() character_mapping = { <----SKIPPED LINES----> |