Utoljára aktív 1731166851

dominic gist felülvizsgálása 1731166851. Revízióhoz ugrás

1 file changed, 60 insertions

aprs_sendstatus.py(fájl létrehozva)

@@ -0,0 +1,60 @@
1 + #!/usr/bin/env python3
2 +
3 + """ sending aprs status packets for my weather station
4 +
5 + Author: Dominic Reich (OE7DRT) <quick.hat4396@qtztsjosmprqmgtunjyf.com>
6 + """
7 +
8 + import aprslib
9 +
10 +
11 + intervals = (
12 + ('weeks', 604800), # 60 * 60 * 24 * 7
13 + ('days', 86400), # 60 * 60 * 24
14 + ('hours', 3600), # 60 * 60
15 + ('minutes', 60),
16 + ('seconds', 1),
17 + )
18 +
19 +
20 + def get_uptime(granularity=2):
21 + with open('/proc/uptime', 'r') as u:
22 + uptime_seconds = int(float(u.readline().split()[0]))
23 +
24 + return(display_time(uptime_seconds, granularity))
25 +
26 +
27 + def display_time(seconds, granularity=2):
28 + result = []
29 +
30 + for name, count in intervals:
31 + value = seconds // count
32 + if value:
33 + seconds -= value * count
34 + if value == 1:
35 + name = name.rstrip('s')
36 + result.append("{} {}".format(value, name))
37 + return ', '.join(result[:granularity])
38 +
39 +
40 + def test():
41 + """test function"""
42 + print('Uptime: ' + get_uptime())
43 +
44 +
45 + def main():
46 + """main func"""
47 + AIS = aprslib.IS("OE7DRT-13", passwd="*****", port=14580)
48 +
49 + #AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Running for " + get_uptime(2) + " on https://wx.oe7drt.com\r\n")
50 + try:
51 + AIS.connect()
52 + except TimeoutError:
53 + print("Could not send packets - Timeout.")
54 + except:
55 + print("An unexpected Error occured:")
56 +
57 + AIS.sendall("OE7DRT-13>APRS,TCPIP*:>Weatherpage: https://wx.oe7drt.com\r\n")
58 +
59 + if __name__ == "__main__":
60 + main()
Újabb Régebbi