コード例 #1
0
 def handleDevice(self):
     "Callback once per item in the device sensor list on datapoint change."
     import traceback
     cmd = ''
     try:
         nam = self.dp().name()
         cmd = self.dp().value().data()
         Utils.log('Command received:' + nam[:nam.find(':')] + ' -> ' + cmd,
                   timestamp=1)
         itms = cmd.split('/')
         if len(itms) == self.numParam:
             command = itms[0]
             sysName = itms[1]
             answer = ''
             for i in xrange(len(itms)):
                 if i > 0: answer = answer + '/' + itms[i]
             result = None
             if sysName == self.sysname:
                 try:
                     result = self.handle(itms, answer)
                     if result is None:
                         error('The command:"' + cmd +
                               '" failed. [Internal Error] ',
                               timestamp=1)
                         return self.makeAnswer('ERROR', answer)
                     return result
                 except Exception, X:
                     error('The command:"' + cmd + '" failed:' + str(X),
                           timestamp=1)
                     traceback.print_exc()
                     return self.makeAnswer('ERROR', answer)
                 except:
                     error('The command:"' + cmd +
                           '" failed (Unknown exception)',
                           timestamp=1)
                     traceback.print_exc()
                     return self.makeAnswer('ERROR', answer)
コード例 #2
0
def info(message, timestamp=None, type=default_error_type):
    "Informational printout to PVSS logger window"
    Utils.log(message, timestamp=timestamp)
    logger.info(type, message)