[aprs-tools] raw_parser, add option for dummy run, and colours

main-solar-only
Richard Meadows 2016-06-02 11:35:58 +01:00
rodzic 233a1a5533
commit f082c49d77
1 zmienionych plików z 25 dodań i 2 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ from ukhas_format import *
from habitat_upload import * from habitat_upload import *
from telemetry_format import * from telemetry_format import *
from datetime import datetime from datetime import datetime
from colorama import *
# Get the name of the input file # Get the name of the input file
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
@ -47,14 +47,37 @@ with open(file_name, 'r') as data_file:
data = sorted(data, key=lambda x: x['time']) data = sorted(data, key=lambda x: x['time'])
# Print data # Print data
print
print "Found the following data points:"
for datum in data: for datum in data:
print_datum(datum, tf) print_datum(datum, tf)
# Prompt for upload
print
print "Do you wish to upload this to habitat?"
response = raw_input("N will trigger a dummy run. (Y/N): ").lower() or "x"
# check response
if response == 'y':
dummy_run = False
elif response == 'n':
dummy_run = True
else:
print "Exiting..."
quit()
print
if dummy_run:
print "Compiled telemetry strings (dummy run):"
else:
print "Compiled telemetry strings for upload:"
# Upload data to habitat # Upload data to habitat
for datum in data: for datum in data:
ukhas_str = ukhas_format(datum, tf) ukhas_str = ukhas_format(datum, tf)
try: try:
print ukhas_str print ukhas_str
print habitat_upload(datum['time'], ukhas_str) if not dummy_run: # Not a dummy run, actually upload
print Fore.CYAN + habitat_upload(datum['time'], ukhas_str) + Fore.RESET
except: except:
None None