def clearFolder(path, protectedList=None): protected = set(['.gitignore']); if protectedList != None: infil = bash.readfile(protectedList); for row in csv.reader(infil): protected |= set(row); infil.close() for fil in bash.ls(path): if not fil in protected: bash.rm_r(path+"/"+fil);
def clearFolder(path, protectedList=None): protected = set(['.gitignore']) if protectedList != None: infil = bash.readfile(protectedList) for row in csv.reader(infil): protected |= set(row) infil.close() for fil in bash.ls(path): if not fil in protected: bash.rm_r(path + "/" + fil)
def compileServerOnlyTemplates(src, mVars, mFuns, package=[]): tmpPath = src+"/"+tmpFolder; if not bash.exists(tmpPath): bash.mkdir(tmpPath); for fil in bash.ls(src): path = src+"/"+fil; if bash.isdir(path) and fil != tmpFolder: compileServerOnlyTemplates(path, mVars, mFuns, package+[fil]); elif fil.endswith(tmpltExt): fil = fil[:len(fil)-len(tmpltExt)]; assert(bash.exists(src+"/"+fil+".tspec")); tmpTmplt = tmpPath+"/"+fil+".tmplt"; tmpTspec = tmpPath+"/"+fil+".tspec"; bash.cp_r(src+"/"+fil+".tmplt", tmpTmplt); bash.cp_r(src+"/"+fil+".tspec", tmpTspec); macros.run(tmpTmplt, mVars, mFuns); macros.run(tmpTspec, mVars, mFuns); compileTemplateToJava(tmpPath+"/"+fil, package); bash.rm_r(tmpPath);
def compileServerOnlyTemplates(src, mVars, mFuns, package=[]): tmpPath = src + "/" + tmpFolder if not bash.exists(tmpPath): bash.mkdir(tmpPath) for fil in bash.ls(src): path = src + "/" + fil if bash.isdir(path) and fil != tmpFolder: compileServerOnlyTemplates(path, mVars, mFuns, package + [fil]) elif fil.endswith(tmpltExt): fil = fil[:len(fil) - len(tmpltExt)] assert (bash.exists(src + "/" + fil + ".tspec")) tmpTmplt = tmpPath + "/" + fil + ".tmplt" tmpTspec = tmpPath + "/" + fil + ".tspec" bash.cp_r(src + "/" + fil + ".tmplt", tmpTmplt) bash.cp_r(src + "/" + fil + ".tspec", tmpTspec) macros.run(tmpTmplt, mVars, mFuns) macros.run(tmpTspec, mVars, mFuns) compileTemplateToJava(tmpPath + "/" + fil, package) bash.rm_r(tmpPath)
projectsForApp = set([]); projectsForAppFil = bash.readfile("build/app-web-projects.csv"); for row in csv.reader(projectsForAppFil): projectsForApp |= set(row); projectsForAppFil.close(); makeWebXML("server/servlet-list.csv", javaProjDir+"/war/WEB-INF/web.xml"); mVars, mFuns = macros.load("build/macros"); mVars['TEST'] = "false"; mVars['DEBUG'] = "true" if debug else "false"; mVars['LOCAL'] = "true" if local else "false"; if bash.exists(javaTmpltDir): bash.rm_r(javaTmpltDir); compileServerOnlyTemplates("server/templates", mVars, mFuns); platforms = ["web", "iOS"]; platformPaths = [javaProjDir+"/war", "iOS/Checkout Express/www"]; if bash.exists(tmpFolder): bash.rm_r(tmpFolder); bash.cp_r("webprojects", tmpFolder); compileFolder(tmpFolder); for i in xrange(0, len(platforms)): if bash.exists(platformPaths[i]): clearFolder(platformPaths[i], "server/protected_war.csv" if i == 0 else None) else: bash.mkdir(platformPaths[i])
server = localServer if local else webServer projectsForApp = set([]) projectsForAppFil = bash.readfile("build/app-web-projects.csv") for row in csv.reader(projectsForAppFil): projectsForApp |= set(row) projectsForAppFil.close() makeWebXML("server/servlet-list.csv", javaProjDir + "/war/WEB-INF/web.xml") mVars, mFuns = macros.load("build/macros") mVars['TEST'] = "false" mVars['DEBUG'] = "true" if debug else "false" mVars['LOCAL'] = "true" if local else "false" if bash.exists(javaTmpltDir): bash.rm_r(javaTmpltDir) compileServerOnlyTemplates("server/templates", mVars, mFuns) platforms = ["web", "iOS"] platformPaths = [javaProjDir + "/war", "iOS/Checkout Express/www"] if bash.exists(tmpFolder): bash.rm_r(tmpFolder) bash.cp_r("webprojects", tmpFolder) compileFolder(tmpFolder) for i in xrange(0, len(platforms)): if bash.exists(platformPaths[i]): clearFolder(platformPaths[i], "server/protected_war.csv" if i == 0 else None) else: bash.mkdir(platformPaths[i])