Пример #1
0
 def getPathTreeFromPath(self, path):
     node = {}
     nodeSons = EnvironmentHelper.listDirectoryContent(path)
     for nodeSon in nodeSons:
         if self.nodeIsValid(nodeSon):
             nodeSonPath = f'{path}{EnvironmentHelper.OS_SEPARATOR}{nodeSon}'
             try:
                 node[nodeSon] = self.getPathTreeFromPath(nodeSonPath)
             except:
                 pass
     return node
Пример #2
0
 def makePathTreeVisible(self, path):
     node = {}
     nodeSons = EnvironmentHelper.listDirectoryContent(path)
     for nodeSon in nodeSons:
         if self.nodeIsValid(nodeSon):
             nodeSonPath = f'{path}{EnvironmentHelper.OS_SEPARATOR}{nodeSon}'
             try:
                 node[nodeSon] = self.makePathTreeVisible(nodeSonPath)
             except:
                 node[nodeSon] = c.NOTHING
     EnvironmentHelper.appendPath(path)
     return node
Пример #3
0
 def addNode(self, nodePath):
     node = {}
     try:
         nodeSons = EnvironmentHelper.listDirectoryContent(nodePath)
         for nodeSon in nodeSons:
             nodeSonPath = f'{nodePath}{EnvironmentHelper.OS_SEPARATOR}{nodeSon}'
             try:
                 node[nodeSon] = self.addNode(nodeSonPath)
             except:
                 node[nodeSon] = c.NOTHING
     except Exception as exception:
         self.failure(f'Not possible to run addNode({nodePath}) rotine',
                      exception,
                      muteStackTrace=True)
     return node
Пример #4
0
 def giveLocalVisibilityToFrameworkApis(self, apiPackageNameList):
     if apiPackageNameList:
         localPackageNameList = EnvironmentHelper.listDirectoryContent(
             self.apisPath)
         for packageName in localPackageNameList:
             if packageName not in self.apiTree.keys(
             ) and packageName in apiPackageNameList:
                 packagePath = f'{self.apisPath}{packageName}'
                 try:
                     self.apiTree[packageName] = self.makePathTreeVisible(
                         packagePath)
                 except:
                     self.apiTree[packageName] = c.NOTHING
         if self.printStatus:
             self.printTree(self.apiTree, f'{c.DEBUG}Api tree')
Пример #5
0
 def spotRootPath(self, rootPath):
     if self.printRootPathStatus:
         try:
             apiPackageList = EnvironmentHelper.listDirectoryContent(
                 rootPath)
             for apiPackage in apiPackageList:
                 self.rootPathTree[apiPackage] = self.addNode(
                     f'{rootPath}{apiPackage}')
             if self.printStatus:
                 self.printTree(
                     self.rootPathTree,
                     f'{c.DEBUG}Root tree (printRootPathStatus is active)')
         except Exception as exception:
             self.failure(
                 f'Not possible to run spotRootPath({rootPath}) rotine',
                 exception)
Пример #6
0
 def makeApisAvaliable(self, apisPath):
     if self.globalsEverything:
         try:
             apiPackageList = EnvironmentHelper.listDirectoryContent(
                 apisPath)
             for apiPackage in apiPackageList:
                 if not apiPackage in list(self.apiTree.keys()):
                     self.apiTree[apiPackage] = self.makePathTreeVisible(
                         f'{apisPath}{apiPackage}')
             if self.printStatus:
                 self.printTree(
                     self.apiTree,
                     f'{c.DEBUG}Api tree (globalsEverithing is active)')
         except Exception as exception:
             self.error(
                 f'Not possible to run makeApisAvaliable({apisPath}) rotine',
                 exception)
Пример #7
0
def newApp(filePath,
           successStatus=True,
           errorStatus=True,
           failureStatus=True,
           warningStatus=True,
           settingStatus=True,
           statusStatus=True,
           infoStatus=True,
           debugStatus=False,
           wrapperStatus=False,
           testStatus=False,
           logStatus=False):
    globalsInstance = globals.newGlobalsInstance(filePath,
                                                 successStatus=successStatus,
                                                 errorStatus=errorStatus,
                                                 failureStatus=failureStatus,
                                                 settingStatus=settingStatus,
                                                 statusStatus=statusStatus,
                                                 infoStatus=infoStatus,
                                                 debugStatus=debugStatus,
                                                 warningStatus=warningStatus,
                                                 wrapperStatus=wrapperStatus,
                                                 testStatus=testStatus,
                                                 logStatus=logStatus)
    try:
        app = globals.importResource(
            KW_APP,
            resourceModuleName=ConverterStatic.getValueOrDefault(
                globalsInstance.apiName,
                StringHelper.join(EnvironmentHelper.listDirectoryContent(
                    f'{globalsInstance.BASE_API_PATH}')[0].split(c.DOT)[:-1],
                                  character=c.DOT)),
            required=True)
    except Exception as exception:
        apiPath = f'{c.DOT}{EnvironmentHelper.OS_SEPARATOR}{globalsInstance.BASE_API_PATH}{globalsInstance.apiName}.py'
        errorMessage = f"Not possible to load app. Make shure it's name is properlly configured at '{globalsInstance.settingFilePath}' and it's instance is named 'app' at '{apiPath}'"
        log.error(newApp, errorMessage, exception)
        raise exception
    if ObjectHelper.isNone(app):
        app = globals.importResource(
            KW_APP, resourceModuleName=globalsInstance.apiName)
        raise Exception(
            'Not possible to load app. Check logs for more details')
    return app