2 # Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
4 # This file is part of tempcontrol.
6 # tempcontrol is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation, either
9 # version 3 of the License, or (at your option) any later version.
11 # tempcontrol is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with tempcontrol. If not, see
18 # <http://www.gnu.org/licenses/>.
20 """Log control and ambient temperature every 10 seconds.
22 usage: python temp_monitor.py
27 from tempcontrol.backend import get_backend
30 b = get_backend('melcor')()
33 with open('temp_monitor.log', 'a') as f:
36 next_time = last + period
38 time.sleep(next_time - time.time())
39 tstr = time.strftime('%Y-%m-%d %H:%M:%S')
40 temp = str(b.get_temp())
41 ambient = str(b.get_ambient_temp())
42 f.write('\t'.join([tstr, temp, ambient]) + '\n')
44 print('\t'.join([tstr, temp, ambient]))