def installKeyboardMod(update=True,paths=None,change=False): paths = ensureLocalSkin(paths) if change: yes = True else: yes = xbmcgui.Dialog().yesno(T(32496),T(32497),T(32498)) if yes: keyboardFile = chooseKeyboardFile(paths.fbPath,paths.currentSkin) if not keyboardFile: return True sourcePath = os.path.join(paths.fbPath,'keyboard',keyboardFile) LOG('Keyboard source path: %s' % sourcePath) copyKeyboardModImages(paths.localSkinPath) keyboardcontents = open(paths.dialogPath,'r').read() if not os.path.exists(paths.backupPath) or not 'Forum Browser' in keyboardcontents: LOG('Creating backup of original DialogKeyboard.xml file: ' + paths.backupPath) open(paths.backupPath,'w').write(open(paths.dialogPath,'r').read()) if not 'Forum Browser' in keyboardcontents or update: LOG('Replacing DialogKeyboard.xml with: ' + sourcePath) os.remove(paths.dialogPath) open(paths.dialogPath,'w').write(open(sourcePath,'r').read()) #if getSetting('FBIsRunning',True) and FBrunning: # dialogs.showMessage(T(32052),'',T(32499) + '[CR][CR]' + T(32477)) #else: dialogs.showMessage(T(32052),'',T(32499)) else: setSetting('keyboard_installed',False) dialogs.showMessage(T(32483),T(32521),' ',T(32522)) return True
def unInstallFont(paths=None): paths = paths or getPaths() if not os.path.exists(paths.fontBackupPath): return False if os.path.exists(paths.fontPath): xbmcvfs.delete(paths.fontPath) xbmcvfs.rename(paths.fontBackupPath,paths.fontPath) dialogs.showMessage(T(32417),T(32590)) return True
def getConfigs(): try: with open(configPath, 'r', encoding='utf-8') as configFile: config.read_file(configFile) poeDirectoryPath = config['Main']['PathOfExileDirectoryPath'] alertSoundPath = config['Audio']['AlertSoundPath'] except (KeyError, FileNotFoundError): config['Main'] = {'PathOfExileDirectoryPath': ''} config['Audio'] = {'AlertSoundPath': defaultAlertSoundPath} with open(configPath, 'w') as configFile: config.write(configFile) return getConfigs() with open(configPath, 'w', encoding='utf-8') as configFile: try: if not poeDirectoryPath or not Path(poeDirectoryPath).exists(): poeDirectoryPath = selectDirectoryDialog('Path of Exile') while not poeDirectoryIsValid(poeDirectoryPath): if not poeDirectoryPath: messagebox.showinfo('Map Alert', 'Path of Exile directory not selected, application closed.') return None showMessage('Invalid directory. Are you sure this is Path of Exile directory?') poeDirectoryPath = selectDirectoryDialog('Path of Exile') config['Main']['PathOfExileDirectoryPath'] = poeDirectoryPath if not alertSoundPath or not Path(alertSoundPath).exists(): alertSoundPath = defaultAlertSoundPath config['Audio']['AlertSoundPath'] = alertSoundPath finally: config.write(configFile) return poeDirectoryPath, alertSoundPath
def setProgress(self,pct,message=''): if pct<0: self.stopThread() dialogs.showMessage('ERROR',message,error=True) return False w = int((pct/100.0)*self._progressWidth) self.getControl(310).setWidth(w) self.getControl(104).setLabel(self.headerTextFormat % message) return True
def checkKBModRemove(skinPath): backupPath = getSkinFilePath(skinPath,'DialogKeyboard.xml.FBbackup') dialogPath = getSkinFilePath(skinPath,'DialogKeyboard.xml') if backupPath and dialogPath: xbmcvfs.delete(dialogPath) xbmcvfs.rename(backupPath,dialogPath) setSetting('keyboard_installed',False) dialogs.showMessage(T(32476),T(32476),' ',T(32477)) return True
def _selectAlertSound(): path = selectFileDialog('Alert Sound') if not path: return if not audioFileIsValid(path): showMessage('Selected file is not audio file.') _selectAlertSound() return setAlertSoundPath(path) writeConfig('Audio', 'AlertSoundPath', path)
def _selectPathOfExileDirectory(): path = selectDirectoryDialog('Path of Exile') if not path: return if not poeDirectoryIsValid(path): showMessage( 'Invalid directory. Are you sure this is Path of Exile directory?') _selectPathOfExileDirectory() return writeConfig('Main', 'PathOfExileDirectoryPath', path)
def installFont(paths=None,update=False): paths = ensureLocalSkin(paths) copyFont(paths.sourceFontPath,paths.localSkinPath) fontcontents = open(paths.fontPath,'r').read() if not os.path.exists(paths.fontBackupPath) or not 'Forum Browser' in fontcontents: LOG('Creating backup of original Font.xml file: ' + paths.fontBackupPath) open(paths.fontBackupPath,'w').write(fontcontents) if not 'Forum Browser' in fontcontents or update: LOG('Modifying contents of Font.xml with: ' + paths.sourceFontXMLPath) if os.path.exists(paths.fontBackupPath): #because we're updating original = open(paths.fontBackupPath,'r').read() else: original = open(paths.fontPath,'r').read() modded = original.replace('<font>',open(paths.sourceFontXMLPath,'r').read() + '<font>',1) open(paths.fontPath,'w').write(modded) dialogs.showMessage(T(32052),'',T(32495))
def ensureLocalSkin(paths=None): paths = paths or getPaths() version = getSkinVersion(paths.skinPath) version2 = getSkinVersion(paths.localSkinPath) if not os.path.exists(paths.localSkinPath) or Version(version2) < Version(version): yesno = xbmcgui.Dialog().yesno(T(32486),T(32487).format(paths.currentSkin),T(32488),T(32489)) if not yesno: return dialog = xbmcgui.DialogProgress() dialog.create(T(32490),T(32491)) try: copyTree(paths.skinPath,paths.localSkinPath,dialog) except: err = ERROR('Failed to copy skin to user directory') dialogs.showMessage(T(32050),err,T(32492),error=True) return finally: dialog.close() #restart = True dialogs.showMessage(T(32304),T(32493),T(32494),success=True) return getPaths() else: return paths