def buildSuite(src_suite, src_module, dest): """ Build jasmine suite. Params: src - src test.module dest - desination build path """ dest_module = os.path.abspath(os.path.normpath(dest + '/module.js')) tmpModule = generateTmpFilename() dest_suite = os.path.abspath(os.path.normpath(dest + '/test.js')) # copy third_party jasmine folder shutil.copytree( os.path.join(settings.THIRD_PARTY_PATH, 'jasmine'), os.path.join(dest, 'jasmine')) # copy jasmine_suite.html template compileTemplate( os.path.join(settings.TEMPLATES_PATH, 'jasmine_suite.html'), os.path.normpath(dest + '/suite.html'), {}, {}) # compile coffee module compileCoffeeModule(os.path.abspath(src_module), tmpModule) # cat with third_party cat([settings.JSON2, tmpModule], dest_module) # compile coffee test suite compileCoffeeModule(os.path.abspath(src_suite), dest_suite)
def createPyServer(self): serverTemplate = os.path.join(settings.WENDER_PATH, 'server/server.py') serverDest = os.path.join(self.confsite.build_path, 'wender/server.py') handlers = [] prefix = os.path.basename(self.projectPath) for conf in self.confappstatic: handlers.append({ 'module': prefix + '.' + conf.name, 'alias': '%sHandlers' % conf.name, }) compileTemplate(serverTemplate, serverDest, { 'handlers': handlers, 'db_host': self.confsite.db_host, 'db_port': self.confsite.db_port, 'db_name': self.confsite.db_name, 'db_user': self.confsite.db_user, 'db_pass': self.confsite.db_pass, 'debug': self.isDebug, 'cookie_secret': self.confsite.cookie_secret, }, {})
def compileApp(self, module, wenderCoffee): scssPath = os.path.abspath(os.path.normpath( module.path + ('/../style/%s' % module.name))) imgPath = os.path.abspath(os.path.normpath( module.path + '/../style/img')) imgTmpPath = os.path.join(settings.TMP_PATH, 'img') # generate dest filenames loaderTemplate = os.path.join(settings.TEMPLATES_PATH, 'app_loader.coffee') loaderCoffee = generateTmpFilename() loaderJs = generateTmpFilename() loaderJsMap = generateTmpFilename() loaderCompressJs = generateTmpFilename() loaderThirdPartyJs = generateTmpFilename() appCoffee = generateTmpFilename() appJs = generateTmpFilename() appCompressJs = generateTmpFilename() loaderScss = os.path.join(scssPath, 'loader.scss') loaderCss = generateTmpFilename() loaderCssMap = generateTmpFilename() loaderCompressCss = generateTmpFilename() mergedCoffee = generateTmpFilename() mainScss = os.path.join(scssPath, 'main.scss') mainCss = generateTmpFilename() mainCssMap = generateTmpFilename() mainCompressCss = generateTmpFilename() srcApp = os.path.join(settings.TEMPLATES_PATH, 'app.html') templateName = 'app-%s.html' % module.name destApp = generateTmpFilename() destCompressApp = generateTmpFilename() # create app loader coffee from template compileTemplate(loaderTemplate, loaderCoffee, { 'css': "{{ static_url('theme/%s.css') }}" % module.name, 'js': "{{ static_url('app/%s.js') }}" % module.name, 'app_name': module.name, 'message': '{{ message }}', }, {}) cat([wenderCoffee, loaderCoffee], mergedCoffee) compileCoffee(mergedCoffee, loaderJs) # cat loaderJs with json2 cat([settings.JSON2, loaderJs], loaderThirdPartyJs) # compile app loader coffee to js # compileCoffee(loaderCoffee, loaderJs) # compile sass style scssToCss(loaderScss, loaderCss) scssToCss(mainScss, mainCss) # copy img from style to tmp path shutil.copytree(imgPath, imgTmpPath) # compile mut module to appCoffee moduleCode = genCoffeeModuleCode(module) with open(appCoffee, 'w') as f: f.write(moduleCode) # compile appCoffee to appJs compileCoffee(appCoffee, appJs) # debug(dem) print appCoffee # compress loaderCss # compressCssJs(loaderCss, loaderJs) compressCss(loaderCss, loaderCssMap, loaderCompressCss, not self.isDebug) # compress mainCss compressCss(mainCss, mainCssMap, mainCompressCss, not self.isDebug) if not self.isDebug: # compress loaderJs compressJs(loaderThirdPartyJs, loaderCssMap, loaderCompressJs, loaderJsMap) # compress appJs compressJs(appJs, '', appCompressJs, '') else: shutil.copy(loaderThirdPartyJs, loaderCompressJs) shutil.copy(appJs, appCompressJs) # create app html template compileTemplate(srcApp, destApp, { 'lang': '{{ lang }}', 'title': '{{ title }}', }, { 'loader_css': loaderCompressCss, 'loader_js': loaderCompressJs, }) if not self.isDebug: # compress app-name.html compressHtml(destApp, destCompressApp) else: shutil.copy(destApp, destCompressApp) shutil.copy(destCompressApp, os.path.join(self.confsite.build_path, 'templates/%s' % templateName)) shutil.copy(mainCompressCss, os.path.join(self.confsite.build_path, 'static/theme/%s.css' % module.name)) shutil.copy(appCompressJs, os.path.join(self.confsite.build_path, 'static/app/%s.js' % module.name)) # remove tmp files safeRemoveFile(loaderCoffee) safeRemoveFile(loaderJs) safeRemoveFile(loaderThirdPartyJs) safeRemoveFile(loaderJsMap) safeRemoveFile(loaderCompressJs) safeRemoveFile(mergedCoffee) # safeRemoveFile(appCoffee) safeRemoveFile(appJs) safeRemoveFile(loaderCss) safeRemoveFile(loaderCssMap) safeRemoveFile(loaderCompressCss) safeRemoveFile(mainCss) safeRemoveFile(mainCssMap) safeRemoveFile(mainCompressCss) safeRemoveFile(destApp) shutil.rmtree(imgTmpPath)