-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.py
More file actions
executable file
·44 lines (28 loc) · 877 Bytes
/
monitor.py
File metadata and controls
executable file
·44 lines (28 loc) · 877 Bytes
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
#! /usr/bin/python3
from monitor import *
import time
import sys
def logTemp():
count = len( sys.argv )
print( "count=={} sys.argv[0]={}".format( count, sys.argv[0] ))
if count < 2 :
filename = "log.csv"
else:
filename = sys.argv[1]
if not filename.endswith( "csv" ) : filename = "%s.csv" % filename
print( "Logging to %s, press Ctrl-C to stop logging..." % filename )
# open for write and erase if it already exists...
file = open( filename, "w+" )
monitor = MonitorPi()
try:
while True:
clear()
print( monitor.getStats() )
text = "{}, {}\n".format( monitor.time, monitor.temp )
file.write( text )
time.sleep(2)
except KeyboardInterrupt:
print( "\nDone." );
finally:
file.close()
logTemp()