]> gitweb.maison.local Git - pyowl.git/commitdiff
Added date and time to log messages + some clean ups
authorlionel <lionel@stargate.enneade.fdn.org>
Mon, 23 Nov 2015 09:25:12 +0000 (10:25 +0100)
committerlionel <lionel@stargate.enneade.fdn.org>
Mon, 23 Nov 2015 09:25:12 +0000 (10:25 +0100)
cm160Server.py

index 53ad88b27de9af581a14b41fe6bb6b7dd447b255..285b1a8ea2f8f1554173c347cd694cd8901c579f 100755 (executable)
@@ -72,8 +72,8 @@ class UserOutput:
       else:
         #Create it
         fd = open(self.__logFile, "w")
-          
-      fd.write("%s\n" % (line) )
+      logdatetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+      fd.write("%s %s\n" % (logdatetime, line) )
     finally:
       if fd != None:
         fd.close()
@@ -436,7 +436,7 @@ class CM160:
   
   def serSend(self, byteList):
     """Send a list of bytes to the serial port
-       openSerialPort() must have been successfully called before alling this method 
+       openSerialPort() must have been successfully called before calling this method 
     """
     self.__ser.write( self.getString(byteList) )
     for b in byteList:
@@ -697,6 +697,7 @@ class MySQLDataStore(object):
   """Responsible for the storage and retrieval of CM160 data using a MySQL database to hold the data"""
 
   def __init__ (self):
+    self.__uo             = uo
     self.__db             = "owl"
     self.__StoreConn      = None
     self.__StoreCursor    = None
@@ -768,8 +769,8 @@ class MySQLDataStore(object):
 
   def info(self, text):
     """Display info text"""
-#    if self.__uo != None:
-#      self.__uo.info(text)
+    if self.__uo != None:
+      self.__uo.info(text)
 
 
 ######################## Command line interface ##########################
@@ -783,34 +784,6 @@ def usage(uo):
     uo.info("-d:  Debug on. Send extra debug text to stdout if not in quiet mode.")
     uo.info("-h : Display this help text.")
 
-def getInput(prompt="", noEcho=False):
-  """Get input from user"""
-  p = "INPUT: %s: " % (prompt)
-  if noEcho:
-    return getpass.getpass(p, sys.stdout)
-  return raw_input(p)
-    
-def getDateTime(text):
-  """Return a datetime object from the given text
-     text may contain a datetime as either
-     dd/mm/yyyy or
-     hh:mi:dd/mm/yyyy 
-  """
-  
-  dt=None
-  
-  #if just the date has been entered
-  if text.find('/') != -1 and text.find(':') == -1:
-    dt=datetime.datetime.strptime(text,"%d/%m/%Y")
-    
-  elif text.find('/') != -1:  
-    dt=datetime.datetime.strptime(text,"%H:%M:%d/%m/%Y")
-    
-  else:
-    raise OWLError("%s is not a valid datetime" % (text) )
-
-  return dt
-
 # MAIN
 
 if __name__=='__main__':