01234567890123456789012345678901234567890123456789012345678901234567890123456789
190191192193194195196197198199200201202203204205206207208209 210211212213214215216217218219220221222223224225226227228229 65356536653765386539654065416542654365446545654665476548654965506551655265536554 655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587 6588 65896590659165926593659465956596659765986599660066016602660366046605660666076608 |
<----SKIPPED LINES---->
# flights per day. This allows those parameters to be fine-tuned in a
# useful way. This file is the location, on the webserver, of that image,
# which needs to be in alignment with the html page that displays it.
HOURLY_IMAGE_FILE = 'hours.png'
# This is all messages that have been sent to the board since the last time
# the file was manually cleared. Newest messages are at the bottom. It is
# visible at the webserver.
# This shows the most recent n messages sent to the board. Newest messages
# are at the top for easier viewing of "what did I miss".
ROLLING_MESSAGE_FILE = 'rolling_messages.txt'
STDERR_FILE = 'secure/stderr.txt'
BACKUP_FILE = 'secure/backup.txt'
SERVICE_VERIFICATION_FILE = 'secure/service-verification.txt'
UPTIMES_FILE = 'uptimes.php'
CODE_HISTORY_FILE = 'code_history.php'
FLIGHT_STATUS = 'flight_status.php'
# This keeps a log of all aircraft not yet cataloged in the AIRCRAFT_LENGTH dict
NEW_AIRCRAFT_FILE = 'secure/new_aircraft.txt'
FLAG_MSG_FLIGHT = 1 # basic flight details
FLAG_MSG_INSIGHT = 2 # random tidbit about a flight
FLAG_MSG_HISTOGRAM = 3 # histogram message
FLAG_MSG_CLEAR = 4 # a blank message to clear the screen
# user-entered message to display for some duration of time
FLAG_MSG_PERSONAL = 5
FLAG_INSIGHT_LAST_SEEN = 0
FLAG_INSIGHT_DIFF_AIRCRAFT = 1
FLAG_INSIGHT_NTH_FLIGHT = 2
FLAG_INSIGHT_GROUNDSPEED = 3
FLAG_INSIGHT_ALTITUDE = 4
FLAG_INSIGHT_VERTRATE = 5
FLAG_INSIGHT_FIRST_DEST = 6
FLAG_INSIGHT_FIRST_ORIGIN = 7
FLAG_INSIGHT_FIRST_AIRLINE = 8
FLAG_INSIGHT_FIRST_AIRCRAFT = 9
FLAG_INSIGHT_LONGEST_DELAY = 10
<----SKIPPED LINES---->
[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"'
% (escaped_sequence, s))
if escaped_value not in valid_codes:
Log('Escaped sequence "%d" is not a valid escape code in message "%s"'
% (escaped_value, s))
else:
message_array.append(escaped_value)
if end_escape == -1:
pointer = len(s)
else:
pointer = end_escape + 1
else:
message_array.append(translation[s[pointer].upper()])
pointer += 1
expected_characters = SPLITFLAP_CHARS_PER_LINE * SPLITFLAP_LINE_COUNT
missing_characters = max(0, expected_characters - len(message_array))
if missing_characters:
for unused_n in range(missing_characters):
message_array.append(0)
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
<----SKIPPED LINES---->
|
01234567890123456789012345678901234567890123456789012345678901234567890123456789
190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 65376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616 |
<----SKIPPED LINES---->
# flights per day. This allows those parameters to be fine-tuned in a
# useful way. This file is the location, on the webserver, of that image,
# which needs to be in alignment with the html page that displays it.
HOURLY_IMAGE_FILE = 'hours.png'
# This is all messages that have been sent to the board since the last time
# the file was manually cleared. Newest messages are at the bottom. It is
# visible at the webserver.
# This shows the most recent n messages sent to the board. Newest messages
# are at the top for easier viewing of "what did I miss".
ROLLING_MESSAGE_FILE = 'rolling_messages.txt'
STDERR_FILE = 'secure/stderr.txt'
BACKUP_FILE = 'secure/backup.txt'
SERVICE_VERIFICATION_FILE = 'secure/service-verification.txt'
UPTIMES_FILE = 'uptimes.php'
CODE_HISTORY_FILE = 'code_history.php'
FLIGHT_STATUS = 'flight_status.php'
# This keeps a log of all aircraft not yet cataloged in the AIRCRAFT_LENGTH dict
# and also keeps a log of new characters needing translation to the displayable
# set of characters for the splitflap display
NEW_AIRCRAFT_FILE = 'secure/new_aircraft.txt'
FLAG_MSG_FLIGHT = 1 # basic flight details
FLAG_MSG_INSIGHT = 2 # random tidbit about a flight
FLAG_MSG_HISTOGRAM = 3 # histogram message
FLAG_MSG_CLEAR = 4 # a blank message to clear the screen
# user-entered message to display for some duration of time
FLAG_MSG_PERSONAL = 5
FLAG_INSIGHT_LAST_SEEN = 0
FLAG_INSIGHT_DIFF_AIRCRAFT = 1
FLAG_INSIGHT_NTH_FLIGHT = 2
FLAG_INSIGHT_GROUNDSPEED = 3
FLAG_INSIGHT_ALTITUDE = 4
FLAG_INSIGHT_VERTRATE = 5
FLAG_INSIGHT_FIRST_DEST = 6
FLAG_INSIGHT_FIRST_ORIGIN = 7
FLAG_INSIGHT_FIRST_AIRLINE = 8
FLAG_INSIGHT_FIRST_AIRCRAFT = 9
FLAG_INSIGHT_LONGEST_DELAY = 10
<----SKIPPED LINES---->
[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}
# untranslated characters: 双
# 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"'
% (escaped_sequence, s))
if escaped_value not in valid_codes:
Log('Escaped sequence "%d" is not a valid escape code in message "%s"'
% (escaped_value, s))
else:
message_array.append(escaped_value)
if end_escape == -1:
pointer = len(s)
else:
pointer = end_escape + 1
else:
try:
message_array.append(translation[s[pointer].upper()])
except KeyError:
WriteFile(NEW_AIRCRAFT_FILE, 'New character' + s[pointer], append=True)
pointer += 1
expected_characters = SPLITFLAP_CHARS_PER_LINE * SPLITFLAP_LINE_COUNT
missing_characters = max(0, expected_characters - len(message_array))
if missing_characters:
for unused_n in range(missing_characters):
message_array.append(0)
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
<----SKIPPED LINES---->
|