Exemplo n.º 1
0
 def threadedSay(self, text):
     if not self.SpVoice: return
     ssml = self.ssml.format(text=saxutils.escape(text))
     try:
         self.SpVoice.Speak(ssml, 1)
     except self.COMError:
         util.ERROR('COMError: RESETTING SAPI', hide_tb=True)
         self.resetSAPI()
         try:
             self.SpVoice.Speak(ssml, 1)
         except self.COMError:
             util.ERROR('COMError: SAPI Failed after reset')
    def _init(self):
        try:
            self._getRecordings()
        except:
            self.getRecordingsFailed = True
            util.ERROR()

        try:
            self._getRules()
        except:
            self.getRulesFailed = True
            util.ERROR()
Exemplo n.º 3
0
    def scheduleButtonClicked(self, controlID):
        action = self.scheduleButtonActions.get(controlID)
        if not action or action != 'delete':
            return

        self.setProperty('action.busy', '1')
        try:
            self._show.deleteAll()
            # Check if we have protected airings. If so don't close
            for item in self.airingsList:
                airing = item.dataSource.get('airing')
                if not airing:
                    continue
                if not airing.deleted and airing.protected:
                    self.fillAirings()
                    break
            else:
                self.doClose()
        except tablo.APIError:
            util.ERROR()
        finally:
            self.setProperty('action.busy', '')

        self.modified = True

        self.updateIndicators()
