コード例 #1
0
def GetSystemTmpPath() -> cPath:
    """ Gets the path to the tmp folder """
    oPath:cPath

    oPath = cPath(GetEnvVar(u"TMPDIR"))
    if oPath.Exists():
        return oPath

    oPath = cPath(GetEnvVar(u"TMP"))
    if oPath.Exists():
        return oPath

    oPath = cPath(u"/var/tmp")
    if oPath.Exists():
        return oPath

    oPath = cPath(u"/var/tmp")
    if oPath.Exists():
        return oPath

    oPath = cPath(u"/tmp")
    if oPath.Exists():
        return oPath

    oPath = Globals.oPathUserDownload+"orcatmp"

    oPath.Create()
    return oPath
コード例 #2
0
    def UploadLocalFile(self, oFile, oBaseLocalDir, oBaseRemoteDir):
        """
        Subfunction to upload a local file including sub pathes to to remote folder

        :param cFileName oFile: FileName to Upload
        :param cPath oBaseLocalDir: Local Path
        :param cPath oBaseRemoteDir: Remote FTP Path
        :return:
        """
        try:
            bRet = False
            uPath = oFile.oPath.string
            oRemoteSubPath = cPath(uPath.replace(oBaseLocalDir.string, ''))
            oRemotePath = cPath(
                uPath.replace(oBaseLocalDir.string, oBaseRemoteDir.string))

            if not self.DirExists(oRemotePath):
                self.CreateDir(oRemotePath)

            if self.ChangeDir(oRemotePath):
                if oFile.Exists():
                    bRet = self._UploadFile(oFile, oRemoteSubPath)
                else:
                    Logger.warning("File no longer exists, (%s)!" %
                                   oFile.string)

            return bRet

        except Exception as e:
            bOnError = True
            LogError('Fatal FTP error', e)
        return bOnError
コード例 #3
0
    def Load_RSA_KEYS(self):

        aKeyPathes = []

        #default adb key path
        aKeyPathes.append(cPath(OS_GetSystemUserPath() + '.android/adbkey'))

        #default Android Path
        if Globals.uPlatform == u'android':
            aKeyPathes.append(
                cPath(OS_GetSystemUserPath() + 'misc/adb/adb_keys/adbkey'))

        #Download path
        aKeyPathes.append(Globals.oPathUserDownload + "/adbkey")

        for oPath in aKeyPathes:
            if oPath.Exists():
                try:
                    self.aGlobalRSA_KEYS.append(
                        PythonRSASigner.FromRSAKeyPath(oPath.string))
                    Logger.info("RSA Keyfiles loaded from " + oPath)
                except Exception as e:
                    Logger.error("Error Loading RSA Keys from " +
                                 oPath.string + " " + str(e))
            else:
                Logger.debug("No RSA Keyfiles at " + oPath)
