Esempio n. 1
0
 def setPlayerSoundDevice(self, soundDevice):
     util.LOG_DEBUG('{0}: try setting soundDevice to {1}'.format(
         self, soundDevice))
     if self._player.setSoundOutputDevice:
         util.LOG_DEBUG('{0}: setting soundDevice to {1}'.format(
             self, soundDevice))
         self._player.setSoundOutputDevice(soundDevice)
Esempio n. 2
0
    def getAvailablePlayerSoundDevices(cls):
        util.LOG_DEBUG('{}.getAvailablePlayerSoundDevices'.format(
            cls.__name__))
        devices = SubprocessAudioPlayer.getAvailablePlayerSoundDevices()

        import re
        output = subprocess.check_output(['aplay', '-L']).splitlines()

        util.LOG_DEBUG(
            '{}.getAvailablePlayerSoundDevices - found devs = {}'.format(
                cls.__name__, output))

        devName = ""
        devDescription = ""
        for l in output:
            util.LOG_DEBUG(
                '{}.getAvailablePlayerSoundDevices - line = {}'.format(
                    cls.__name__, l))
            if l.find("CARD=") > 0:
                if devName <> "":
                    util.LOG_DEBUG(
                        '{}.getAvailablePlayerSoundDevices: Add Device {}: {}'.
                        format(cls.__name__, devName, devDescription))
                    devices.append((devName, devDescription))
                devName = l
                devDescription = l
            else:
                devDescription = (devDescription + " " + l.strip()).strip()

        util.LOG_DEBUG(
            '{}.getAvailablePlayerSoundDevices - found devices = {}'.format(
                cls.__name__, devices))

        return devices
Esempio n. 3
0
    def pipe(self, source):
        # km-p 201506
        pipeArgs = self._pipeArgs
        util.LOG_DEBUG(
            "SubprocessAudioPlayer.pipe: before adding _soundOutputArgs pipeArgs={}"
            .format(pipeArgs))
        if self._soundOutputArgs is not None:
            pipeArgs = pipeArgs + self._soundOutputArgs

        util.LOG_DEBUG(
            "SubprocessAudioPlayer.pipe: after adding _soundOutputArgs pipeArgs={}"
            .format(pipeArgs))

        #self._wavProcess = subprocess.Popen(self._pipeArgs,stdin=subprocess.PIPE,stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT)
        self._wavProcess = subprocess.Popen(pipeArgs,
                                            stdin=subprocess.PIPE,
                                            stdout=(open(os.path.devnull,
                                                         'w')),
                                            stderr=subprocess.STDOUT)
        ##########

        try:
            shutil.copyfileobj(source, self._wavProcess.stdin)
        except IOError, e:
            if e.errno != errno.EPIPE:
                util.ERROR('Error piping audio', hide_tb=True)
Esempio n. 4
0
    def setSoundOutputDevice(self, device):
        util.LOG_DEBUG('{}: Setting SoundOutputDevice to {}'.format(
            self.ID, device))
        SubprocessAudioPlayer.setSoundOutputDevice(self, device)

        util.LOG_DEBUG('{}: _pipeArgs before adding {}'.format(
            self.ID, self._pipeArgs))
        if device <> '' and device <> '/' and device <> '__default__':
            self._soundOutputArgs = ('-D{}'.format(device), )
        else:
            self._soundOutputArgs = None
        util.LOG_DEBUG('{}: _pipeArgs after adding {}'.format(
            self.ID, self._pipeArgs))
Esempio n. 5
0
def getWindowReader(winID):
    # km-p 201507 logging added
    util.LOG_DEBUG ("getWindowReader ({})".format (winID))

    reader = xbmc.getInfoLabel('Window({0}).Property(TTS.READER)'.format(winID))
    if reader and reader in READERS_MAP:
        return READERS_MAP[reader]
    return READERS_WINID_MAP.get(winID,DefaultWindowReader)
Esempio n. 6
0
    def getEditText(self):
        util.LOG_DEBUG('VirtualKeyboardReader.getEditText; EditID={}'.format(
            self.editID))

        # km-p  201508 fix -> retrieve control label or edit field
        #   (editID = 4 => numeric input -> label)
        #   (others (?) => edit field)

        if self.editID == 4:
            info = 'Control.GetLabel({0})'.format(self.editID)
        else:
            info = 'Control.GetLabel({0}).index(1)'.format(self.editID)

        util.LOG_DEBUG(
            'VirtualKeyboardReader.getEditText; info={}'.format(info))
        #
        # return xbmc.getInfoLabel(info).decode('utf-8')
        infoLabelContent = xbmc.getInfoLabel(info).decode('utf-8')
        util.LOG_DEBUG(
            'VirtualKeyboardreader.getEditText: infoLabelContent={}'.format(
                infoLabelContent))
        return infoLabelContent
