示例#1
0
 def lineReceived(self, line):
     """we got a full line from Pioneer"""
     logDebug(self, "p", "READ from {}: {}".format(self.wrapper.name(), repr(line)))
     if self.wrapper.tasks.running:
         self.wrapper.tasks.gotAnswer(PioneerMessage(line))
     else:
         LOGGER.error("Pioneer sent data without being asked:{}".format(line))
示例#2
0
文件: lgtv.py 项目: wrohdewald/halirc
 def _setAttributes(self, decoded, encoded):
     """The LG interface is a bit
     stupid: When sending, we send two characters for the command
     like ka or ma. But the answer only returns the second character,
     so we cannot easily find the corresponding full command"""
     if encoded is not None:
         parts = encoded.split(' ')
         if len(parts) < 3:
             self._decoded = ':'
             return
         self.status = parts[2][:2]
         cmd2 = parts[0]
         self.status = parts[2][:2]
         encodedValue = parts[2][2:]
         items = [x for x in self.commands.items() if x[1][1] == cmd2]
         if len(items) > 1:
             LOGGER.error('answer from LG matches more than 1 command: {}'.format(items))
         elif len(items) == 0:
             LOGGER.error('answer from LG matches no command: {}'.format(self.encoded))
         humanCommand = items[0][0]
         if encodedValue:
             decodedValue = self.values[humanCommand][encodedValue]
         else:
             decodedValue = 'None'
         self._decoded = ':'.join([humanCommand, decodedValue])
     else: # decoded
         self._decoded = decoded
         humanCommand = self.humanCommand()
         humanValue = self.value()
         if humanValue:
             encodedValue = [x[0] for x in self.values[humanCommand].items() if x[1] == humanValue][0]
         else:
             self.isQuestion = True
             encodedValue = 'ff'
     self._encoded = ' '.join([self.commands[humanCommand], self.setID, encodedValue])
示例#3
0
文件: gembird.py 项目: fazme/halirc
 def errReceived(self, data):
     """got stderr from sispmctl"""
     for line in data.split('\n'):
         if not line:
             # we do not want to log the copyright...
             # what sense does it make to add that
             # to an error message?
             break
         LOGGER.error('Gembird: %s' % line)
示例#4
0
 def errReceived(self, data):
     """got stderr from sispmctl"""
     for line in data.split('\n'):
         if not line:
             # we do not want to log the copyright...
             # what sense does it make to add that
             # to an error message?
             break
         LOGGER.error('Gembird: {}'.format(line))
示例#5
0
 def lineReceived(self, line):
     """we got a full line from Pioneer"""
     logDebug(self, 'p', 'READ from {}: {}'.format(self.wrapper.name(),
                                                   repr(line)))
     if self.wrapper.tasks.running:
         self.wrapper.tasks.gotAnswer(PioneerMessage(line))
     else:
         LOGGER.error(
             'Pioneer sent data without being asked:{}'.format(line))
示例#6
0
文件: vdr.py 项目: wrohdewald/halirc
 def _toggle1(result):
     """result ends in NOT_SUSPENDED or SUSPEND_NORMAL"""
     if result.value().endswith(' NOT_SUSPENDED'):
         return self.send('plug softhddevice susp').addCallback(_remoteOff).addCallback(startKodi)
     elif result.value().endswith(' SUSPEND_NORMAL'):
         if self.kodiProcess:
             logDebug(self, None, 'killing kodi process {}'.format(self.kodiProcess.pid))
             self.kodiProcess.kill() # would be nice to terminate cleanly
             _ = self.kodiProcess.wait()
             self.kodiProcess = None
         subprocess.Popen(['killall', '-9', 'kodi.bin']).wait()
         reactor.callLater(7, self.send, 'plug softhddevice resu')
         return self.send('remo on')
     else:
         LOGGER.error('plug softhddevice stat returns unexpected answer:{}'.format(repr(result)))
         return succeed(None)
示例#7
0
文件: lgtv.py 项目: wrohdewald/halirc
 def _setAttributes(self, decoded, encoded):
     """The LG interface is a bit
     stupid: When sending, we send two characters for the command
     like ka or ma. But the answer only returns the second character,
     so we cannot easily find the corresponding full command"""
     if encoded is not None:
         parts = encoded.split(' ')
         if len(parts) < 3:
             self._decoded = ':'
             return
         self.status = parts[2][:2]
         cmd2 = parts[0]
         self.status = parts[2][:2]
         encodedValue = parts[2][2:]
         items = [x for x in self.commands.items() if x[1][1] == cmd2]
         if len(items) > 1:
             LOGGER.error(
                 'answer from LG matches more than 1 command: {}'.format(
                     items))
         elif len(items) == 0:
             LOGGER.error('answer from LG matches no command: {}'.format(
                 self.encoded))
         humanCommand = items[0][0]
         if encodedValue:
             decodedValue = self.values[humanCommand][encodedValue]
         else:
             decodedValue = 'None'
         self._decoded = ':'.join([humanCommand, decodedValue])
     else:  # decoded
         self._decoded = decoded
         humanCommand = self.humanCommand()
         humanValue = self.value()
         if humanValue:
             encodedValue = [
                 x[0] for x in self.values[humanCommand].items()
                 if x[1] == humanValue
             ][0]
         else:
             self.isQuestion = True
             encodedValue = 'ff'
     self._encoded = ' '.join(
         [self.commands[humanCommand], self.setID, encodedValue])
示例#8
0
文件: vdr.py 项目: wrohdewald/halirc
 def lineReceived(self, line):
     """we got a full line from vdr"""
     logDebug(self, 'p', 'READ from {}: {}'.format(self.wrapper.name(), repr(line)))
     if line.startswith('221 '):
         # this is an error because we should have
         # closed the connection ourselves after a
         # much shorter timeout than the server timeout
         LOGGER.error('vdr closes connection, timeout')
         self.wrapper.close()
         return
     if line.startswith('220 '):
         self.wrapper.openDeferred.callback(None)
         return
     if line.split(' ')[0] not in ['250', '354', '550', '900', '910', '911']:
         LOGGER.error('from {}: {}'.format(self.wrapper.name(), line))
     if self.wrapper.tasks.running:
         self.wrapper.tasks.gotAnswer(VdrMessage(line))
     else:
         LOGGER.error('vdr sent data without being asked:{}'.format(line))
示例#9
0
文件: lgtv.py 项目: wrohdewald/halirc
 def connectionLost(self, reason):
     """USB disconnect or similar"""
     self.connected = False
     LOGGER.error('LGTV lost connection: {}'.format(reason))
     reactor.callLater(5, self.connect)
示例#10
0
 def gotNoProtocol(result):
     """something went wrong"""
     msg = "Pioneer: %s" % result.getErrorMessage()
     LOGGER.error(msg)
     raise Exception(msg)
示例#11
0
 def gotNoProtocol(result):
     """something went wrong"""
     msg = 'Pioneer: %s' % result.getErrorMessage()
     LOGGER.error(msg)
     raise Exception(msg)
示例#12
0
文件: lgtv.py 项目: wrohdewald/halirc
 def connectionLost(self, reason):
     """USB disconnect or similar"""
     self.connected = False
     LOGGER.error('LGTV lost connection: {}'.format(reason))
     reactor.callLater(5, self.connect)