コード例 #4
0
    def InitPathes(self) -> None:
        """
        init all used pathes by the app (root pathes needs to be initialized)
        """

        Globals.oPathSkin = self.oPathSkinRoot + Globals.uSkinName

        oPathCheck = Globals.oPathSharedDocuments + "elements" + (
            "skin_" + Globals.uSkinName)
        if oPathCheck.Exists():
            Globals.oPathStandardPages = oPathCheck
        else:
            Globals.oPathStandardPages = (Globals.oPathSharedDocuments +
                                          "elements") + "skin_default"
        Globals.oPathUserDownload = OS_GetUserDownloadsDataPath()
        Globals.oPathStandardElements = Globals.oPathStandardPages
        Globals.oPathStandardPages = Globals.oPathStandardPages + "pages"
        Globals.oFnElementIncludeWrapper = cFileName(
            Globals.oPathStandardElements) + u'block_elementincludewrapper.xml'

        Globals.oFnSkinXml = cFileName(Globals.oPathSkin) + u'skin.xml'
        Globals.oPathSounds = cPath(Globals.oPathSoundsRoot) + self.uSoundsName
        Globals.oFnSoundsXml = cFileName(Globals.oPathSounds) + u'sounds.xml'
        Globals.oPathFonts = Globals.oPathResources + u'fonts'
        Globals.oFnGestureLog = cFileName(
            Globals.oPathUserDownload) + u'gestures.log'
        Globals.oFnLangInfo = cFileName(Globals.oPathLanguageRoot +
                                        Globals.uLanguage) + u'langinfo.xml'
        Globals.oFnAction = cFileName(Globals.oPathAction) + u'actions.xml'
        Globals.oFnActionEarlyAppStart = cFileName(
            Globals.oPathAction) + u'actionsearly.xml'
        Globals.oFnActionFreshInstall = cFileName(
            Globals.oPathAppReal + u'actions') + u'actionsfallback.xml'
        Globals.oFnCredits = cFileName(Globals.oPathAppReal) + u'credits.txt'

        Globals.oPathGestures = cPath(Globals.oPathAction)
        Globals.oFnGestures = cFileName(
            Globals.oPathGestures) + u'gestures.xml'
        Globals.oFnLog = cFileName('').ImportFullPath(
            uFnFullName=FileHandler.filename)
        Globals.oFnLicense = cFileName(Globals.oPathAppReal) + u'license.txt'
        Globals.oPathCookie = Globals.oPathTmp
        Globals.uScriptLanguageFileTail = u'/languages/' + Globals.uLanguage + '/strings.xml'
        Globals.uScriptLanguageFallBackTail = u'/languages/English/strings.xml'
        Globals.oFnInterfaceLanguage = cFileName(
            Globals.oPathInterface + u'/%s/languages/' +
            Globals.uLanguage) + u'strings.xml'
        Globals.oFnInterfaceLanguageFallBack = cFileName(
            Globals.oPathInterface + u'/%s/languages/English') + u'strings.xml'
        oDefinitionPathes = cDefinitionPathes(
            uDefinitionName=Globals.uDefinitionName)
        Globals.dDefinitionPathes[Globals.uDefinitionName] = oDefinitionPathes
        SetDefinitionPathes(uDefinitionName=Globals.uDefinitionName)

        Globals.aLogoPackFolderNames = Globals.oPathTVLogos.GetFolderList(
            bFullPath=False)

        if Globals.oDefinitionPathes.oPathDefinition.Exists():
            Globals.oDefinitionPathes.oPathDefinitionAtlas.Create()
コード例 #5
0
def GetUserDownloadsDataPath():
    """ returns the path to the download folder """
    oRetPath = cPath(OS_ToPath(expanduser('~') + sep + 'Downloads'))
    Logger.debug("Download Folder  = " + oRetPath.string)

    if oRetPath.Exists():
        return oRetPath

    Logger.error("Downloadpath not valid:" + oRetPath.string)
    return cPath('')
コード例 #6
0
def GetSystemUserPath() -> cPath:
    """
    Returns the Operation System User Path
    """

    uUserPath: str = expanduser('~')
    oCheckFile = cFileName(cPath(uUserPath))
    oCheckFile = oCheckFile + "NTUSER.DAT"

    if not oCheckFile.Exists():
        uUserPath = dirname(uUserPath)

    return cPath(uUserPath)
コード例 #7
0
ファイル: WikiDoc.py プロジェクト: thica/ORCA-Remote
    def __init__(self,**kwargs):
        self.dFileList:Dict[str,cFileName]          = {}
        self.aDocs:List[cWikiPage]                  = []
        self.dTocs:Dict[str,List[cWikiTocEntry]]    = {}
        self.dImageFileList:Dict[str,cFileName]     = {}
        self.dImageFileListBase:Dict[str,cFileName] = {}
        self.oSourcePath:cPath                      = cPath(Globals.oPathRoot) + "ORCA"

        self.uHost:str                              = kwargs["Host"]
        self.uWikiPath:str                          = kwargs["WikiPath"]
        self.uUser:str                              = kwargs["User"]
        self.uPassword:str                          = kwargs["Password"]
        self.oWikiTargetFolder:cPath                = cPath(kwargs["WikiTargetFolder"])
        self.uWikiApp:str                           = kwargs["WikiApp"]
コード例 #8
0
    def __init__(self, **kwargs):
        self.dFileList = {}
        self.aDocs = []
        self.dTocs = {}
        self.dImageFileList = {}
        self.dImageFileListBase = {}
        self.oSourcePath = cPath(Globals.oPathRoot) + "ORCA"

        self.uHost = kwargs["Host"]
        self.uWikiPath = kwargs["WikiPath"]
        self.uUser = kwargs["User"]
        self.uPassword = kwargs["Password"]
        self.oWikiTargetFolder = cPath(kwargs["WikiTargetFolder"])
        self.uWikiApp = kwargs["WikiApp"]
