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()
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:
"""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
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 ##########################
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__':