Print usage if no options are provided
parent
3219edd35e
commit
2b04bffdc3
|
@ -13,6 +13,7 @@ from utils import get_active_transmitter_info, get_transmitter_stats, \
|
||||||
efficiency, find_passes, schedule_observation
|
efficiency, find_passes, schedule_observation
|
||||||
import settings
|
import settings
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
import sys
|
||||||
|
|
||||||
_LOG_LEVEL_STRINGS = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG']
|
_LOG_LEVEL_STRINGS = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG']
|
||||||
|
|
||||||
|
@ -89,6 +90,11 @@ if __name__ == "__main__":
|
||||||
help="Set the logging output level. {0}".format(_LOG_LEVEL_STRINGS))
|
help="Set the logging output level. {0}".format(_LOG_LEVEL_STRINGS))
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Check arguments
|
||||||
|
if args.station == None:
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Setting logging level
|
# Setting logging level
|
||||||
numeric_level = args.log_level
|
numeric_level = args.log_level
|
||||||
if not isinstance(numeric_level, int):
|
if not isinstance(numeric_level, int):
|
||||||
|
@ -114,6 +120,10 @@ if __name__ == "__main__":
|
||||||
# Get ground station information
|
# Get ground station information
|
||||||
ground_station = get_groundstation_info(ground_station_id)
|
ground_station = get_groundstation_info(ground_station_id)
|
||||||
|
|
||||||
|
# Exit if ground station is empty
|
||||||
|
if not ground_station:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Create cache
|
# Create cache
|
||||||
if not os.path.isdir(cache_dir):
|
if not os.path.isdir(cache_dir):
|
||||||
os.mkdir(cache_dir)
|
os.mkdir(cache_dir)
|
||||||
|
@ -258,12 +268,13 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
schedule_needed = False
|
schedule_needed = False
|
||||||
|
|
||||||
logging.info("Sch | NORAD | Start time | End time | El | " +
|
logging.info("GS | Sch | NORAD | Start time | End time | El | " +
|
||||||
"Priority | Transmitter UUID | Satellite name ")
|
"Priority | Transmitter UUID | Satellite name ")
|
||||||
for satpass in sorted(scheduledpasses, key=lambda satpass: satpass['tr']):
|
for satpass in sorted(scheduledpasses, key=lambda satpass: satpass['tr']):
|
||||||
logging.info(
|
logging.info(
|
||||||
"%3.d | %05d | %s | %s | %3.0f | %4.6f | %s | %s" %
|
"%3d | %3.d | %05d | %s | %s | %3.0f | %4.6f | %s | %s" %
|
||||||
(satpass['scheduled'],
|
(ground_station_id,
|
||||||
|
satpass['scheduled'],
|
||||||
int(satpass['id']),
|
int(satpass['id']),
|
||||||
satpass['tr'].strftime("%Y-%m-%dT%H:%M:%S"),
|
satpass['tr'].strftime("%Y-%m-%dT%H:%M:%S"),
|
||||||
satpass['ts'].strftime("%Y-%m-%dT%H:%M:%S"),
|
satpass['ts'].strftime("%Y-%m-%dT%H:%M:%S"),
|
||||||
|
@ -273,7 +284,7 @@ if __name__ == "__main__":
|
||||||
satpass['name'].rstrip()))
|
satpass['name'].rstrip()))
|
||||||
if not satpass['scheduled']:
|
if not satpass['scheduled']:
|
||||||
schedule_needed = True
|
schedule_needed = True
|
||||||
|
|
||||||
# Login and schedule passes
|
# Login and schedule passes
|
||||||
if schedule and schedule_needed:
|
if schedule and schedule_needed:
|
||||||
loginUrl = '{}/accounts/login/'.format(settings.NETWORK_BASE_URL) # login URL
|
loginUrl = '{}/accounts/login/'.format(settings.NETWORK_BASE_URL) # login URL
|
||||||
|
|
6
utils.py
6
utils.py
|
@ -258,8 +258,12 @@ def get_groundstation_info(ground_station_id):
|
||||||
ground_station_id))
|
ground_station_id))
|
||||||
for o in r.json():
|
for o in r.json():
|
||||||
if o['id'] == ground_station_id:
|
if o['id'] == ground_station_id:
|
||||||
found = True
|
if o['status'] == 'Online' or o['status'] == 'Testing':
|
||||||
|
found = True
|
||||||
|
else:
|
||||||
|
found = False
|
||||||
break
|
break
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
logging.info('Ground station information retrieved!')
|
logging.info('Ground station information retrieved!')
|
||||||
return o
|
return o
|
||||||
|
|
Loading…
Reference in New Issue