Mercurial > templog
comparison py/tempserver.py @ 229:99255c501e02
test sensor
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 10 Apr 2015 23:55:07 +0800 |
parents | d9e81a563923 |
children | 185621f47040 |
comparison
equal
deleted
inserted
replaced
228:d9e81a563923 | 229:99255c501e02 |
---|---|
29 def __enter__(self): | 29 def __enter__(self): |
30 self.params = params.Params() | 30 self.params = params.Params() |
31 self.fridge = fridge.Fridge(self) | 31 self.fridge = fridge.Fridge(self) |
32 self.uploader = uploader.Uploader(self) | 32 self.uploader = uploader.Uploader(self) |
33 self.params.load() | 33 self.params.load() |
34 self.set_sensors(sensor_ds18b20.DS18B20s(self)) | 34 self.set_sensors(sensor.make_sensor(self)) |
35 asyncio.get_event_loop().add_signal_handler(signal.SIGHUP, self._reload_signal) | 35 asyncio.get_event_loop().add_signal_handler(signal.SIGHUP, self._reload_signal) |
36 return self | 36 return self |
37 | 37 |
38 def __exit__(self, exc_type, exc_value, traceback): | 38 def __exit__(self, exc_type, exc_value, traceback): |
39 L("Exiting, cleanup handler"); | 39 L("Exiting, cleanup handler"); |
100 try: | 100 try: |
101 self.params.load() | 101 self.params.load() |
102 L("Reloaded.") | 102 L("Reloaded.") |
103 self._wakeup.set() | 103 self._wakeup.set() |
104 self._wakeup.clear() | 104 self._wakeup.clear() |
105 except self.Error, e: | 105 except Error as e: |
106 W("Problem reloading: %s" % str(e)) | 106 W("Problem reloading: %s" % str(e)) |
107 | 107 |
108 def setup_logging(): | 108 def setup_logging(): |
109 logging.basicConfig(format='%(asctime)s %(message)s', | 109 logging.basicConfig(format='%(asctime)s %(message)s', |
110 datefmt='%m/%d/%Y %I:%M:%S %p', | 110 datefmt='%m/%d/%Y %I:%M:%S %p', |
122 pidf = lockfile.pidlockfile.PIDLockFile(pidpath, threaded=False) | 122 pidf = lockfile.pidlockfile.PIDLockFile(pidpath, threaded=False) |
123 do_hup = '--hup' in sys.argv | 123 do_hup = '--hup' in sys.argv |
124 try: | 124 try: |
125 pidf.acquire(1) | 125 pidf.acquire(1) |
126 pidf.release() | 126 pidf.release() |
127 except (lockfile.AlreadyLocked, lockfile.LockTimeout), e: | 127 except (lockfile.AlreadyLocked, lockfile.LockTimeout) as e: |
128 pid = pidf.read_pid() | 128 pid = pidf.read_pid() |
129 if do_hup: | 129 if do_hup: |
130 try: | 130 try: |
131 os.kill(pid, signal.SIGHUP) | 131 os.kill(pid, signal.SIGHUP) |
132 print>>sys.stderr, "Sent SIGHUP to process %d" % pid | 132 print>>sys.stderr, "Sent SIGHUP to process %d" % pid |