Exemplo n.º 4
0
	def pipe(self,source):
		self._wavProcess = subprocess.Popen(self._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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def runCommandAndPipe(self, text):
     postdata = {
         'text': text.encode('utf-8')
     }  #TODO: This fixes encoding errors for non ascii characters, but I'm not sure if it will work properly for other languages
     if self.perlServer:
         postdata['voice'] = self.voice
         postdata['rate'] = self.remote_speed
         req = urllib2.Request(self.httphost + 'speak.wav',
                               urllib.urlencode(postdata))
     else:
         self.updatePostdata(postdata)
         req = urllib2.Request(self.httphost + 'wav',
                               urllib.urlencode(postdata))
     try:
         res = urllib2.urlopen(req)
         if not res.info().get('Content-Type') == 'audio/x-wav': return None
         self.failFlag = False
         return res
     except:
         err = util.ERROR(
             'SpeechServerBackend: Failed to get wav from server',
             hide_tb=True)
         if self.failFlag:
             self.flagAsDead(
                 reason=err)  #This is the second fail in a row, mark dead
         self.failFlag = True
         return False
     return True
Exemplo n.º 7
0
    def deviceVersionAllowed(self, device):
        try:
            return util.Version(device.version) >= util.Version('2.2.9')
        except:
            util.ERROR()

        return True
Exemplo n.º 8
0
 def onVideoWindowClosed(self):
     util.DEBUG_LOG('Player: Video window closed')
     try:
         self.handler.onVideoWindowClosed()
         self.stop()
     except:
         util.ERROR()
Exemplo n.º 9
0
    def onAction(self, action):
        try:
            ID = action.getId()
            if 57 < ID < 68:
                if not xbmc.getCondVisibility('ControlGroup({0}).HasFocus(0)'.format(self.PIN_ENTRY_GROUP_ID)):
                    item = self.userList.getSelectedItem()
                    if not item.dataSource.isProtected:
                        return
                    self.setFocusId(self.PIN_ENTRY_GROUP_ID)
                self.pinEntryClicked(ID + 142)
                return
            elif 142 <= ID <= 149:  # JumpSMS action
                if not xbmc.getCondVisibility('ControlGroup({0}).HasFocus(0)'.format(self.PIN_ENTRY_GROUP_ID)):
                    item = self.userList.getSelectedItem()
                    if not item.dataSource.isProtected:
                        return
                    self.setFocusId(self.PIN_ENTRY_GROUP_ID)
                self.pinEntryClicked(ID + 60)
                return
            elif ID in (xbmcgui.ACTION_NAV_BACK, xbmcgui.ACTION_BACKSPACE):
                if xbmc.getCondVisibility('ControlGroup({0}).HasFocus(0)'.format(self.PIN_ENTRY_GROUP_ID)):
                    self.pinEntryClicked(211)
                    return
        except:
            util.ERROR()

        kodigui.BaseWindow.onAction(self, action)
Exemplo n.º 10
0
    def onAction(self, action):
        try:
            controlID = self.getFocusId()

            if not controlID and self.lastFocusID and not action == xbmcgui.ACTION_MOUSE_MOVE:
                self.setFocusId(self.lastFocusID)

            if action in (xbmcgui.ACTION_NAV_BACK,
                          xbmcgui.ACTION_CONTEXT_MENU):
                if not xbmc.getCondVisibility(
                        'ControlGroup({0}).HasFocus(0)'.format(
                            self.OPTIONS_GROUP_ID)):
                    if self.getProperty('on.extras'):
                        self.setFocusId(self.OPTIONS_GROUP_ID)
                        return

            if action == xbmcgui.ACTION_LAST_PAGE and xbmc.getCondVisibility(
                    'ControlGroup(300).HasFocus(0)'):
                self.next()
            elif action == xbmcgui.ACTION_NEXT_ITEM:
                self.setFocusId(300)
                self.next()
            elif action == xbmcgui.ACTION_FIRST_PAGE and xbmc.getCondVisibility(
                    'ControlGroup(300).HasFocus(0)'):
                self.prev()
            elif action == xbmcgui.ACTION_PREV_ITEM:
                self.setFocusId(300)
                self.prev()
        except:
            util.ERROR()

        kodigui.ControlledWindow.onAction(self, action)
Exemplo n.º 11
0
    def onAction(self, action):
        try:
            controlID = self.getFocusId()
            if action == xbmcgui.ACTION_MOVE_LEFT:
                self.setUpDownDatetime(controlID)

                if controlID in self.chanLabelButtons:
                    return self.guideLeft(True)
                elif controlID - 1 in self.chanLabelButtons:
                    return self.guideLeft()
            elif action == xbmcgui.ACTION_MOVE_RIGHT:
                self.setUpDownDatetime(controlID)

                if self.selectionIsOffscreen(
                ) or 100 <= controlID <= self.gen.maxEnd:
                    return self.guideRight()
            elif action == xbmcgui.ACTION_MOVE_DOWN:
                if controlID > self.gen.maxEnd:
                    return self.guideNavDown()
            elif action == xbmcgui.ACTION_MOVE_UP:
                if controlID > self.gen.maxEnd:
                    return self.guideNavUp()
            elif action == xbmcgui.ACTION_PAGE_DOWN:
                if controlID > self.gen.maxEnd:
                    return self.guideNavDown(6)
            elif action == xbmcgui.ACTION_PAGE_UP:
                if controlID > self.gen.maxEnd:
                    return self.guideNavUp(6)
            elif action == xbmcgui.ACTION_NAV_BACK or action == xbmcgui.ACTION_PREVIOUS_MENU:
                WM.showMenu()
                return
        except:
            util.ERROR()

        kodigui.BaseWindow.onAction(self, action)
Exemplo n.º 12
0
    def settingList(cls, setting, *args):
        self = cls()
        if setting == 'engine':
            try:
                engines = urllib2.urlopen(self.httphost + 'engines/wav',
                                          data='').read().splitlines()
            except urllib2.HTTPError:
                return None
            except:
                util.ERROR('SpeechServerBackend: engines', hide_tb=True)
                self.failFlag = True
                return None

            ret = []
            for e in engines:
                ret.append(e.split('.', 1))
            return ret
        elif setting.startswith('voice.'):
            ret = []
            voices = self.voices(args[0])
            if not voices: return None
            for v in voices:
                v = v.split('.')[-1]
                ret.append((v, v))
            return ret
        return None
Exemplo n.º 13
0
    def onAction(self, action):
        try:
            if action.getId() in MOVE_SET:
                controlID = self.getFocusId()
                if controlID == self.POSTERS_PANEL_ID or controlID == self.SCROLLBAR_ID:
                    self.updateKey()
            elif action == xbmcgui.ACTION_CONTEXT_MENU:
                if not xbmc.getCondVisibility(
                        'ControlGroup({0}).HasFocus(0)'.format(
                            self.OPTIONS_GROUP_ID)):
                    self.setFocusId(self.OPTIONS_GROUP_ID)
                    return
            elif action in (xbmcgui.ACTION_NAV_BACK,
                            xbmcgui.ACTION_CONTEXT_MENU):
                if not xbmc.getCondVisibility(
                        'ControlGroup({0}).HasFocus(0)'.format(
                            self.OPTIONS_GROUP_ID)):
                    if xbmc.getCondVisibility(
                            'IntegerGreaterThan(Container(101).ListItem.Property(index),5)'
                    ):
                        self.setFocusId(self.OPTIONS_GROUP_ID)
                        return

            self.updateItem()

        except:
            util.ERROR()

        kodigui.MultiWindow.onAction(self, action)
Exemplo n.º 14
0
    def onAction(self, action):
        try:
            pass
        except:
            util.ERROR()

        kodigui.BaseDialog.onAction(self, action)
Exemplo n.º 15
0
    def onAction(self, action):
        try:
            self.updateKey(action)

            if action == xbmcgui.ACTION_NAV_BACK or action == xbmcgui.ACTION_PREVIOUS_MENU:
                if xbmc.getCondVisibility(
                        'ControlGroup({0}).HasFocus(0)'.format(
                            self.MENU_GROUP_ID)) or self.getProperty(
                                'hide.menu'):
                    WM.showMenu()
                    return
                else:
                    self.setFocusId(self.MENU_GROUP_ID)
                    return
            elif self.getFocusId() == self.SHOW_PANEL_ID:
                if action in (xbmcgui.ACTION_MOVE_UP, xbmcgui.ACTION_MOVE_DOWN,
                              xbmcgui.ACTION_MOVE_LEFT,
                              xbmcgui.ACTION_MOVE_RIGHT):
                    self.updateSelected()
            elif action == xbmcgui.ACTION_MOVE_RIGHT and self.getFocusId(
            ) == self.MENU_LIST_ID:
                self.onClick(self.MENU_LIST_ID)
        except:
            util.ERROR()

        kodigui.BaseWindow.onAction(self, action)
Exemplo n.º 16
0
    def onAction(self, action):
        controlID = self.getFocusId()
        try:
            if action == xbmcgui.ACTION_LAST_PAGE and xbmc.getCondVisibility(
                    'ControlGroup(300).HasFocus(0)'):
                self.next()
            elif action == xbmcgui.ACTION_NEXT_ITEM:
                self.next()
            elif action == xbmcgui.ACTION_FIRST_PAGE and xbmc.getCondVisibility(
                    'ControlGroup(300).HasFocus(0)'):
                self.prev()
            elif action == xbmcgui.ACTION_PREV_ITEM:
                self.prev()

            if controlID == self.TRACKS_LIST_ID:
                self.checkForHeaderFocus(action)
            if controlID == self.LIST_OPTIONS_BUTTON_ID and self.checkOptionsAction(
                    action):
                return
            elif action == xbmcgui.ACTION_CONTEXT_MENU:
                if not xbmc.getCondVisibility(
                        'ControlGroup({0}).HasFocus(0)'.format(
                            self.OPTIONS_GROUP_ID)):
                    self.setFocusId(self.OPTIONS_GROUP_ID)
                    return
            # elif action in(xbmcgui.ACTION_NAV_BACK, xbmcgui.ACTION_CONTEXT_MENU):
            #     if not xbmc.getCondVisibility('ControlGroup({0}).HasFocus(0)'.format(self.OPTIONS_GROUP_ID)):
            #         self.setFocusId(self.OPTIONS_GROUP_ID)
            #         return
        except:
            util.ERROR()

        kodigui.ControlledWindow.onAction(self, action)
Exemplo n.º 17
0
def getSkinPath():
    skin = currentKodiSkin()
    default = util.ADDON.getAddonInfo('path')
    if skin == 'skin.confluence':
        return default
    if skin not in FONT_TRANSLATIONS:
        return default
    if updateNeeded():
        util.DEBUG_LOG('Updating custom skin')
        try:
            setupDynamicSkin()

            for xml in SKINS_XMLS:
                customizeSkinXML(skin, xml)
            with open(VERSION_FILE, 'w') as f:
                f.write('{0}:{1}:{2}'.format(currentKodiSkin(), VERSION,
                                             OLD_API and ':old' or ''))
        except:
            util.ERROR()
            return default

    util.DEBUG_LOG('Using custom fonts for: {0}'.format(skin))

    return os.path.join(
        xbmc.translatePath(util.ADDON.getAddonInfo('profile')).decode('utf-8'),
        'skin')
Exemplo n.º 18
0
def search(deviceAuth, category='', terms=''):
    url = None
    if terms:
        url = SEARCH_URL.format(deviceAuth=urllib.quote(deviceAuth, ''),
                                search=urllib.quote(terms.encode('utf-8'), ''))
    elif category:
        url = SUGGEST_URL.format(deviceAuth=urllib.quote(deviceAuth, ''),
                                 category=category)

    if not url:
        util.DEBUG_LOG('Search: No category or terms')
        return

    util.DEBUG_LOG('Search URL: {0}'.format(url))

    req = requests.get(url)

    try:
        results = req.json()
        if not results: return []
        return [Series(r) for r in results]
    except:
        util.ERROR()

    return None
Exemplo n.º 19
0
    def onAction(self, action):
        try:
            if self.postPlayMode:
                self.cancelTimer()
                self.resetPassoutProtection()
                if action in (xbmcgui.ACTION_NAV_BACK,
                              xbmcgui.ACTION_CONTEXT_MENU):
                    if not xbmc.getCondVisibility(
                            'ControlGroup({0}).HasFocus(0)'.format(
                                self.OPTIONS_GROUP_ID)):
                        if not util.advancedSettings.fastBack or action == xbmcgui.ACTION_CONTEXT_MENU:
                            self.lastNonOptionsFocusID = self.lastFocusID
                            self.setFocusId(self.OPTIONS_GROUP_ID)
                            return

                if action in (xbmcgui.ACTION_NAV_BACK,
                              xbmcgui.ACTION_PREVIOUS_MENU):
                    self.doClose()
                    return

                if action in (xbmcgui.ACTION_NEXT_ITEM,
                              xbmcgui.ACTION_PLAYER_PLAY):
                    self.playVideo()
                elif action == xbmcgui.ACTION_PREV_ITEM:
                    self.playVideo(prev=True)
                elif action == xbmcgui.ACTION_STOP:
                    self.doClose()
        except:
            util.ERROR()

        kodigui.ControlledWindow.onAction(self, action)
Exemplo n.º 20
0
    def playVideo(self, prev=False):
        self.cancelTimer()
        try:
            if not self.next and self.playlist:
                if prev:
                    self.playlist.prev()
                self.aborted = False
                self.playQueue = self.playlist
                self.video = None
                self.play(handler=self.handler)
            else:
                video = self.next
                if prev:
                    video = self.prev

                if not video:
                    util.DEBUG_LOG(
                        'Trying to play next video with no next video available'
                    )
                    self.video = None
                    return

                self.playQueue = None
                self.video = video
                self.play(handler=self.handler)
        except:
            util.ERROR()
Exemplo n.º 21
0
 def runCommand(self, text, outFile):
     postdata = {
         'text': text.encode('utf-8')
     }  #TODO: This fixes encoding errors for non ascii characters, but I'm not sure if it will work properly for other languages
     if self.perlServer:
         postdata['voice'] = self.voice
         postdata['rate'] = self.remote_speed
         req = urllib2.Request(self.httphost + 'speak.wav',
                               urllib.urlencode(postdata))
     else:
         self.updatePostdata(postdata)
         req = urllib2.Request(self.httphost + 'wav',
                               urllib.urlencode(postdata))
     with open(outFile, "w") as wav:
         try:
             res = urllib2.urlopen(req)
             if not res.info().get('Content-Type') == 'audio/x-wav':
                 return False  #If not a wav we will crash XBMC
             shutil.copyfileobj(res, wav)
             self.failFlag = False
         except:
             err = util.ERROR('SpeechServerBackend: wav.write',
                              hide_tb=True)
             if self.failFlag:
                 self.flagAsDead(
                     reason=err
                 )  #This is the second fail in a row, mark dead
             self.failFlag = True
             return False
     return True
Exemplo n.º 22
0
    def valueLabel(self):
        try:
            import platform
            dist = platform.dist()
            if dist and len(dist) > 1:
                plat = u'{0} {1}'.format(dist[0], dist[1])
            else:
                plat = platform.platform()
                plat = u'{0} {1}'.format(plat[0],
                                         '.'.join(plat[1].split('.', 2)[:2]))
        except:
            util.ERROR()

        plat = plat.strip()

        if not plat:
            if xbmc.getCondVisibility('System.Platform.Android'):
                plat = 'Android'
            elif xbmc.getCondVisibility('System.Platform.OSX'):
                plat = 'OSX'
            elif xbmc.getCondVisibility('System.Platform.Darwin'):
                plat = 'Darwin'
            elif xbmc.getCondVisibility('System.Platform.Linux.RaspberryPi'):
                plat = 'Linux (RPi)'
            elif xbmc.getCondVisibility('System.Platform.Linux'):
                plat = 'Linux'
            elif xbmc.getCondVisibility('System.Platform.Windows'):
                plat = 'Windows'

        return plat or T(32411, 'Unknown')
Exemplo n.º 23
0
 def available(ext=None):
     if not sys.platform.startswith('win'): return False
     try:
         import winplay  #@analysis:ignore
         return True
     except:
         util.ERROR('winplay import failed', hide_tb=True)
     return False
Exemplo n.º 24
0
    def onAction(self, action):
        try:
            if action == xbmcgui.ACTION_NAV_BACK or action == xbmcgui.ACTION_PREVIOUS_MENU:
                self.abort = True
        except:
            util.ERROR()

        kodigui.BaseWindow.onAction(self, action)
Exemplo n.º 25
0
    def onAction(self, action):
        try:
            if action in (xbmcgui.ACTION_NAV_BACK, xbmcgui.ACTION_PREVIOUS_MENU):
                self.doClose()
        except:
            util.ERROR()

        kodigui.ControlledWindow.onAction(self, action)
Exemplo n.º 26
0
    def onPlayBackStarted(self):
        try:
            self.trickWindow.setPosition(self.absolutePosition)
            self.trickWindow.blank()
        except:
            util.ERROR()

        self.startWait()
Exemplo n.º 27
0
def skinningAPIisOld():
    try:
        return util.Version(
            util.xbmcaddon.Addon('xbmc.gui').getAddonInfo(
                'version')) < util.Version('5.2.0')
    except:
        util.ERROR()
        return False
Exemplo n.º 28
0
    def onAction(self, action):
        try:
            controlID = self.getFocusId()
            if self.checkSeekActions(action, controlID):
                return
        except:
            util.ERROR()

        kodigui.ControlledWindow.onAction(self, action)
Exemplo n.º 29
0
    def onAction(self, action):
        try:
            if action == xbmcgui.ACTION_NAV_BACK or action == xbmcgui.ACTION_PREVIOUS_MENU:
                # Close is handled in the window manager. We prevent it here because this stays open until all threads are finished
                return
        except:
            util.ERROR()

        kodigui.BaseWindow.onAction(self, action)
Exemplo n.º 30
0
    def onAction(self, action):
        try:
            if not xbmc.getCondVisibility('Player.HasMedia'):
                self.doClose()
                return
        except:
            util.ERROR()

        kodigui.BaseDialog.onAction(self, action)