def checkNewVersion(self): try: #Fails on Helix beta 1 on OpenElec #1103 from distutils.version import LooseVersion except ImportError: def LooseVersion(v): comp = [int(x) for x in re.split(r'a|b',v)[0].split(".")] fourth = 2 fifth = 0 if 'b' in v: fourth = 1 fifth = int(v.split('b')[-1] or 0) elif 'a' in 'v': fourth = 0 fifth = int(v.split('a')[-1] or 0) comp.append(fourth) comp.append(fifth) return comp lastVersion = util.getSetting('version','0.0.0') util.setSetting('version',__version__) if lastVersion == '0.0.0': self.firstRun() return True elif LooseVersion(lastVersion) < LooseVersion(__version__): self.queueNotice(u'{0}... {1}'.format(T(32104),__version__)) return True return False
def preInstalledFirstRun(): if not util.isPreInstalled(): #Do as little as possible if there is no pre-install if util.wasPreInstalled(): util.LOG('PRE INSTALL: REMOVED') # Set version to 0.0.0 so normal first run will execute and fix the keymap util.setSetting('version','0.0.0') import enabler enabler.markPreOrPost() # Update the install status return False import enabler lastVersion = util.getSetting('version') if not enabler.isPostInstalled() and util.wasPostInstalled(): util.LOG('POST INSTALL: UN-INSTALLED OR REMOVED') # Add-on was removed. Assume un-installed and treat this as a pre-installed first run to disable the addon elif lastVersion: enabler.markPreOrPost() # Update the install status return False # Set version to 0.0.0 so normal first run will execute on first enable util.setSetting('version','0.0.0') util.LOG('PRE-INSTALLED FIRST RUN') util.LOG('Installing basic keymap') # Install keymap with just F12 enabling included from lib import keymapeditor keymapeditor.installBasicKeymap() util.LOG('Pre-installed - DISABLING') enabler.disableAddon() return True
def renameDevice(): import xbmcgui from lib import devices from lib import pbclient from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('pb_client_iden'),util.getSetting('pb_client_nickname')) if not dev or not dev.ID: xbmcgui.Dialog().ok(localise(32076),localise(32077)) name = xbmcgui.Dialog().input('{0}:'.format(localise(32078)),dev.name or '') if not name: return if name == dev.name: return token = util.getSetting('pb_access_token') client = pbclient.Client(token) while deviceNameExists(client,name): name = xbmcgui.Dialog().input(localise(32079),dev.name or '') if not name: return if name == dev.name: return if not token: xbmcgui.Dialog().ok(localise(32068),localise(32080),localise(32081)) return try: if client.updateDevice(dev,nickname=name): util.setSetting('pb_client_nickname',dev.name) xbmcgui.Dialog().ok(localise(32062),'{0}: '.format(localise(32082)),'',dev.name) except pbclient.PushbulletException, e: showError(e.message)
def renameDevice(): import xbmcgui from lib import devices from lib import PushbulletTargets from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('device_iden'), util.getSetting('device_name')) if not dev or not dev.ID: xbmcgui.Dialog().ok(T(32076), T(32077)) name = xbmcgui.Dialog().input('{0}:'.format(T(32078)), dev.name or '') if not name: return if name == dev.name: return token = util.getSetting('token') client = PushbulletTargets.Client(token) while deviceNameExists(client, name): name = xbmcgui.Dialog().input(T(32079), dev.name or '') if not name: return if name == dev.name: return if not token: xbmcgui.Dialog().ok(T(32068), T(32080), T(32081)) return try: if client.updateDevice(dev, nickname=name): util.setSetting('device_name', dev.name) xbmcgui.Dialog().ok(T(32062), '{0}: '.format(T(32082)), '', dev.name) except PushbulletTargets.PushbulletException, e: showError(e.message)
def viewTypeButtonClicked(self): win = self.nextWindow() key = self.section.key if not key.isdigit(): key = self.section.getLibrarySectionId() util.setSetting( 'viewtype.{0}.{1}'.format(self.section.server.uuid, key), win.VIEWTYPE)
def volumeDown(self): if not self.settings or not 'volume' in self.settings: return util.T(32180) vol = self.setting('volume') vol -= self.volumeStep if vol < self.volumeExternalEndpoints[0]: vol = self.volumeExternalEndpoints[0] util.setSetting('{0}.{1}'.format('volume',self.provider),vol) if util.DEBUG: util.LOG('Volume DOWN: {0}'.format(vol)) return u'{0} {1}'.format(vol,self.volumeSuffix)
def volumeDown(self): if not self.settings or not 'volume' in self.settings: return util.T(32180) vol = self.setting('volume') vol -= self.volumeStep if vol < self.volumeExternalEndpoints[0]: vol = self.volumeExternalEndpoints[0] util.setSetting('{0}.{1}'.format('volume', self.provider), vol) if util.DEBUG: util.LOG('Volume DOWN: {0}'.format(vol)) return u'{0} {1}'.format(vol, self.volumeSuffix)
def selectDevice(): from lib import gui, PushbulletTargets token = util.getSetting('token') client = PushbulletTargets.Client(token) ID = gui.selectDevice(client, extra=T(32083)) if ID == None: return util.setSetting('selected_device', ID)
def selectDevice(): from lib import gui, pbclient token = util.getSetting('pb_access_token') client = pbclient.Client(token) ID = gui.selectDevice(client, extra=localise(32083)) if ID == None: return util.setSetting('selected_device', ID)
def selectDevice(): from lib import gui, pbclient token = util.getSetting('pb_access_token') client = pbclient.Client(token) ID = gui.selectDevice(client,extra=localise(32083)) if ID == None: return util.setSetting('selected_device',ID)
def selectDevice(): from lib import gui, PushbulletTargets token = util.getSetting('token') client = PushbulletTargets.Client(token) ID = gui.selectDevice(client,extra=T(32083)) if ID == None: return util.setSetting('selected_device',ID)
def selectVoice(): import xbmcgui b = getBackend()() voices = b.voices() if not voices: xbmcgui.Dialog().ok('Not Available','No voices to select.') return idx = xbmcgui.Dialog().select('Choose Voice',voices) if idx < 0: return voice = voices[idx] util.LOG('Voice for {0} set to: {1}'.format(b.provider,voice)) util.setSetting('voice.{0}'.format(b.provider),voice) util.setSetting('voice',voice)
def setEngine(self,provider,wav_stream=False): if not provider: if self.backend: return else: if self.backend and self.backend.provider == provider: return if wav_stream: backend = backends.getWavStreamBackend(provider) else: backend = backends.getBackend(provider) if backend and (not self.backend or backend.provider != self.backend.provider): if self.backend: self.backend._close() if self.preferred_player: util.setSetting('player.' + provider, self.preferred_player) self.backend = backend() self.backend.setWavStreamMode()
def set(self, val): old = self.get() if old != val: util.DEBUG_LOG('Setting: {0} - changed from [{1}] to [{2}]'.format( self.ID, old, val)) plexnet.plexapp.APP.trigger('change:{0}'.format(self.ID)) return util.setSetting(self.ID, val)
deviceMap[d['iden']] = d['nickname'] except pbclient.PushbulletException, e: showError(e.message) return idx = xbmcgui.Dialog().select(localise(32071),deviceMap.values() + [localise(32072)]) if idx < 0: return dev = devices.KodiDevice(None,util.getSetting('pb_client_nickname') or None) if idx == len(deviceMap): if not addNewDevice(client,dev): return else: dev.ID = deviceMap.keys()[idx] dev.name = deviceMap.values()[idx] or dev.name util.setSetting('pb_client_iden',dev.ID) util.setSetting('pb_client_nickname',dev.name) util.LOG('DEVICE LINKED: {0}'.format(dev.name)) xbmcgui.Dialog().ok(localise(32073), '{0}: '.format(localise(32074)), ' [B]{0}[/B]'.format(dev.name), localise(32075)) def renameDevice(): import xbmcgui from lib import devices from lib import pbclient from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('pb_client_iden'),util.getSetting('pb_client_nickname')) if not dev or not dev.ID: xbmcgui.Dialog().ok(localise(32076),localise(32077)) name = xbmcgui.Dialog().input('{0}:'.format(localise(32078)),dev.name or '') if not name: return
def saveToken(token): util.setSetting('pb_access_token', token)
def _saveSettings(self): jsonString = json.dumps(self._settings) util.setSetting('library.settings.{0}'.format(self.serverID), jsonString)
showError(e.message) return idx = xbmcgui.Dialog().select(localise(32071), deviceMap.values() + [localise(32072)]) if idx < 0: return dev = devices.KodiDevice(None, util.getSetting('pb_client_nickname') or None) if idx == len(deviceMap): if not addNewDevice(client, dev): return else: dev.ID = deviceMap.keys()[idx] dev.name = deviceMap.values()[idx] or dev.name util.setSetting('pb_client_iden', dev.ID) util.setSetting('pb_client_nickname', dev.name) util.LOG('DEVICE LINKED: {0}'.format(dev.name)) xbmcgui.Dialog().ok(localise(32073), '{0}: '.format(localise(32074)), ' [B]{0}[/B]'.format(dev.name), localise(32075)) def renameDevice(): import xbmcgui from lib import devices from lib import pbclient from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('pb_client_iden'), util.getSetting('pb_client_nickname')) if not dev or not dev.ID:
def saveToken(token): util.setSetting('pb_access_token',token)
def saveToken(token): util.setSetting('token', token)
def saveToken(token): util.setSetting('token',token)
def setVoice(self,voice): if not self.backend or not voice or not '.' in voice: return provider, voice = voice.split('.',1) if provider != self.backend.provider: return util.setSetting('voice.' + provider, voice)
deviceMap[d['iden']] = d['nickname'] except PushbulletTargets.PushbulletException, e: showError(e.message) return idx = xbmcgui.Dialog().select(T(32071), deviceMap.values() + [T(32072)]) if idx < 0: return dev = devices.KodiDevice(None, util.getSetting('device_name') or None) if idx == len(deviceMap): if not addNewDevice(client, dev): return else: dev.ID = deviceMap.keys()[idx] dev.name = deviceMap.values()[idx] or dev.name util.setSetting('device_iden', dev.ID) util.setSetting('device_name', dev.name) util.LOG('DEVICE LINKED: {0}'.format(dev.name)) xbmcgui.Dialog().ok(T(32073), '{0}: '.format(T(32074)), ' [B]{0}[/B]'.format(dev.name), T(32075)) def renameDevice(): import xbmcgui from lib import devices from lib import PushbulletTargets from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('device_iden'), util.getSetting('device_name')) if not dev or not dev.ID:
def saveCurrent(self): if not self.current: return util.setSetting('window.last', self.current.name)
def setRate(self,rate): if not rate: return if not strIsNumber(rate): return rate = self.backend.scaleSpeed(int(rate),20) util.setSetting('speed.' + self.backend.provider, rate)
def mostRecentUpdated(self, modified): util.setSetting('most_recent', '{0:10f}'.format(modified))
def _setSetting(self,key,value): util.setSetting('youtube_{0}'.format(key),self.value)
deviceMap[d['iden']] = d['nickname'] except PushbulletTargets.PushbulletException, e: showError(e.message) return idx = xbmcgui.Dialog().select(T(32071),deviceMap.values() + [T(32072)]) if idx < 0: return dev = devices.KodiDevice(None,util.getSetting('device_name') or None) if idx == len(deviceMap): if not addNewDevice(client,dev): return else: dev.ID = deviceMap.keys()[idx] dev.name = deviceMap.values()[idx] or dev.name util.setSetting('device_iden',dev.ID) util.setSetting('device_name',dev.name) util.LOG('DEVICE LINKED: {0}'.format(dev.name)) xbmcgui.Dialog().ok(T(32073), '{0}: '.format(T(32074)), ' [B]{0}[/B]'.format(dev.name), T(32075)) def renameDevice(): import xbmcgui from lib import devices from lib import PushbulletTargets from lib import util dev = devices.getDefaultKodiDevice(util.getSetting('device_iden'),util.getSetting('device_name')) if not dev or not dev.ID: xbmcgui.Dialog().ok(T(32076),T(32077)) name = xbmcgui.Dialog().input('{0}:'.format(T(32078)),dev.name or '') if not name: return
def setPitch(self,pitch): if not pitch: return if not strIsNumber(pitch): return pitch = self.backend.scalePitch(int(pitch),50) util.setSetting('pitch.' + self.backend.provider, pitch)
def mostRecentUpdated(self,modified): util.setSetting('most_recent','{0:10f}'.format(modified))
def setBackend(self, backend): if self.tts: self.tts.close() self.tts = backend util.setSetting("voice", self.tts.currentVoice())
def setVolume(self,volume): if not volume: return if not strIsNumber(volume): return volume = self.backend.scaleVolume(int(volume),12) util.setSetting('volume.' + self.backend.provider, volume)
def savePassword(key,user,password): setSetting(key,encryptPassword(user,password))