Esempio n. 7
0
    def getAvailablePlayerSoundDevices(cls, playerID):
        util.LOG_DEBUG("{}.cls.getAvailablePlayerSoundDevices ({})".format(
            cls.__name__, playerID))

        devices = []
        for p in cls.players:
            if p.available() and p.ID == playerID:
                try:
                    devices = p.getAvailablePlayerSoundDevices()
                except AttributeError:
                    pass

        return devices
Esempio n. 8
0
    def getControlText(self, controlID):
        label = xbmc.getInfoLabel('System.CurrentControl').decode('utf-8')
        try:
            util.LOG_DEBUG('{}.{}: label={}'.format('SelectDialogReader',
                                                    'getControlText', label))
        except:
            pass

        try:
            selected = xbmc.getCondVisibility(
                'Container({0}).ListItem.IsSelected'.format(
                    controlID)) and ': {0}'.format(util.T(32200)) or ''
        except:
            selected = ''
            try:
                util.LOG_DEBUG(
                    '{}.{}: Error when getting selected value! (ControlID={}, Label={}'
                    .format('SelectDialogReader', 'getControlText', controlID,
                            label))
            except:
                pass

        try:
            util.LOG_DEBUG('{}.{}: selected={}'.format('SelectDialogReader',
                                                       'getControlText',
                                                       selected))
        except:
            pass

        text = u'{0}{1}'.format(label, selected)
        try:
            util.LOG_DEBUG('{}.{}: text={}'.format('SelectDialogReader',
                                                   'getControlText', text))
        except:
            pass

        return (text, text)
Esempio n. 9
0
    def getMonitoredText(self, isSpeaking=False):
        text = self.getEditText()

        util.LOG_DEBUG(
            'VirtualKeyboardreader.getMonitoredText: text={}'.format(text))

        if text != self.keyboardText:
            if not self.keyboardText and len(text) > 1:
                self.keyboardText = text
                self.lastChange = time.time()
                return None
            self.lastChange = time.time()
            out = ''
            d = difflib.Differ()
            if not text and self.keyboardText:
                self.keyboardText = ''
                out = util.T(32178)
            elif self.isIP(text):
                if self.isIP(text) and self.isIP(
                        self.keyboardText):  #IP Address
                    oldip = self.keyboardText.replace(' ', '').split('.')
                    newip = text.replace(' ', '').split('.')
                    for old, new in zip(oldip, newip):
                        if old == new: continue
                        out = ' '.join(list(new))
                        break
            elif len(text) > len(self.keyboardText):
                for c in d.compare(self.keyboardText, text):
                    if c.startswith('+'):
                        out += u' ' + (c.strip(' +') or util.T(32177))
            else:
                for c in d.compare(self.keyboardText, text):
                    if c.startswith('-'):
                        out += u' ' + (c.strip(' -') or util.T(32177))
                if out: out = out.strip() + ' {0}'.format(util.T(32179))
            self.keyboardText = text
            if out:
                return out.strip()
        else:
            now = time.time()
            if now - self.lastChange > 2:  #We haven't had input for a second, read all the text
                if text != self.lastRead:
                    self.lastChange = now
                    self.lastRead = text
                    if self.isIP(text): return text.replace(' ', '')
                    return text
        return None
Esempio n. 10
0
 def getAvailablePlayerSoundDevices(cls, playerID):
     util.LOG_DEBUG('{}.getAvailablePlayerSoundDevices({})'.format(
         cls.__name__, playerID))
     devices = []
     devices = cls.playerClass.getAvailablePlayerSoundDevices(playerID)
     return devices
Esempio n. 11
0
 def setPlayerSoundDevice(self, soundDevice):
     util.LOG_DEBUG('{}.setPlayerSoundDevice to {}'.format(
         self.__class__.__name__, soundDevice))
     self.player.setPlayerSoundDevice(soundDevice)
Esempio n. 12
0
 def getAvailablePlayerSoundDevices(cls):
     util.LOG_DEBUG('{}.getAvailablePlayerSoundDevices'.format(
         cls.__name__))
     devices = [('__default__', util.T(32203))]
     return devices