/
dimeteo.py
71 lines (47 loc) · 1.4 KB
/
dimeteo.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import logging
import logging.config
logging.config.fileConfig('logging.conf')
logger = logging.getLogger()
# dimeteo modules
import gui, wfs, db, timer, sensors, pir
from threading import Thread
def main():
# Get forecasts and save to DB
def get_forecasts():
data = wfs.wfs().get_all_sources()
dbase = db.db()
dbase.insert_wfs_data(data)
dbase.close_connection()
# Read data from sensors and save to DB
def read_sensors():
data = sensors.sensors().read_all()
dbase = db.db()
dbase.insert_sensor_data(data)
dbase.close_connection()
# Screensaver
scr = Thread(target = pir.screensaver)
scr.daemon = True
scr.start()
##test
##get_forecasts()
##read_sensors()
# get data from forecasts each hour
repeat_get_forecasts = timer.timer(3600, get_forecasts)
repeat_get_forecasts.start()
# get data from sensors each minute
repreat_read_sensors = timer.timer(60, read_sensors)
repreat_read_sensors.start()
# Send sensor data to openweathermap.com
#response = wfs.wfs().send_to_owm()
#print (response)
# Interface
root = gui.Interface()
root.mainloop()
if __name__ == '__main__':
main()
# 'application' code
#logger.debug('debug message')
#logger.info('info message')
#logger.warn('warn message')
#logger.error('error message')
#logger.critical('critical message')