def ExecuteActionRedirect(self, oAction: cAction) -> eReturnCode: """ WikiDoc:Doc WikiDoc:Context:ActionsDetails WikiDoc:Page:Actions-Redirect WikiDoc:TOCTitle: redirect = redirect = Redirects a xml file to load to a new xml file. Purpose of this action is, to replace elements (standard / Skin / definition) by a customized element This action will not modify the error code <div style="overflow:auto; "> {| border=1 class="wikitable" ! align="left" | string ! align="left" | from ! align="left" | to |- |redirect |Full path and filename to the xml file which should be replaced |Full path and filename to the replacement file |}</div> WikiDoc:End """ oFrom: cFileName = cFileName("").ImportFullPath( uFnFullName=oAction.dActionPars.get("from", "")) oTo: cFileName = cFileName("").ImportFullPath( uFnFullName=oAction.dActionPars.get("to", "")) self.oEventDispatcher.LogAction(uTxt=u'Redirect', oAction=oAction) Globals.oTheScreen.oSkin.dSkinRedirects[oFrom.string] = oTo return eReturnCode.Nothing
def __init__(self, **kwargs): self.oLayout = FloatLayout(size_hint=(1, 1)) super(SettingPicture, self).__init__(**RemoveNoClassArgs(kwargs, SettingFile)) try: oFnPic = cFileName().ImportFullPath(self.value) self.oPic = Image(source=UnEscapeUnicode(ToAtlas(oFnPic)), size_hint=(1, 1), pos_hint={ 'x': 0.0, 'y': 0.0 }) oFnBack = cFileName(Globals.oPathResources + "pics") + "imagepicker_background.png" self.oBack = Image(source=ToAtlas(oFnBack), size_hint=(1, 1), pos_hint={ 'x': 0.0, 'y': 0.0 }) self.oLayout.add_widget(self.oBack) self.oLayout.add_widget(self.oPic) self.add_widget(self.oLayout) self.content.children[1].text = '' except Exception as e: uMsg = u'Settings: Picture: can\'t load image file: ' + ToUnicode( e) + " " + oFnPic Logger.error(uMsg)
def __init__(self): self.uName = u'' self.oFnNormal = cFileName(u'') self.oFnBold = cFileName(u'') self.oFnItalic = cFileName(u'') self.oFnBoldItalic = cFileName(u'')
def Init(self,uScriptName,oFnScript=None): """ Initializes the script """ self.bIsInit = True self.uScriptName = uScriptName if oFnScript is None: oFnScriptPy = cFileName(Globals.oScripts.dScriptPathList[self.uScriptName]) + u'script.py' oFnScript = cFileName(oFnScriptPy) self.oFnScript = cFileName(oFnScript) self.oPathMyCode = Globals.oScripts.dScriptPathList[self.uScriptName] self.oPathMy = Globals.oDefinitionPathes.oPathDefinitionScriptSettings+self.uScriptName self.oResultParser = cScriptResultParser(self) self.oFnAction = cFileName(self.oPathMyCode+"actions")+"customactions.xml" if not self.oPathMy.Exists(): self.oPathMy.Create() self.oScriptConfig = cScriptConfig(self) self.oScriptConfig.Init() Globals.oLanguage.LoadXmlFile("SCRIPT", uScriptName) self.oFnConfig = cFileName(self.oPathMy) +'config.ini' oRepManagerEntry=cRepManagerEntry(oFnScript) if oRepManagerEntry.ParseFromSourceFile(): self.iMyVersion = oRepManagerEntry.oRepEntry.iVersion self.iOrcaVersion = oRepManagerEntry.oRepEntry.iMinOrcaVersion Globals.oNotifications.RegisterNotification("on_stopapp",self.DeInit,"Script:"+self.uScriptName) Globals.oNotifications.RegisterNotification("on_pause",self.OnPause,"Script:"+self.uScriptName) Globals.oNotifications.RegisterNotification("on_resume",self.OnResume,"Script:"+self.uScriptName) self.ShowDebug(u'Init')
def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor): """ Reads further Widget attributes from a xml node """ bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor) if bRet: self.oFnPictureNormal = cFileName(u'').ImportFullPath( GetXMLTextAttributeVar(oXMLNode, u'picturenormal', False, u'')) self.oFnPictureButton = cFileName(u'').ImportFullPath( GetXMLTextAttributeVar(oXMLNode, u'picturebutton', False, u'')) self.fMin = GetXMLTextAttribute(oXMLNode, u'mindatavalue', False, u'0.0') self.fMax = GetXMLTextAttribute(oXMLNode, u'maxdatavalue', False, u'100.0') self.uDestVar = GetXMLTextAttribute(oXMLNode, u'destvar', False, self.uDestVar) #roundpos: the position, the number should be rounded self.iRoundPos = GetXMLIntAttribute(oXMLNode, u'roundpos', False, 0) self.uDeviceOrientation = GetXMLTextAttribute( oXMLNode, u'orientation', False, self.uDeviceOrientation) self.bDiscardMoves = GetXMLBoolAttributeVar( oXMLNode, u'discardmoves', False, False) self.fValue = self.fMin return bRet
def __init__(self,**kwargs): super(cWidgetButton, self).__init__(hastext=True) self.oFnButtonPictureNormal = cFileName('') self.oFnButtonPicturePressed = cFileName('') self.bAutoHide = False # Disabled reserved for future self.oFnButtonPictureDisabled = cFileName('') self.ClassName = cTouchButton
def __init__(self, **kwargs): super().__init__() self.oFnButtonPictureNormal: cFileName = cFileName('') self.oFnButtonPicturePressed: cFileName = cFileName('') self.bAutoHide: bool = False # Disabled reserved for future self.oFnButtonPictureDisabled: cFileName = cFileName('') self.ClassName: Callable = cTouchButton
def Init(self) -> None: """ Implicitly initializes the language object :return: """ self.oFnLanguagePrimary = cFileName(Globals.oPathLanguageRoot + Globals.uLanguage) + u'strings.xml' self.oFnLanguageEnglish = cFileName(Globals.oPathLanguageRoot + u'English') + u'strings.xml' self.oFnLanguageFallBackPrimary = cFileName(Globals.oPathAppReal + u'languages/'+ Globals.uLanguage) + u'strings.xml' self.oFnLanguageFallBackEnglish = cFileName(Globals.oPathAppReal + u'languages/English') + u'strings.xml'
def orca_et_loader( uFile: str, uParse: str, uEncoding: str = "xml", oReplacementVars: Optional[cDefinitionVars] = None) -> List[Element]: """Custom Loader for ElementTree Include to add definition path to includes and to make make bulk include using placeholder possible """ aRet: List[Element] = [] aFiles: List[cFileName] = [] oFn: cFileName uRaw: str oFnLoad: cFileName oFnLoadFileRedirect: Union[cFileName, None] uBaseName: str oFn: cFileName oElement: Element uFnFileShort: str if oReplacementVars is None: oReplacementVars = cDefinitionVars() if "*" in uFile or "?" in uFile: oFn = cFileName("").ImportFullPath(uFnFullName=uFile) oDir: cPath = oFn.oPath aFolderFiles = oDir.GetFileList(bFullPath=True, bSubDirs=False) for uFolderFile in aFolderFiles: if MatchWildCard(uValue=uFolderFile, uMatchWithWildCard=oFn.string): aFiles.append( cFileName("").ImportFullPath(uFnFullName=uFolderFile)) else: oFn = cFileName("").ImportFullPath(uFnFullName=uFile) if oFn.Exists(): aFiles.append(cFileName("").ImportFullPath(uFnFullName=uFile)) else: Logger.debug(u'XML: Skipping XML Include (File not found):' + oFn.string) for oFnLoad in aFiles: oFnLoadFileRedirect = Globals.oTheScreen.oSkin.dSkinRedirects.get( oFnLoad.string) if oFnLoadFileRedirect is not None: oFnLoad = oFnLoadFileRedirect Logger.debug(u'XML: Loading XML Include:' + oFnLoad) #uRaw= ElementInclude.default_loader(uLoadFile, "text", encoding) uRaw = CachedFile(oFileName=oFnLoad) uRaw = ReplaceDefVars(uRaw, oReplacementVars) aRet.append(fromstring(uRaw)) uFnFileShort = ShortenFileName(uFnFile=oFnLoad.string) if aRet[-1].get("linefilename", "") == "": aRet[-1].set("linefilename", uFnFileShort) for oElement in aRet[-1]: oElement.set("linefilename", uFnFileShort) return aRet
def InitWidgetFromXml(self,oXMLNode,oParentScreenPage, uAnchor): """ Reads further Widget attributes from a xml node """ bRet=super(cWidgetSwitch, self).InitWidgetFromXml(oXMLNode,oParentScreenPage, uAnchor) self.uDestVar = GetXMLTextAttribute(oXMLNode,u'destvar', False,self.uName+'_switchstate') self.uGroup = GetXMLTextAttribute(oXMLNode,u'group', False,'') self.oFnButtonPictureNormalOrg = cFileName(self.oFnButtonPictureNormal) self.oFnButtonPicturePressedOrg = cFileName(self.oFnButtonPicturePressed) if GetVar(uVarName = self.uDestVar)=='1': self.oFnButtonPictureNormal,self.oFnButtonPicturePressed=self.oFnButtonPicturePressed,self.oFnButtonPictureNormal return bRet
def GetJsonFromSettingFileName(uSettingFileName: str) -> str: oFnSetting: cFileName = cFileName( Globals.oPathAppReal + "ORCA/settings/settingstrings") + uSettingFileName if not oFnSetting.Exists(): oFnSetting: cFileName = cFileName( Globals.oPathApp + "ORCA/settings/settingstrings") + uSettingFileName return ReplaceVars(LoadFile(oFileName=oFnSetting))
def OnFailure(self, request, result): """ Handle an FTP Failure event """ self.bFinished = True self.bOnError = True cFileName('').ImportFullPath(self.uDest).Delete() LogError(u'can\'t load online resource: %s to %s [%s]' % (self.uUrl, self.uDest, result)) self.OnSuccess(None, None) self.bIsLoading = False SetVar(uVarName="DOWNLOADERROR", oVarValue="1") StopWait() return
def Linux_GetDataDir(): """ tries to find an already installed data folder and sets a default, if none has been found """ uRootPath = u"/" Logger.debug("Linux Root Folder = " + uRootPath) uSubDir = u'OrcaRemote' uUserDataDir = OS_GetUserDownloadsDataPath() try: uUserDataDir = Globals.oApp.user_data_dir except: pass # First try to Find existing Orca Data Dir aTestDirs = [ cPath(uUserDataDir) + uSubDir, cPath(OS_GetUserDownloadsDataPath()) + uSubDir, cPath(uRootPath) + uSubDir, cPath(os.getcwd()) ] for oTestDir in aTestDirs: Logger.debug(u"Try to find Orca installations file at: " + oTestDir.string) if (cFileName(cPath(oTestDir) + 'actions') + 'actions.xml').Exists(): Logger.debug(u"Found Orca installations file at " + oTestDir.string) return oTestDir # First try to Find existing Orca Data Dir for oTestDir in aTestDirs: Logger.debug(u"Try to find Orca installations file (Fallback) at: " + oTestDir.string) if (cFileName(cPath(oTestDir) + 'actions') + 'actionsfallback.xml').Exists(): Logger.debug(u"Found Orca installations file (Fallback) at " + oTestDir.string) return oTestDir # if we haven't found anything try to find the best writable location Logger.error(u"Haven't found Orca installations file") for oTestDir in aTestDirs: if oTestDir.IsWritable(): Logger.debug(u"Fallback: Trying Orca installations file at: " + oTestDir.string) return oTestDir #if we are here, we failed return cPath(OS_GetUserDownloadsDataPath() + uSubDir)
def __init__(self, **kwargs): super(cWidgetSlider, self).__init__(hastext=True) self.oFnPictureNormal = cFileName(u'') self.oFnPictureButton = cFileName(u'') self.uDestVar = u'slider' self.uDeviceOrientation = u'horizontal' self.bDiscardMoves = True self.fMin = 0.0 self.fMax = 100.0 self.fValue = 0.0 self.fOldValue = 10000.23445 self.fDataRange = 100.0 self.iRoundPos = 0
def SaveRepositoryXML(self,uType:str,uDescription:str) -> None: """ Saves the main repository directory xml """ oVal:Element uContent:str uRoot:str oPath:cPath= Globals.oPathTmp + "RepManager" oPath.Create() oPath=oPath+"repositories" oPath.Create() oPath=oPath+uType oPath.Create() oFnXml:cFileName=cFileName(oPath) +'repository.xml' oXMLRoot:Element = Element('repository') oVal = SubElement(oXMLRoot,'version') oVal.text = '1.00' oVal = SubElement(oXMLRoot,'type') oVal.text = uType oVal = SubElement(oXMLRoot,'description') oVal.text = uDescription oXMLEntries:Element = SubElement(oXMLRoot,'entries') for oEntry in self.aRepManagerEntries: Logger.debug ('Saving Repository-Entry [%s]' % oEntry.oFnEntry.string) oEntry.oRepEntry.WriteToXMLNode(oXMLNode=oXMLEntries) for oSource in oEntry.oRepEntry.aSources: bZipParentDir:bool = cPath.CheckIsDir(uCheckName=oSource.uLocal) # Create according Zip if bZipParentDir: uUpper:str = os.path.basename(oSource.uSourceFile) uFinalPath:str = uType oDest:cFileName = cFileName().ImportFullPath(uFnFullName='%s/RepManager/repositories/%s/%s' % (Globals.oPathTmp.string, uFinalPath, uUpper)) uUpper1:str = os.path.split(os.path.abspath(oSource.uLocal))[0] uRoot = AdjustPathToOs(uPath=ReplaceVars(uUpper1)+'/') self.aZipFiles.append({'filename':oSource.uLocal,'dstfilename':oDest.string, 'removepath':uRoot, 'skipfiles':ToUnicode(oEntry.oRepEntry.aSkipFileNames)}) else: uDest:str = AdjustPathToOs(uPath='%s/RepManager/repositories/%s/%s.zip' % (Globals.oPathTmp.string, uType, os.path.splitext(os.path.basename(oSource.uLocal))[0])) uRoot = AdjustPathToOs(uPath=Globals.oPathRoot.string + "/" + oSource.uTargetPath) self.aZipFiles.append({'filename':oSource.uLocal,'dstfilename':uDest, 'removepath':uRoot}) oFSFile = open(oFnXml.string, 'w') uContent = XMLPrettify(oElem=oXMLRoot) uContent = ReplaceVars(uContent) oFSFile.write(EscapeUnicode(uContent)) oFSFile.close()
def OnProgress(self, request, lCurrentSize, lTotalSize): """ Updates the progressbar """ if not self.oProgressBar is None: if self.bFirstMessage: self.bFirstMessage = False self.oProgressBar.SetMax(lTotalSize) if self.oProgressBar.bCancel: self.bFinished = True self.bOnError = True cFileName('').ImportFullPath(self.uDest).Delete() self.OnSuccess(None, None) return self.oProgressBar.Update(lCurrentSize)
def LoadScriptList(self, oPath=None): """ loads a list of all scripts """ if oPath is None: oPath = Globals.oPathScripts if oPath == Globals.oPathScripts: Logger.debug(u'Scripts: Loading Script List') aScriptNameList = oPath.GetFolderList() for uScriptNameFolder in aScriptNameList: oFolderPath = cPath(oPath) + uScriptNameFolder if (cFileName(oFolderPath) + "script.py").Exists(): self.aScriptNameList.append(uScriptNameFolder) self.dScriptPathList[uScriptNameFolder] = oFolderPath else: self.LoadScriptList(oPath=oFolderPath) if oPath == Globals.oPathScripts: self.aScriptNameList.sort(key=lambda x: x) for uScriptName in self.aScriptNameList: SetVar(uVarName="SCRIPTPATH[%s]" % uScriptName, oVarValue=self.dScriptPathList[uScriptName].string) oPathScriptSkinElements = self.dScriptPathList[ uScriptName] + "elements" oPathCheck = oPathScriptSkinElements + ("skin_" + Globals.uSkinName) if oPathCheck.Exists(): oPathScriptSkinElements = oPathCheck else: oPathScriptSkinElements = oPathScriptSkinElements + "skin_default" SetVar(uVarName="SCRIPTPATHSKINELEMENTS[%s]" % (uScriptName), oVarValue=oPathScriptSkinElements.string)
def ConvertItach2CCF(self): #todo : remove when we know, it is not used anymore from ORCA.utils.XML import GetXMLTextAttribute import codecs aFiles = Globals.oPathCodesets.GetFolderList() aFiles2 = [] for uFile in aFiles: if uFile.startswith("CODESET_iTach_"): aFiles2.append(uFile) for uFile in aFiles2: oFile = cFileName(Globals.oPathCodesets) + uFile oXMLCodeset = ElementTree(file=oFile.string).getroot() oXMLCodes = oXMLCodeset.findall('code') for oXMLCode in oXMLCodes: uCmd = GetXMLTextAttribute(oXMLCode, "cmd", False, "") if uCmd.startswith("sendir,"): uRepeat, uCmd = ITach2CCF(uCmd) oXMLCode.set("cmd_ccf", uCmd) oXMLCode.set("repeatcount", uRepeat) del oXMLCode.attrib["cmd"] uFileName = oFile.string.replace("_iTach_", "_infrared_ccf_") uFinal = ToUnicode(XMLPrettify(oXMLCodeset)) uFinal = uFinal.replace(u'<?xml version="1.0"?>', u'<?xml version="1.0" encoding="UTF-8"?>') with codecs.open(uFileName, 'w', 'utf-8') as outfile: outfile.write(uFinal)
def LanguageChange(self) -> None: """ changes the filename of the definition language file :return: """ self.oFnDefinitionLanguage = cFileName(self.oPathDefinition + (u'languages/' + Globals.uLanguage)) + u'strings.xml' return None
def _ReadCodeset(self, uFN): del self.aCodesetCmds[:] try: oXMLCodeset = LoadXMLFile(cFileName(Globals.oPathCodesets) + uFN) Orca_include(oXMLCodeset, orca_et_loader) if oXMLCodeset is not None: # First read imported codesets oXMLImports = oXMLCodeset.find('imports') if oXMLImports is not None: oXMLImportCodesets = oXMLImports.find('codeset') if oXMLImportCodesets is not None: oXMLImportCodes = oXMLImportCodesets.findall('code') for oXMLCode in oXMLImportCodes: uCmd = GetXMLTextAttribute(oXMLCode, 'action', False, '') if uCmd: self.aCodesetCmds.append(uCmd) oXMLCodes = oXMLCodeset.findall('code') for oXMLCode in oXMLCodes: uCmd = GetXMLTextAttribute(oXMLCode, 'action', False, '') if uCmd: self.aCodesetCmds.append(uCmd) except Exception as e: LogError('Error Reading Codeset', e)
def Init(self): """ Init function, sets the configuration file name and add the default sections """ self.oFnConfig = cFileName(self.oScript.oPathMy) + u'config.ini' if not self.oFnConfig.Exists(): self.oConfigParser.filename = self.oFnConfig.string self.CreateSection(uSectionName=self.uDefaultConfigName)
def ConvertItach2CCF(self) -> None: #todo : remove when we know, it is not used anymore oXMLCode: Element uFile: str uCmd: str uRepeat: str uFileName: str uFinal: str aFiles: List[str] = Globals.oPathCodesets.GetFolderList() aFiles2: List[str] = [] for uFile in aFiles: if uFile.startswith("CODESET_iTach_"): aFiles2.append(uFile) for uFile in aFiles2: oFile: cFileName = cFileName(Globals.oPathCodesets) + uFile oXMLCodeset: Element = LoadXMLFile(oFile=oFile) oXMLCodes: List[Element] = oXMLCodeset.findall('code') for oXMLCode in oXMLCodes: uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode, uTag="cmd", bMandatory=False, vDefault="") if uCmd.startswith("sendir,"): uRepeat, uCmd = ITach2CCF(uCmd) oXMLCode.set("cmd_ccf", uCmd) oXMLCode.set("repeatcount", uRepeat) del oXMLCode.attrib["cmd"] uFileName = oFile.string.replace("_iTach_", "_infrared_ccf_") uFinal = ToUnicode(XMLPrettify(oElem=oXMLCodeset)) uFinal = uFinal.replace(u'<?xml version="1.0"?>', u'<?xml version="1.0" encoding="UTF-8"?>') with codecs.open(uFileName, 'w', 'utf-8') as oOutfile: oOutfile.write(uFinal)
def ReadItachFunctionTranslation(self) -> None: """ Reads the translation set from IRDB to ORCA """ oSet: Element oCommand: Element if len(self.dTranslations) == 0: oFnTranslation: cFileName = cFileName( Globals.oPathResources + u"irdbtranslation") + u"itach2orca.xml" try: Logger.debug(u'IRDB: Loading Translation Table:' + oFnTranslation.string) oET_Root: Element = LoadXMLFile(oFile=oFnTranslation) #oSets=oET_Root.findall('set') for oSet in oET_Root: for oCommand in oSet.findall('action'): uFrom: str = GetXMLTextAttribute(oXMLNode=oCommand, uTag=u'from', bMandatory=True, vDefault='') uTo: str = GetXMLTextAttribute(oXMLNode=oCommand, uTag=u'to', bMandatory=True, vDefault='') self.dTranslations[uFrom] = uTo except ParseError as e: ShowErrorPopUp(uMessage=LogError( uMsg=u'IRDB: Error:Loading Translations file', oException=e))
def Save_As_iTach(self, oSet: List[cIRCode]) -> None: oRoot: Element oCodesetCode: Element oFunction: cIRCode uFilename: str = Globals.oPathCodesets.string + "/iTach/" + self.oCodesetName.text oFilename: cFileName = cFileName().ImportFullPath( uFnFullName=uFilename.replace("_XXXXX_", "_iTach_")) try: oRoot = Element("codeset") for oFunction in oSet: oCodesetCode = SubElement(oRoot, "action") oCodesetCode.set("string", "codeset") oCodesetCode.set("name", oFunction.uFunction) oCodesetCode.set("type", oFunction.uType) uString: str = oFunction.uCode1.replace( "sendir,1:1,", "sendir,$cvar(CONFIG_MODULE):$cvar(CONFIG_CONNECTOR),") uString = uString.replace("\n", "") uString = uString.replace("\r", "") oCodesetCode.set("cmd", uString) uFinal: str = XMLPrettify(oElem=oRoot) uFinal = uFinal.replace('<?xml version="1.0"?>', '<?xml version="1.0" encoding="UTF-8"?>') oFile = open(oFilename.string, 'w') oFile.write(uFinal) oFile.close() #oTree = ElementTree(oRoot) #oTree.write(uFilename, encoding="UTF-8",xml_declaration='<?xml version="1.0" encoding="UTF-8"?>') except Exception as e: ShowErrorPopUp(uMessage=LogError( uMsg=u'IRDB: Error Writing iTach codeset file', oException=e))
def LoadReferences(self,*,oPath:cPath,uLogoPackFolderName:str) -> None: """ Loads References from a file. A reference file matches a logo file name to a SAT/DVB:C service id, the file name is fixed "srp.index.txt" :param oPath: the path to the icon root foolder :param uLogoPackFolderName: the logo pack folder name :return: """ aLines:List[str] uLine:str uReference:str uFileName:str if uLogoPackFolderName in self.dReferences: return self.dReferences[uLogoPackFolderName] = {} oFnReferences = cFileName(oPath) + "srp.index.txt" if oFnReferences.Exists(): oFile = open(oFnReferences.string,"r") aLines = oFile.readlines() oFile.close() for uLine in aLines: uReference,uFileName=uLine.split("=") uReference= NormalizeReference(uReference=uReference) self.dReferences[uLogoPackFolderName][uReference] = uFileName.split("-")[0]
def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor): """ Reads further Widget attributes from a xml node """ bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor) if bRet: self.oFnPictureNormal = cFileName("").ImportFullPath( GetXMLTextAttributeVar(oXMLNode, u'picturenormal', False, u'')) self.fMin = GetXMLFloatAttributeVar(oXMLNode, u'mindatavalue', False, u'0') self.fMax = GetXMLFloatAttributeVar(oXMLNode, u'maxdatavalue', False, u'100') self.iLeftBoundaryAngle = GetXMLIntAttributeVar( oXMLNode, u'leftboundaryangle', False, u'0') self.iRightBoundaryAngle = GetXMLIntAttributeVar( oXMLNode, u'rightboundaryangle', False, u'0') self.uDestVar = GetXMLTextAttribute(oXMLNode, u'destvar', False, u'knob') self.bDiscardMoves = GetXMLBoolAttributeVar( oXMLNode, u'discardmoves', False, False) #roundpos: the position, the number should be rounded self.iRoundPos = GetXMLIntAttribute(oXMLNode, u'roundpos', False, 0) self.fValue = 0.0 self.fOldValue = 10000.23445 self.iAbsAngle = 0 return bRet
def __init__(self, oInterFace: cInterface): super().__init__(oInterFace) self.aIniSettings.uHost = u"discover" self.aIniSettings.uPort = u"5555" self.aIniSettings.uFNCodeset = u"CODESET_android_adb_DEFAULT.xml" self.aIniSettings.fTimeOut = 2.0 self.aIniSettings.iTimeToClose = -1 self.aIniSettings.uDiscoverScriptName = u"discover_upnp" self.aIniSettings.uParseResultOption = u'store' self.aIniSettings.fDISCOVER_UPNP_timeout = 5.0 self.aIniSettings.uDISCOVER_UPNP_models = u"[]" self.aIniSettings.uDISCOVER_UPNP_servicetypes = "urn:dial-multiscreen-org:service:dial:1" self.aIniSettings.uDISCOVER_UPNP_manufacturer = "" self.aIniSettings.uDISCOVER_UPNP_prettyname = "" # Load the helper if TYPE_CHECKING: from interfaces.android_adb.adb_helper import cADB_Helper self.oDevice = cADB_Helper() else: oFn_Adb_Helper = cFileName( self.oInterFace.oPathMyCode) + u'adb_helper.py' oModule = Globals.oModuleLoader.LoadModule( oFnModule=oFn_Adb_Helper, uModuleName='adb_helper') self.oDevice = oModule.GetClass("cADB_Helper")()
def CollectFiles(self,oPath, bSubDirs=False): """ adds all files in a folder to the list of sources """ aFiles=oPath.GetFileList(bSubDirs=bSubDirs,bFullPath=True) for uFile in aFiles: oFile=cFileName(u'').ImportFullPath(uFnFullName=uFile) if oFile.string.endswith(".py") or oFile.string.endswith(".txt"): self.dFileList[oFile.string]=oFile
def _ReadCodeset(self, uFN: str) -> None: oXMLCode: Element uCmd: str del self.aCodesetCmds[:] try: oXMLCodeset: Element = LoadXMLFile( oFile=cFileName(Globals.oPathCodesets) + uFN) Orca_include(oXMLCodeset, orca_et_loader) if oXMLCodeset is not None: # First read imported codesets oXMLImports: Element = oXMLCodeset.find('imports') if oXMLImports is not None: oXMLImportCodesets: Element = oXMLImports.find('codeset') if oXMLImportCodesets is not None: for oXMLCode in oXMLImportCodesets.findall('code'): uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode, uTag='action', bMandatory=False, vDefault='') if uCmd: self.aCodesetCmds.append(uCmd) for oXMLCode in oXMLCodeset.findall('code'): uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode, uTag='action', bMandatory=False, vDefault='') if uCmd: self.aCodesetCmds.append(uCmd) except Exception as e: LogError(uMsg='Error Reading Codeset', oException=e)
def ParseIconsFromXMLNode(self, *, oXMLNode: Element) -> None: """ Parses all icon definitions from the xml objects """ oXMLIcons: Element = oXMLNode.find('icons') if oXMLIcons is not None: Logger.info(u'Loading Icons') for oXMLIcon in oXMLIcons.findall('icon'): uIconName: str = GetXMLTextAttribute(oXMLNode=oXMLIcon, uTag=u'name', bMandatory=True, vDefault=u'') oFnIconFont: cFileName = cFileName("").ImportFullPath( uFnFullName=GetXMLTextAttribute(oXMLNode=oXMLIcon, uTag=u'font', bMandatory=True, vDefault=u'')) uIconChar: str = GetXMLTextAttribute(oXMLNode=oXMLIcon, uTag=u'char', bMandatory=True, vDefault=u'') uFontName: str = oFnIconFont.basename fIconScale: float = GetXMLFloatAttribute(oXMLNode=oXMLIcon, uTag=u'scale', bMandatory=False, fDefault=1.0) Globals.dIcons[uIconName] = { "fontfile": oFnIconFont.string, "char": uIconChar, "fontname": uFontName, "scale": fIconScale } Globals.oTheScreen.oFonts.ParseDirect( uFontName=uFontName, uFontFileNormal=oFnIconFont.string)