コード例 #9
0
ファイル: ConfigHelpers.py プロジェクト: thica/ORCA-Remote
def Config_GetDefault_Path(*, oConfig: ConfigParser, uSection: str,
                           uOption: str, uDefaultValue: str) -> cPath:
    return cPath(
        Config_GetDefault_Str(oConfig=oConfig,
                              uSection=uSection,
                              uOption=uOption,
                              vDefaultValue=uDefaultValue))
コード例 #10
0
def GetInstallationDataPath() -> cPath:
    """ Gets the path to the folder where the installer places the ORCA files"""
    '''
    The environment ist
    'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar', 'ANDROID_SOCKET_zygote': '8', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/org.orca.orca/files/app', 'ANDROID_APP_PATH': '/data/user/0/org.orca.orca/files/app', 'ANDROID_PRIVATE': '/data/user/0/org.orca.orca/files', 'ANDROID_UNPACK': '/data/user/0/org.orca.orca/files/app', 'PYTHONHOME': '/data/user/0/org.orca.orca/files/app', 'PYTHONPATH': '/data/user/0/org.orca.orca/files/app:/data/user/0/org.orca.orca/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'True', 'P4A_ORIENTATION': 'sensor', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
    # we expect as result
    # /data/data/org.orca.orca/files/app
    
    Access to the environment looks like

    Environment     = autoclass('android.os.Environment')
    tt1:str  = Environment.getStorageDirectory().getPath()
    tt2:str   = Environment.getRootDirectory().getPath()
    tt3:str   = Environment.getDataDirectory().getPath()

    Android getStorageDirectory() = /storage
    Android getRootDirectory() = /system
    Android getDataDirectory() = /data
    
    So we make it simple to utilize the environment var
    
    '''

    oPath = cPath(GetEnvVar(u"ANDROID_APP_PATH"))
    Logger.debug("Android GetInstallationDataPath = " + oPath.string)
    return oPath
コード例 #11
0
    def CreateDir(self, oPath, uSep=u'/'):
        """
        creates a remote ftp path
        :param cPath oPath: The Remote Path to create
        :param string uSep: The Separator to slit the pathes into it's sub pathes
        :return: True/False
        """

        uPath = oPath.unixstring
        uSplitPath = uPath.split(uSep)
        uNewDir = u''
        for uServerDir in uSplitPath:
            if uServerDir:
                uNewDir += uSep + uServerDir
                if not self.DirExists(cPath(uNewDir)):
                    try:
                        Logger.debug(
                            'Attempting to create directory (%s) ...' %
                            (uNewDir))
                        self.oFTP.mkd(uNewDir)
                    except Exception as e:
                        LogError(
                            'can\'t create directory (%s) ...' % (uNewDir), e)
                        return False
        return True
コード例 #12
0
    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)
コード例 #13
0
 def CollectAllChannelLogos(self):
     """
     Collect all chanel logos in a dict (if not already done)
     """
     if len(self.dLogos) == 0:
         self.CollectAllChannelLogos_sub(
             oPath=cPath("$var(RESOURCEPATH)/tvlogos"))
コード例 #14
0
def GetInstallationDataPath():
    """ Gets the path to the folder where the installer places the ORCA files"""

    sPathname = os.path.dirname(sys.argv[0])
    uAppPath = os.path.abspath(sPathname)
    oPathRoot = cPath(uAppPath)

    return oPathRoot
コード例 #15
0
 def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):
     """ Reads further Widget attributes from a xml node """
     self.oPathStart = cPath(GetVar(uVarName="filebrowserfile"))
     self.uActionNameCancel = GetXMLTextAttribute(oXMLNode, u'actioncancel',
                                                  False, u'')
     self.bDirSelect = GetXMLBoolAttribute(oXMLNode, u'dirselect', False,
                                           False)
     return self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
コード例 #16
0
 def ExportOrcaFiles(self, *args, **kwargs):
     """
     Export all Orca Files a given location
     """
     oPath = cPath(GetVar(uVarName="filebrowserfile")) + "/OrcaExport"
     oPath.Delete()
     if not Globals.oPathRoot.string in oPath.string:
         fIgnore = ignore_patterns('*.ini', 'ORCA', '*.py*')
         Globals.oPathRoot.Copy(oPath, fIgnore)
