Commits

Anonymous committed 61191de

logging

Comments (0)

Files changed (3)

domain/__init__.py

         return base_object
 
     def run_cycle(self):
-        logging.info('Beginning garden check')
+        logging.info('Beginning garden cycle')
         cycle_begin = datetime.now()
         readings = {}
 
             self.shift_current_bed()
 
         self.run_updates()
+        logging.debug("cycle complete")
 
     def run_updates(self):
         #TODO set event precedence or filter down events

domain/devices.py

     def getData(self):
         line = self.serial.readline().replace('\n', '').replace('\r', '').replace(";", "")
         parts = line.split(',')
-        if int(parts[0]) == 1:
-            return parts[1:]
-        raise Exception(parts[1])
+        try:
+            if int(parts[0]) == 1:
+                return parts[1:]
+        except :
+            logging.info("GardenDuino read error: %s" % (parts,))
+            raise
 
     def close(self):
         self.serial.close()
 
 class HotHouseRequestHandler(SimpleHTTPRequestHandler):
     def do_GET(self):
+        logging.debug('GET REQUEST Received %s' % (self.path,))
         parsedParams = urlparse.urlparse(self.path)
         queryParsed = urlparse.parse_qs(parsedParams.query)
 
             self.processMyRequest("unknown command")
 
     def do_POST(self):
+        logging.debug('POST REQUEST Received')
         self.send_response(405)
 
     def processMyRequest(self, status):
         try:
             self.garden.run_cycle()
         except Exception as e :
+            logging.debug("server - run garden cycle error")
             raise
 
         self.finish_check = datetime.now()
         else:
             new_timeout = int(float(settings.GARDEN.CHECK_INTERVAL) - float(check_length))
             self.timeout = (new_timeout + 1)
+        logging.debug("new timeout: %s" % (self.timeout,))
 
 
     def serve(self):
         self.garden.run_cycle()
         while self.run:
             self.handle_request()
+            logging.debug("serve loop end")
 
 
 if __name__=="__main__":