01234567890123456789012345678901234567890123456789012345678901234567890123456789
437438439440441442443444445446447448449450451452453454455456 457458459460461462463464465466467468469470471472473474475476477478479480481482 483484485486 487488489490491492493494495496497498499500501502503504505506 583584585586587588589590591592593594595596597598599600601602603 604605606607608609610 611 612613614615616617618619620621622623624625626627628629630631 21292130213121322133213421352136213721382139214021412142214321442145214621472148 21492150215121522153215421552156215721582159216021612162216321642165216621672168 64906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530 | <----SKIPPED LINES----> 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 BD-700 Global 7500 (twin-jet)'] = 33.88 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 T182 Turbo Skylane (piston-single)'] = 8.84 AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61 AIRCRAFT_LENGTH['Cessna 421 (twin-piston)'] = 11.09 AIRCRAFT_LENGTH['Cirrus SR-20 (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus SR-22 (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus SR22 Turbo (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus Vision SF50 (single-jet)'] = 9.42 AIRCRAFT_LENGTH['Daher-Socata TBM-900 (single-turboprop)'] = 10.72 AIRCRAFT_LENGTH['Dassault Falcon 50 (tri-jet)'] = 18.52 AIRCRAFT_LENGTH['Dassault Falcon 2000 (twin-jet)'] = 20.23 AIRCRAFT_LENGTH['Dassault Falcon 900 (tri-jet)'] = 20.21 AIRCRAFT_LENGTH['Embraer 170/175 (twin-jet)'] = (29.90 + 31.68) / 2 AIRCRAFT_LENGTH['EMBRAER 175 (long wing) (twin-jet)'] = 31.68 AIRCRAFT_LENGTH['Embraer ERJ-135 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer ERJ-145 (twin-jet)'] = 29.87 AIRCRAFT_LENGTH['Embraer ERJ 175 (twin-jet)'] = 31.68 AIRCRAFT_LENGTH['Embraer ERJ 190 (twin-jet)'] = 36.25 AIRCRAFT_LENGTH['Embraer ERJ-190 (twin-jet)'] = 36.25 AIRCRAFT_LENGTH['Embraer Legacy 450 (twin-jet)'] = 19.69 AIRCRAFT_LENGTH['Embraer Legacy 550 (twin-jet)'] = 20.74 AIRCRAFT_LENGTH['Embraer Legacy 600/650 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer Phenom 100 (twin-jet)'] = 12.82 AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9 AIRCRAFT_LENGTH['Epic Aircraft LT (single-turboprop)'] = 10.92 AIRCRAFT_LENGTH['Eurocopter EC-635 (twin-turboshaft)'] = 10.21 AIRCRAFT_LENGTH['Fairchild Dornier 328JET (twin-jet)'] = 21.11 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['GULFSTREAM AEROSPACE G-7 Gulfstream G600 (twin-jet)'] = 29.29 <----SKIPPED LINES----> except IOError: Log('Unable to append to ' + file) if rolling: Tail(file, rolling, lines_to_keep=ROLLING_LOG_SIZE) def Tail(in_name, rolling_name, max_line_length=100, lines_to_keep=1000): """Fast pythonic implementation of tail -n. Args: in_name: name of file for which we want the tail rolling_name: name of file to write out max_line_length: since this uses seek to find the block of text near the end that has at most the lines_to_keep number of lines, we need to estimate the max line length over that block of text. We can afford to be a little conservative here. lines_to_keep: how many lines to keep in the rolling file. Returns: Integer number of lines actually kept. """ with open(in_name, 'r') as f: f.seek(0, os.SEEK_END) f_length = f.tell() bytes_to_read = min(max_line_length * lines_to_keep, f_length) f.seek(f_length - bytes_to_read) end_text = f.read() lines = end_text.split('\n') # perhaps the file was smaller than lines_to_keep lines, or many lines were # longer than max_line_length; in that case, the resulting text block will # potentially be smaller than lines_to_keep lines_to_keep = min(lines_to_keep, len(lines)) with open(rolling_name, 'w') as f: f.write('\n'.join(lines[-lines_to_keep:])) return lines_to_keep def UpdateRollingLogSize(configuration): """Set the global rolling_log_line_count based on settings file.""" if 'rolling_log_line_count' in configuration: global ROLLING_LOG_SIZE ROLLING_LOG_SIZE = configuration['rolling_log_line_count'] def LogTimes(times, threshold=0, title=''): <----SKIPPED LINES----> parsed_flight_details = parsed_json['flights'][fa_flight_number] flight['fa_flight_number'] = fa_flight_number origin = parsed_flight_details.get('origin') if origin: flight['origin_friendly'] = origin.get('friendlyLocation') flight['origin_iata'] = origin.get('iata') destination = parsed_flight_details.get('destination') if destination: flight['destination_friendly'] = destination.get('friendlyLocation') flight['destination_iata'] = destination.get('iata') aircraft_type = parsed_flight_details.get('aircraft') if aircraft_type: flight['aircraft_type_code'] = aircraft_type.get('type') flight['aircraft_type_friendly'] = aircraft_type.get('friendlyType') if flight['aircraft_type_friendly']: flight['aircraft_type_friendly'] = flight[ 'aircraft_type_friendly'].replace('biréacteur', 'twin-jet') flight['owner_location'] = Unidecode(aircraft_type.get('ownerLocation')) flight['owner'] = Unidecode(aircraft_type.get('owner')) flight['tail'] = Unidecode(aircraft_type.get('tail')) takeoff_time = parsed_flight_details.get('takeoffTimes') if takeoff_time: flight['scheduled_takeofftime'] = takeoff_time.get('scheduled') flight['actual_takeoff_time'] = takeoff_time.get('actual') gate_departure_time = parsed_flight_details.get('gateDepartureTimes') if gate_departure_time: flight['scheduled_departure_time'] = gate_departure_time.get('scheduled') flight['actual_departure_time'] = gate_departure_time.get('actual') gate_arrival_time = parsed_flight_details.get('gateArrivalTimes') if gate_arrival_time: flight['scheduled_arrival_time'] = gate_arrival_time.get('scheduled') flight['estimated_arrival_time'] = gate_arrival_time.get('estimated') landing_time = parsed_flight_details.get('landingTimes') <----SKIPPED LINES----> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] where each 0 is replaced by an integer 0,...,69. ''' # For each element in the string, # if it is an '{', find the closing '}' and collapse into one element # if it is not an '{' and we are not in an escaped string, translate translation = { ' ': 0, 'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20, 'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25, 'Z': 26, '1': 27, '2': 28, '3': 29, '4': 30, '5': 31, '6': 32, '7': 33, '8': 34, '9': 35, '0': 36, '!': 37, '@': 38, '#': 39, '$': 40, '(': 41, ')': 42, '-': 44, '+': 46, '&': 47, '=': 48, ';': 49, ':': 50, "'": 52, '"': 53, '%': 54, ',': 55, '.': 56, '/': 59, '?': 60, '°': 62, 'É': 5, 'Д': 1, 'В': 2} # valid codes are those enumerated above plus the seven colors in 63, ..., 69 valid_codes = list(translation.values()) valid_codes.extend([63, 64, 65, 66, 67, 68, 69]) pointer = 0 message_array = [] while pointer < len(s): if s[pointer] == '{': end_escape = s.find('}', pointer) if end_escape == -1: Log('Escaped sequence missing closing curly brace: "%s"' % s) escaped_sequence = s[pointer+1 : end_escape] try: escaped_value = int(escaped_sequence) except ValueError: Log('Escaped sequence "%s" is not a number in message "%s"' <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657 215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196 65186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558 | <----SKIPPED LINES----> 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 BD-700 Global 7500 (twin-jet)'] = 33.88 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 1SP (twin-jet)'] = 13.26 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 T182 Turbo Skylane (piston-single)'] = 8.84 AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61 AIRCRAFT_LENGTH['Cessna 421 (twin-piston)'] = 11.09 AIRCRAFT_LENGTH['Cirrus SR-20 (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus SR-22 (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus SR22 Turbo (piston-single)'] = 7.92 AIRCRAFT_LENGTH['Cirrus Vision SF50 (single-jet)'] = 9.42 AIRCRAFT_LENGTH['Daher-Socata TBM-900 (single-turboprop)'] = 10.72 AIRCRAFT_LENGTH['Dassault Falcon 50 (tri-jet)'] = 18.52 AIRCRAFT_LENGTH['Dassault Falcon 7X (tri-jet)'] = 23.38 AIRCRAFT_LENGTH['Dassault Falcon 2000 (twin-jet)'] = 20.23 AIRCRAFT_LENGTH['Dassault Falcon 900 (tri-jet)'] = 20.21 AIRCRAFT_LENGTH['Embraer 170/175 (twin-jet)'] = (29.90 + 31.68) / 2 AIRCRAFT_LENGTH['EMBRAER 175 (long wing) (twin-jet)'] = 31.68 AIRCRAFT_LENGTH['EMBRAER 195 (twin-jet)'] = 38.66 AIRCRAFT_LENGTH['Embraer ERJ-135 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer ERJ-145 (twin-jet)'] = 29.87 AIRCRAFT_LENGTH['Embraer ERJ 175 (twin-jet)'] = 31.68 AIRCRAFT_LENGTH['Embraer ERJ 190 (twin-jet)'] = 36.25 AIRCRAFT_LENGTH['Embraer ERJ-190 (twin-jet)'] = 36.25 AIRCRAFT_LENGTH['Embraer Legacy 450 (twin-jet)'] = 19.69 AIRCRAFT_LENGTH['Embraer Legacy 550 (twin-jet)'] = 20.74 AIRCRAFT_LENGTH['Embraer Legacy 600/650 (twin-jet)'] = 26.33 AIRCRAFT_LENGTH['Embraer Phenom 100 (twin-jet)'] = 12.82 AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9 AIRCRAFT_LENGTH['Epic Aircraft LT (single-turboprop)'] = 10.92 AIRCRAFT_LENGTH['Eurocopter EC-635 (twin-turboshaft)'] = 10.21 AIRCRAFT_LENGTH['Fairchild Dornier 328JET (twin-jet)'] = 21.11 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['GULFSTREAM AEROSPACE G-7 Gulfstream G600 (twin-jet)'] = 29.29 <----SKIPPED LINES----> except IOError: Log('Unable to append to ' + file) if rolling: Tail(file, rolling, lines_to_keep=ROLLING_LOG_SIZE) def Tail(in_name, rolling_name, max_line_length=100, lines_to_keep=1000): """Fast pythonic implementation of tail -n. Args: in_name: name of file for which we want the tail rolling_name: name of file to write out max_line_length: since this uses seek to find the block of text near the end that has at most the lines_to_keep number of lines, we need to estimate the max line length over that block of text. We can afford to be a little conservative here. lines_to_keep: how many lines to keep in the rolling file. Returns: Integer number of lines actually kept, or -1 if UnicodeDecodeError detected (in which case the file was left unmodified). """ with open(in_name, 'r') as f: f.seek(0, os.SEEK_END) f_length = f.tell() bytes_to_read = min(max_line_length * lines_to_keep, f_length) f.seek(f_length - bytes_to_read) try: end_text = f.read() # Periodically, we get the following python error: # # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 0: # invalid start byte # # after which the module errors once, but subsequent calls to Log (and thus # to Tail) do not cause the same error. If there were really an invalid or # non-decodable byte in that position stored on disk, then presumably # subsequent calls to log on restart would cause the same error (because, # when exiting with an unhandled exception from this point, the log file # was not updated). Thus, we can reasonably assume that this is a transient # error, and just skip taking the tail. The next call to Log will # correct the log length to be the max number of lines. # # An incorrect assumption here - that is, if the error is not transient - # will show up by having a log file far in excess of the ROLLING_LOG_SIZE # number of lines. except UnicodeDecodeError: return -1 lines = end_text.split('\n') # perhaps the file was smaller than lines_to_keep lines, or many lines were # longer than max_line_length; in that case, the resulting text block will # potentially be smaller than lines_to_keep lines_to_keep = min(lines_to_keep, len(lines)) with open(rolling_name, 'w') as f: f.write('\n'.join(lines[-lines_to_keep:])) return lines_to_keep def UpdateRollingLogSize(configuration): """Set the global rolling_log_line_count based on settings file.""" if 'rolling_log_line_count' in configuration: global ROLLING_LOG_SIZE ROLLING_LOG_SIZE = configuration['rolling_log_line_count'] def LogTimes(times, threshold=0, title=''): <----SKIPPED LINES----> parsed_flight_details = parsed_json['flights'][fa_flight_number] flight['fa_flight_number'] = fa_flight_number origin = parsed_flight_details.get('origin') if origin: flight['origin_friendly'] = origin.get('friendlyLocation') flight['origin_iata'] = origin.get('iata') destination = parsed_flight_details.get('destination') if destination: flight['destination_friendly'] = destination.get('friendlyLocation') flight['destination_iata'] = destination.get('iata') aircraft_type = parsed_flight_details.get('aircraft') if aircraft_type: flight['aircraft_type_code'] = aircraft_type.get('type') flight['aircraft_type_friendly'] = aircraft_type.get('friendlyType') if flight['aircraft_type_friendly']: flight['aircraft_type_friendly'] = flight[ 'aircraft_type_friendly'].replace('biréacteur', 'twin-jet') flight['aircraft_type_friendly'] = flight[ 'aircraft_type_friendly'].replace('zweimotoriger Jet', 'twin-jet') flight['owner_location'] = Unidecode(aircraft_type.get('ownerLocation')) flight['owner'] = Unidecode(aircraft_type.get('owner')) flight['tail'] = Unidecode(aircraft_type.get('tail')) takeoff_time = parsed_flight_details.get('takeoffTimes') if takeoff_time: flight['scheduled_takeofftime'] = takeoff_time.get('scheduled') flight['actual_takeoff_time'] = takeoff_time.get('actual') gate_departure_time = parsed_flight_details.get('gateDepartureTimes') if gate_departure_time: flight['scheduled_departure_time'] = gate_departure_time.get('scheduled') flight['actual_departure_time'] = gate_departure_time.get('actual') gate_arrival_time = parsed_flight_details.get('gateArrivalTimes') if gate_arrival_time: flight['scheduled_arrival_time'] = gate_arrival_time.get('scheduled') flight['estimated_arrival_time'] = gate_arrival_time.get('estimated') landing_time = parsed_flight_details.get('landingTimes') <----SKIPPED LINES----> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] where each 0 is replaced by an integer 0,...,69. ''' # For each element in the string, # if it is an '{', find the closing '}' and collapse into one element # if it is not an '{' and we are not in an escaped string, translate translation = { ' ': 0, 'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20, 'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25, 'Z': 26, '1': 27, '2': 28, '3': 29, '4': 30, '5': 31, '6': 32, '7': 33, '8': 34, '9': 35, '0': 36, '!': 37, '@': 38, '#': 39, '$': 40, '(': 41, ')': 42, '-': 44, '+': 46, '&': 47, '=': 48, ';': 49, ':': 50, "'": 52, '"': 53, '%': 54, ',': 55, '.': 56, '/': 59, '?': 60, '°': 62, 'É': 5, 'Д': 1, 'В': 2, 'Í': 9} # valid codes are those enumerated above plus the seven colors in 63, ..., 69 valid_codes = list(translation.values()) valid_codes.extend([63, 64, 65, 66, 67, 68, 69]) pointer = 0 message_array = [] while pointer < len(s): if s[pointer] == '{': end_escape = s.find('}', pointer) if end_escape == -1: Log('Escaped sequence missing closing curly brace: "%s"' % s) escaped_sequence = s[pointer+1 : end_escape] try: escaped_value = int(escaped_sequence) except ValueError: Log('Escaped sequence "%s" is not a number in message "%s"' <----SKIPPED LINES----> |