def compile_app(): if config.DEBUG: input_file = 'app.html' path = Path('templates/').path compontents = Path('static/components').path output_file = 'out-app.html' compiler = Compiler(input_file, path, compontents, output_file) compiler.start()
def dstFile(self): """ 导出文件路径 """ if self.__dstFile is None: return None path = os.path.join(CustomConfig().dstRoot, self.__dstFile) return Path.normalizePath(path)
def __init__(self): xml = SimpleXML(Path.executeDirectory()) binSect = xml.openSection("bin.xml") if binSect is None: Listener().cbError("config file 'bin.xml' is not exist.") engine.exit(1) self.__binSect = binSect
def getWorkbook(self, fileName, encoding): """ 获取 Excel 工作簿 Excel 文件不存在,或者 Excel 在操作中,则引起 ExcelComException fileName 的编码必须与本程序脚本使用的编码一致 """ fileName = Path.normalizePath(fileName) if fileName in self.__wbooks: return self.__wbooks[fileName] sysFileName = script2sys(fileName) sysFileName = Path.normalizePath(sysFileName) if not os.path.exists(sysFileName): raise ExcelFixException("errUnexist", file=fileName) try: wbook = xlrd.open_workbook(sysFileName) self.__wbooks[fileName] = wbook return wbook except xlrd.XLRDError, err: raise ExcelFixException("errUnexist", file=fileName)
def getSrcFullName(srcFile): """ 获取数据源文件全路径 """ for root in CustomConfig().srcRoots: fullName = os.path.join(root, srcFile) fullName = Path.normalizePath(fullName) if os.path.exists(script2sys(fullName)): return fullName return srcFile
def _initEnvironment(): """ 初始化环境变量 """ sys.path.append(script2sys(Path.executeDirectory())) # 将程序根目录添加到环境变量 for root in CustomConfig().syscodeTplRoots: # 将配置文件所在路径加入环境变量 sys.path.append(root) if CustomConfig().syscodeSrcPluginRoot != "": sys.path.append(CustomConfig().syscodeSrcPluginRoot) # 数据源插件根目录 if CustomConfig().syscodeDstPluginRoot != "": sys.path.append(CustomConfig().syscodeDstPluginRoot) # 数据导出插件根目录
def dstRoot(self): """ 导出路径的根目录 """ if self.__dstRoot is None: try: root = self.__cfgSect["paths"].readString("dstRoot") except: raise ConfigTagPathException("<paths>/<dstRoot>") self.__dstRoot = Path.realToExecutePath(root) return self.__dstRoot
def tplRoots(self): """ 模板文件路径列表 """ if self.__tlpRoots is None: self.__tlpRoots = [] try: roots = self.__cfgSect["paths"]["tplRoots"].readStrings("item") except: raise ConfigTagPathException("<paths>/<tplRoots>") for root in roots: self.__tlpRoots.append(Path.realToExecutePath(root)) return self.__tlpRoots
def getSheet(self, fileName, encoding): """ 获取一个 CSV 表格 fileName 的编码必须与本程序脚本使用的编码一致 """ fileName = Path.normalizePath(fileName) sysFileName = script2sys(fileName) if fileName in self.__sheets: return self.__sheets[fileName] if not os.path.exists(sysFileName): raise CSVFixException("errUnexist", file=fileName) try: file = open(sysFileName, "rb") except Exception, err: raise DataSourceException(sys2script(err.__str__()))
def change_frontend_connection(ip_addr): global port framework_path = Path('static/framework.js').path file_path = os.path.join(os.getcwd(), framework_path) client_server = open(file_path, 'r') client_server_lines = client_server.readlines() for i, line in enumerate(client_server_lines): if line.rstrip().lstrip() == '//$SOCKET_IP': client_server_lines[i + 1] = ' socket = io.connect("http://' + ip_addr + ':' + str( port) + '"); //This line was autogenerated.\n' break client_server = open(file_path, 'w') client_server.writelines(client_server_lines) client_server.close()
from libs import Path from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC DEBUG = True port = 8080 # Defualt settings chromedriver_name = "chromedriver" data_dir_path = Path( '/home/jgcardelus/Desktop/coding-projects/cosmos-tv-settings/chrome-preferences' ).path settings_path = Path( '/home/jgcardelus/Desktop/coding-projects/cosmos-tv-settings/settings.json' ).path system = platform.system() if system == "Windows": chromedriver_name = "chromedriver.exe" data_dir_path = Path( "C:\\Users/jgcar/Desktop/Coding/AAA_MixedProjects/cosmos-tv-settings" ).path settings_path = Path( "C:\\Users/jgcar/Desktop/Coding/AAA_MixedProjects/cosmos-tv-settings/settings.json" ).path
def fileName(self): return Path.normalizePath(self.__sheet.fileName)
def __init__(self): xml = SimpleXML(Path.executeDirectory()) try: self.__lngSect = xml.openSection(SysConfig().lngFile) except Exception, err: raise err
def syscodeDstPluginRoot(self): root = self.__cfgSect["paths"].readString("dstPluginRoot") return script2sys(Path.realToExecutePath(root))
def __init(self): xml = SimpleXML(Path.executeDirectory()) cfgSect = xml.openSection("config.xml") if cfgSect is None: raise ConfigFixException("errNoConfig", file="config.xml") self.__cfgSect = cfgSect
def __getFullPath(rpath): path = Path.realToExecutePath(rpath) return sys2script(path)
def syscodeSrcPluginRoot(self): """ 数据源插件(相对可执行文件的路径) """ root = self.__cfgSect["paths"].readString("srcPluginRoot") return script2sys(Path.realToExecutePath(root))
def load_apps(): apps_path = Path('services/services.json').path apps_file = open(apps_path, 'r') apps = apps_file.read() server.emit('apps', apps)