コード例 #17
0
 def CollectAllChannelLogos_sub(self, oPath):
     """
     Helper function to recursive get all files in a folder tree
     :param cPath oPath: The start folder in the folder tree
     """
     self.GetFolderFiles(oPath)
     aFolder = oPath.GetFolderList(bFullPath=True)
     for uFolder in aFolder:
         self.CollectAllChannelLogos_sub(cPath(uFolder))
コード例 #18
0
ファイル: FileBrowser.py プロジェクト: thica/ORCA-Remote
 def On_Success(self, instance:FileBrowser) -> None:
     """ called , when a user makes a selection """
     if len(instance.selection)!=0:
         oItem = cPath(instance.selection[0])
         if self.bDirSelect and not oItem.IsDir():
             return
         SetVar(uVarName = "filebrowserfile", oVarValue = oItem.string)
         self.On_Button_Up(instance)
         return
コード例 #19
0
 def ImportOrcaFiles(self, *args, **kwargs):
     """
     Import all ORCA files from a given location
     """
     oPath = cPath(GetVar(uVarName="filebrowserfile"))
     oFnCheckFile = cFileName(oPath + 'actions') + 'actions.xml'
     if oFnCheckFile.Exists():
         if not Globals.bProtected:
             oPath.Copy(Globals.oPathRoot)
コード例 #20
0
def GetAllKnownFolders():
    global dPlaces
    uPathPlace: str
    if len(dPlaces) == 0:
        for tPlace in aPlaces:
            if dPlaces.get(tPlace[0]) is None:
                uPathPlace = GetKnownFolderPath(tPlace[1])
                if uPathPlace:
                    dPlaces[tPlace[0]] = cPath(uPathPlace)
                    print(tPlace[0], ":", uPathPlace)
コード例 #21
0
 def HandleValue(self, uName, uValue):
     if uName.startswith("oPath"):
         uTmp = uValue
         if uTmp.startswith("~"):
             uTmp = OS_GetSystemUserPath() + uTmp[1:]
         self.oParameter[uName] = cPath(uTmp)
     elif uName.startswith("b"):
         self.oParameter[uName] = (uValue != "")
     else:
         self.oParameter[uName] = uValue
コード例 #22
0
ファイル: RepManager.py プロジェクト: thica/ORCA-Remote
    def CreateRepVarArray(self,uBaseLocalDir:str) -> None:
        aLocalFiles:List[str] = cPath(uBaseLocalDir).GetFileList(bSubDirs=True, bFullPath=True)
        SetVar(uVarName="REPMAN_LOCALBASENAME", oVarValue=uBaseLocalDir)
        SetVar(uVarName="REPMAN_CNTFILES",      oVarValue= str(len(aLocalFiles)))
        Var_DelArray("REPMAN_LOCALFILENAMES[]")

        i:int=0
        for uLocalFile in aLocalFiles:
            uIndex:str = str(i) + "]"
            SetVar(uVarName="REPMAN_LOCALFILENAMES[" + uIndex ,oVarValue=uLocalFile)
            i += 1
コード例 #23
0
ファイル: script.py プロジェクト: thica/ORCA-Remote
 def ImportOrcaFiles(self, *args, **kwargs) -> None:
     """
         Import all ORCA files from a given location
         """
     oPath: cPath = cPath(GetVar(uVarName="filebrowserfile"))
     oFnCheckFile: cFileName = cFileName(oPath + 'actions') + 'actions.xml'
     if oFnCheckFile.Exists():
         if not Globals.bProtected:
             oPath.Copy(oDest=Globals.oPathRoot)
             if GetVar(uVarName="CHECKBOX_IMPORT_CHANGE_LOCATION") == "1":
                 Globals.oOrcaConfigParser.set("ORCA", u'rootpath', '')
                 Globals.oOrcaConfigParser.write()
