def execute(self, filepath): if (self.options.debug): self.log.log('>>> Opening Script: ' + filepath) self.log.log('') self.log.log('') if (self.options.driver): driver = LoadedDrivers.getBaseDriver(self.options.driver) else: driver = LoadedDrivers.getDefaultBaseDriver() input = InputStream(driver.readScript(filepath)) # input = FileStream(filepath) lexer = Ah210Lexer(input) stream = CommonTokenStream(lexer) parser = Ah210Parser(stream) tree = parser.prog() printer = AhListener() visitor = AhVisitor(self.config, self.header, self.auth, parameters=self.parameters, options=self.options) visitor.setState(file=getPath(filepath)) return visitor.visit(tree)
def execute_system_scripts_save(): driver = LoadedDrivers.getDefaultBaseDriver() driver.saveScript(request.json['file-name'], request.json['file']) return json.dumps({ 'status': 200, 'file-name': getPath(request.json['file-name']) })
def getCatalog(self): path = self.basePath baseLength = len(path) files = getAllFiles(path + "/**/*.ah") catalog = [] for file in files: fPath = getPath(file) command = fPath[baseLength + 1:-3].replace('/', ' ').replace('\\', ' ') catalog.append(command) return catalog
def execute_system_scripts_rename(): driver = LoadedDrivers.getDefaultBaseDriver() if (not driver.renameScript(request.json['file-name-original'], request.json['file-name-new'])): return json.dumps({ 'status': 500, 'message': 'Cannot rename to an existing file.' }) return json.dumps({ 'status': 200, 'file-name': getPath(request.json['file-name-new']) })
def setup(self, config, header, auth, parameters, options=Options()): self.config = config self.header = header self.auth = auth self.options = options self.request = None self.parameters = parameters if (self.getDriverPath() is None): self.basePath = str( config.path ) + '/drivers/plugins/commandtax/' + self.getDriverName() else: self.basePath = self.getDriverPath() + '/' + self.getDriverName() self.basePath = getPath(self.basePath) return self
def handle(self, command): from apitax.ah.commandtax.commands.Script import Script if (self.override(command)): return self.request = Script(self.config, self.header, self.auth, self.parameters, self.options) path = self.basePath i = 0 for element in command: element = element.strip() if (element == '--driver'): i += 2 elif (element[:2] == '--'): i += 1 if (i > 0): i -= 1 else: path += '/' + element # print(element+":"+str(i)) path += '.ah' path = getPath(path) self.request.handle([path]) return self.request
def __init__(self): super().__init__() self.users = read(getPath(State.paths['root'] + "/app/users.json"))
def getScriptsPath(self, append=''): return getPath(self.config.path + '/drivers/plugins/scriptax/' + self.__class__.__name__ + '/' + append)
def getScriptsCatalog(self): files = getAllFiles(self.getScriptsPath("scripts/**/*.ah")) returner = {"scripts": []} for file in files: returner['scripts'].append( {"label": file.split('/')[-1].split('.')[0].title(), "relative-path": file, "path": getPath(file)}) # print(returner) return returner