Skip to content
Snippets Groups Projects

Backend

Merged Martin Petráček requested to merge backend into master
6 unresolved threads
Viewing commit 1575aae2
Show latest version
2 files
+ 27
11
Preferences
Compare changes
Files
2
+ 5
4
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import json
@@ -9,8 +10,8 @@ from threading import Timer
class macAddrStore():
def __init__(self):
self.__load()
self.save_interval=30*60
self.mac_timeout=60*24*30
self.save_interval=30*60 #TBD: move to configuration
self.mac_timeout=60*60*24*30 #TBD: move to configuration
t = Timer(self.save_interval, self.__timeout)
t.setDaemon(True) #thread will be canceled on exit (it hangs on exit without this)
t.start()
@@ -22,10 +23,10 @@ class macAddrStore():
if mac in self.known:
self.known[mac]=int(time.time())
else:
print "new MAC"
print "new MAC address %s" % mac
self.known[mac]=int(time.time())
self.__save()
os.system(u"/usr/bin/create_notification -s news 'Ve vasi siti se objevilo nove zarizeni (MAC adresa %s)' 'New device (MAC address %s) appeared on your network.'" % (mac, mac)) #TBD: Czech non-ascii characters...
os.system("/usr/bin/create_notification -s news 'Ve vasi siti se objevilo nove zarizeni (MAC adresa %s)' 'New device (MAC address %s) appeared on your network.'" % (mac, mac)) #TBD: Czech non-ascii characters...
def __save(self):
f = open('/tmp/known_macs.txt', 'w')