コード例 #24
0
ファイル: Zip.py プロジェクト: thica/ORCA-Remote
    def Unzip(self, oPath:cPath) -> bool:
        """
        Unzips a zip file  to a path
        If the output location does not yet exist, it creates it

        :param cPath oPath:
        :return: True if successful
        """

        oZip:Union[ZipFile,None]=None
        uEach:str
        uRoot:str
        uName:str
        oFn:cFileName
        # oFn:cPath

        try:

            Logger.debug(u'Extracting file [%s] to path [%s]' % (self.string, oPath.string))

            oZip = ZipFile(self.string, 'r')
            if not oPath.IsDir():
                oPath.Create()
            for uEach in oZip.namelist():
                # each=ToUnicode(each)

                Logger.debug(u'Extracting ' + ToUnicode(basename(uEach)) + ' ...')
                # Check to see if the item was written to the zip file with an
                # archive name that includes a parent directory. If it does, create
                # the parent folder in the output workspace and then write the file,
                # otherwise, just write the file to the workspace.
                #
                if not uEach.endswith('/'):
                    uRoot, uName = split(uEach)
                    oFolder = cPath(oPath) + uRoot
                    if not oFolder.IsDir():
                        oFolder.Create()
                    oFn = cFileName(oFolder) + uName
                    uFn = oFn.string
                    Logger.debug(u'... Writing to ' + uFn)
                    oFile = open(uFn, 'wb')
                    oFile.write(oZip.read(uEach))
                    oFile.close()
            oZip.close()
            return True
        except Exception as e:
            LogError(uMsg=u'Unzip: Fatal Error unzipping file',oException=e)
            try:
                oZip.close()
            except Exception:
                pass
            return False
コード例 #25
0
    def Finish(self) -> bool:
        """ Finish loading """

        oET_Root: Element

        if self.oRef.dPars["Finalize"] == "REPOSITORY XML":
            try:
                oET_Root = LoadXMLFile(oFile=self.oFnDest, bNoCache=True)
                if not oET_Root is None:
                    self.oRepository.ParseFromXMLNode(oXMLNode=oET_Root)
            except Exception as e:
                LogError(uMsg=u'can\'t parse repository:' + self.uUrl,
                         oException=e)
                return True
        if self.oRef.dPars["Finalize"] == "FILE ZIP":
            try:
                if not self.bOnError:
                    if self.uTarget.startswith('.' or '..' in self.uTarget):
                        LogError(
                            uMsg=
                            'All destination pathes must be inside the ORCA directory, absolute pathes are not allowed!:'
                            + self.uTarget)
                    else:
                        oZipFile: cZipFile = cZipFile('').ImportFullPath(
                            uFnFullName=self.oFnDest.string)
                        if oZipFile.IsZipFile():
                            if not Globals.bProtected:
                                oZipFile.Unzip(
                                    cPath('$var(APPLICATIONPATH)/' +
                                          self.uTarget))
                            else:
                                LogError(
                                    uMsg="Protected: Nothing will be unzipped")
                        else:
                            if oZipFile.Exists():
                                Logger.error("Failed to unzip:" +
                                             oZipFile.string)
                            else:
                                Logger.error("Failed to download zip:" +
                                             oZipFile.string)
                                #todo: handle unzipped files
                        oZipFile.Delete()
                Logger.debug(
                    'LoadOnlineResource: Finished download Resource  [%s][%s]'
                    % (self.uType, self.uName))
                RegisterDownLoad(uType=self.uType,
                                 uName=self.uName,
                                 iVersion=ToInt(self.uVersion))
            except Exception as e:
                LogError(uMsg=u'can\'t unpack resources:' + self.uUrl,
                         oException=e)
