-
Notifications
You must be signed in to change notification settings - Fork 1
/
logbook.py
49 lines (40 loc) · 1.7 KB
/
logbook.py
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
#! python
import datetime
def contact():
# Store contact details
heard_callsign = raw_input('Station Heard: ').upper()
rst_heard = raw_input('Station Heard RST: ')
working_callsign = raw_input('Working Callsign: ').upper()
rst_working = raw_input('Station Working RST: ')
freq = raw_input('Frequency (e.g 7038): ')
mode = raw_input('Mode (e.g PSK31, PSK63, RTTY): ').upper()
comment = raw_input('Comment (e.g Name, Location): ')
utc_datetime = datetime.datetime.utcnow()
# Output contact details
print('\nQSO Logged:')
print('Date/Time\t\tHeard\tRST\tWorking\tRST\tFreq\tMode\tComment')
print(utc_datetime.strftime("%d/%m/%Y %H:%M") + '\t\t' + heard_callsign + '\t' + rst_heard + '\t' + working_callsign + '\t' + rst_working + '\t' + freq + '\t' + mode + '\t' + comment);
# Create a create or open file logbook.txt and store amateur radio contact
with open("logbook.txt", "a") as myfile:
myfile.write(utc_datetime.strftime("%d/%m/%Y %H:%M") + '\t' + heard_callsign + '\t' + rst_heard + '\t' + working_callsign + '\t' + rst_working + '\t' + freq + '\t' + mode + '\t' + comment + '\n')
def logbook():
print('\nLogbook:')
print('Date/Time\t\tHeard\tRST\tWorking\tRST\tFreq\tMode\tComment')
t = open('logbook.txt', 'r')
print(t.read() + '\n')
def no_such_action():
print('\nAction not found\n')
def main():
actions = {"contact": contact, "logbook": logbook}
while True:
print('Python Amateur Radio Logbook')
print('\nMenu Options')
print('\ncontact: allows you to create an entry')
print('logbook: shows all log entrys\n')
selection = raw_input("Your selection: ")
if "quit" == selection:
return
toDo = actions.get(selection, no_such_action)
toDo()
if __name__ == "__main__":
main()