forked from arnekaas/DSMR-P1-usb-logger
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.py
executable file
·36 lines (30 loc) · 1.04 KB
/
test.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
import time,os
from process_p1_telegram import process_p1_telegram
from sqlite_log import sqlite_log
print ("P1 read test started..." + time.strftime("%Y-%m-%d %H:%M:%S"))
def test(dirout=os.path.dirname(os.path.realpath(__file__)),
logfolder="../data/logs"):
try:
from read_p1_telegram import read_p1_telegram
telegram = read_p1_telegram(logfolder=logfolder)
except:
print("DSMR P1 USB read failed, usign test telegram")
with open(os.path.join(dirout,logfolder,'testP1telegram.txt'), 'r') as myfile:
telegram=myfile.read()
print (telegram)
#try:
serial_number, values = process_p1_telegram(telegram)
#except:
# print("processing failed")
# return
sqlite_log(serial_number, values, logfolder=logfolder,db_name="P1_observations.db")
try:
execfile("mysql_logger.py")
except:
print("mysql save of data failed, please check settings in mysql_logger.py")
return
def main():
test()
return
if __name__ == "__main__":
main()