summaryrefslogtreecommitdiff
path: root/scripts/builder/backendBuilder.py
authorGiulio Cesare Solaroli <giulio.cesare@solaroli.it>2012-03-03 22:06:27 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@solaroli.it>2012-03-03 22:06:27 (UTC)
commite7e021141d7906b537b3622ed706017f31222dfd (patch) (side-by-side diff)
treed9366dae335a9bded5c0ee859895abe251790818 /scripts/builder/backendBuilder.py
parenta0661c3b02aa26d6b08ff13dc321e09478868159 (diff)
parentcf9c0c34e1358452e0c7276c5b3ec6598f0c089d (diff)
downloadclipperz-e7e021141d7906b537b3622ed706017f31222dfd.zip
clipperz-e7e021141d7906b537b3622ed706017f31222dfd.tar.gz
clipperz-e7e021141d7906b537b3622ed706017f31222dfd.tar.bz2
Merge pull request #28 from gcsolaroli/master
Added static resources used by /beta when exiting the application
Diffstat (limited to 'scripts/builder/backendBuilder.py') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/builder/backendBuilder.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py
index 5ecdda0..3e61955 100644
--- a/scripts/builder/backendBuilder.py
+++ b/scripts/builder/backendBuilder.py
@@ -1,118 +1,118 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys, os, json
import shutil
import hashlib
import main
#===================================================================
class BackendBuilder(object):
def __init__ (self, projectTargetDir, frontends, versions, settings):
self.projectTargetDir = projectTargetDir
self.frontends = frontends
self.versions = versions
self.settings = settings
# --------------------------------------------------------------------------
def name (self):
raise NotImplementedError()
def relativePath (self):
raise NotImplementedError()
def compileCode (self):
raise NotImplementedError()
def createPackage (self):
raise NotImplementedError()
# --------------------------------------------------------------------------
def sourceFolder (self):
return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src')
def tempFolder (self):
return os.path.join(self.projectTargetDir, '.tmp', self.relativePath())
def frontEndTempFolder (self):
return self.tempFolder()
def developmentTargetFolder (self):
return os.path.join(self.projectTargetDir, 'development', self.relativePath())
def targetFolder (self):
return os.path.join(self.projectTargetDir, self.relativePath())
# --------------------------------------------------------------------------
def writeToFolder (self, folder, filename, content):
file = open(os.path.join(folder, filename), 'w')
file.write(content.encode('utf-8'))
file.close()
def configureIndexContent (self, indexContent, requestPathPrefix = ".."):
result = indexContent
result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] )
result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] )
return result
def logChecksums (self, content, message):
md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest()
shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest()
sha256Digest = hashlib.sha256(content.encode('utf-8')).hexdigest()
print message + ": " + md5Digest + " (md5)"
print message + ": " + shaDigest + " (sha1)"
print message + ": " + sha256Digest + " (sha256)"
def shouldCompileCode (self):
return ('debug' in self.versions) or ('install' in self.versions)
def run (self):
print self.name() + " - RUN"
if self.shouldCompileCode():
self.compileCode()
for frontend in self.frontends:
main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module))
if 'debug' in self.versions:
frontend.copyResourcesToFolder(self.frontEndTempFolder())
index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))
self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug.html'), index)
if 'install' in self.versions:
index = self.configureIndexContent(frontend.assemble())
self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index.html'), index)
self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum")
self.createPackage()
if 'development' in self.versions:
for frontend in self.frontends:
main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module))
index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url'])
- self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development.html'), index)
+ self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index.html'), index)
#===================================================================