コード例 #26
0
    def ExecuteActionExecuteFTPCommand(self,oAction:cAction) -> eReturnCode:
        """
        executeftpcommand:
            Executes various FTP commands (connect, disconnect, uploadfile)
            Parameter:
            None
        """

        self.oEventDispatcher.LogAction(uTxt=u'ExecuteFTPCommand',oAction=oAction)

        bRet:bool               = False
        uCommand:str            = ReplaceVars(oAction.dActionPars.get("command",  ""))
        uHost:str               = ReplaceVars(oAction.dActionPars.get("host",     ""))
        uUsername:str           = ReplaceVars(oAction.dActionPars.get("user",     ""))
        uPassword:str           = ReplaceVars(oAction.dActionPars.get("password", ""))
        uSSL:str                = ReplaceVars(oAction.dActionPars.get("ssl",      ""))

        oLocalFile:cFileName    = cFileName('').ImportFullPath(uFnFullName=ReplaceVars(oAction.dActionPars.get("localfile",       "")))
        oLocalBaseFolder:cPath  = cPath(ReplaceVars(oAction.dActionPars.get("localbasefolder", "")))
        oRemoteBaseFolder:cPath = cPath(ReplaceVars(oAction.dActionPars.get("remotebasefolder","")))

        if Globals.oFTP is None:
            Globals.oFTP = cFTP(ToBool(uSSL))

        if uCommand==u'connect':
            bRet = Globals.oFTP.Connect(uServer=uHost)
            if bRet:
                bRet=Globals.oFTP.Login(uUsername=uUsername, uPassword=uPassword )
        elif uCommand==u'disconnect':
            bRet=Globals.oFTP.DisConnect()
        elif uCommand==u'uploadfile':
            bRet = Globals.oFTP.UploadLocalFile(oFile=oLocalFile, oBaseLocalDir=oLocalBaseFolder, oBaseRemoteDir=oRemoteBaseFolder)
        elif uCommand==u'downloadfile':
            bRet = Globals.oFTP.DownloadRemoteFile(oFnFile=oLocalFile, oPathLocal=oLocalBaseFolder, oPathRemote=oRemoteBaseFolder)
        if bRet:
            return eReturnCode.Success
        else:
            return eReturnCode.Error
コード例 #27
0
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)
コード例 #28
0
ファイル: script.py プロジェクト: thica/ORCA-Remote
 def ExportOrcaFiles(self, *args, **kwargs) -> None:
     """
     Export all Orca Files a given location
     """
     oPath: cPath = cPath(
         GetVar(uVarName="filebrowserfile")) + "/OrcaExport"
     oPath.Delete()
     if not Globals.oPathRoot.string in oPath.string:
         fIgnore = ignore_patterns('*.ini', 'ORCA', '*.py*')
         Globals.oPathRoot.Copy(oDest=oPath, fIgnoreFiles=fIgnore)
         if GetVar(uVarName="CHECKBOX_EXPORT_CHANGE_LOCATION") == "1":
             Globals.oOrcaConfigParser.set("ORCA", u'rootpath',
                                           oPath.string)
             Globals.oOrcaConfigParser.write()
コード例 #29
0
ファイル: RepManager.py プロジェクト: thica/ORCA-Remote
 def GetFonts(self) -> None:
     """ Gets all others reps """
     del self.aFiles[:]
     del self.aRepManagerEntries[:]
     aFontsFolders:List[str] = Globals.oPathFonts.GetFolderList(bFullPath=True)
     for uFontFolder in aFontsFolders:
         oFnFontDefinition:cFileName = cFileName(cPath(uFontFolder)) + "fonts.xml"
         oRepManagerEntry:cRepManagerEntry = cRepManagerEntry(oFileName=oFnFontDefinition)
         if oRepManagerEntry.ParseFromXML():
             if not oRepManagerEntry.oRepEntry.bSkip:
                 self.aRepManagerEntries.append(oRepManagerEntry)
         else:
             Logger.warning('Font not ready for Repository Manager, skipped: '+oFnFontDefinition)
     self.SaveRepositoryXML('fonts','Font Resources')
コード例 #30
0
ファイル: adb_helper.py プロジェクト: thica/ORCA-Remote
    def Load_RSA_KEYS(self) -> None:
        # default adb key path
        aKeyPathes:List[cPath] = [cPath(OS_GetSystemUserPath() + '.android/adbkey')]

        #default Android Path
        if Globals.uPlatform==u'android':
            aKeyPathes.append(cPath(OS_GetSystemUserPath()+'misc/adb/adb_keys/adbkey'))

        #Download path
        aKeyPathes.append(Globals.oPathUserDownload+"/adbkey")

        for oPath in aKeyPathes:
            if oPath.Exists():
                try:
                    with open(str(oPath)) as f:
                        oPriv   = f.read()
                        oSigner = PythonRSASigner('', oPriv)
                        self.aGlobalRSA_KEYS.append(oSigner)
                        Logger.info("RSA Keyfiles loaded from "+str(oPath))
                except Exception as e:
                    Logger.error("Error Loading RSA Keys from "+str(oPath)+" "+str(e))
            else:
                Logger.debug("No RSA Keyfiles at "+oPath)