forked from jfrancis42/js8net-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstations.py
More file actions
executable file
·68 lines (59 loc) · 2.22 KB
/
stations.py
File metadata and controls
executable file
·68 lines (59 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# coding: utf-8
import time
import json
from js8net import *
import argparse
# Main program.
if __name__ == "__main__":
parser=argparse.ArgumentParser(description='Monitored Station Reporter.')
parser.add_argument('--js8-host',default=False,help='IP/DNS of JS8Call server (default localhost)')
parser.add_argument('--js8-port',default=False,help='TCP port of JS8Call server (default 2442)')
parser.add_argument('--call-activity',default=False,help='Show only call activity',action='store_true')
parser.add_argument('--band-activity',default=False,help='Show only band activity',action='store_true')
parser.add_argument('--age',default=False,help='Sort list by age',action='store_true')
parser.add_argument('--snr',default=False,help='Sort list by SNR',action='store_true')
args=parser.parse_args()
js8host=False
js8port=False
if(args.js8_host):
js8host=args.js8_host
else:
js8host='localhost'
if(args.js8_port):
js8port=int(args.js8_port)
else:
js8port=2442
# Connect to JS8Call.
start_net(js8host,js8port)
# If Call Activity...
if(not(args.call_activity)):
stuff=get_call_activity()
if(stuff):
if(args.age):
for station in sorted(stuff,key=lambda n: n.age()):
print(station.string())
elif(args.snr):
for station in sorted(stuff,key=lambda n: n.snr,reverse=True):
print(station.string())
else:
for station in stuff:
print(station.string())
else:
print('No active stations.')
print()
# If Band Activity...
if(not(args.band_activity)):
stuff=get_band_activity()
if(stuff):
if(args.age):
for station in sorted(stuff,key=lambda n: n.age()):
print(station.string())
elif(args.snr):
for station in sorted(stuff,key=lambda n: n.snr,reverse=True):
print(station.string())
else:
for station in stuff:
print(station.string())
else:
print('No active stations.')