summaryrefslogtreecommitdiff
path: root/scripts
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) (unidiff)
treed9366dae335a9bded5c0ee859895abe251790818 /scripts
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') (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 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# -*- coding: UTF-8 -*- 2# -*- coding: UTF-8 -*-
3 3
4import sys, os, json 4import sys, os, json
5import shutil 5import shutil
6import hashlib 6import hashlib
7 7
8import main 8import main
9 9
10#=================================================================== 10#===================================================================
11 11
12 12
13class BackendBuilder(object): 13class BackendBuilder(object):
14 14
15 def __init__ (self, projectTargetDir, frontends, versions, settings): 15 def __init__ (self, projectTargetDir, frontends, versions, settings):
16 self.projectTargetDir = projectTargetDir 16 self.projectTargetDir = projectTargetDir
17 self.frontends = frontends 17 self.frontends = frontends
18 self.versions = versions 18 self.versions = versions
19 self.settings = settings 19 self.settings = settings
20 20
21 # -------------------------------------------------------------------------- 21 # --------------------------------------------------------------------------
22 22
23 def name (self): 23 def name (self):
24 raise NotImplementedError() 24 raise NotImplementedError()
25 25
26 26
27 def relativePath (self): 27 def relativePath (self):
28 raise NotImplementedError() 28 raise NotImplementedError()
29 29
30 30
31 def compileCode (self): 31 def compileCode (self):
32 raise NotImplementedError() 32 raise NotImplementedError()
33 33
34 34
35 def createPackage (self): 35 def createPackage (self):
36 raise NotImplementedError() 36 raise NotImplementedError()
37 37
38 # -------------------------------------------------------------------------- 38 # --------------------------------------------------------------------------
39 39
40 def sourceFolder (self): 40 def sourceFolder (self):
41 return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src') 41 return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src')
42 42
43 43
44 def tempFolder (self): 44 def tempFolder (self):
45 return os.path.join(self.projectTargetDir, '.tmp', self.relativePath()) 45 return os.path.join(self.projectTargetDir, '.tmp', self.relativePath())
46 46
47 47
48 def frontEndTempFolder (self): 48 def frontEndTempFolder (self):
49 return self.tempFolder() 49 return self.tempFolder()
50 50
51 51
52 def developmentTargetFolder (self): 52 def developmentTargetFolder (self):
53 return os.path.join(self.projectTargetDir, 'development', self.relativePath()) 53 return os.path.join(self.projectTargetDir, 'development', self.relativePath())
54 54
55 def targetFolder (self): 55 def targetFolder (self):
56 return os.path.join(self.projectTargetDir, self.relativePath()) 56 return os.path.join(self.projectTargetDir, self.relativePath())
57 57
58 # -------------------------------------------------------------------------- 58 # --------------------------------------------------------------------------
59 59
60 def writeToFolder (self, folder, filename, content): 60 def writeToFolder (self, folder, filename, content):
61 file = open(os.path.join(folder, filename), 'w') 61 file = open(os.path.join(folder, filename), 'w')
62 file.write(content.encode('utf-8')) 62 file.write(content.encode('utf-8'))
63 file.close() 63 file.close()
64 64
65 65
66 def configureIndexContent (self, indexContent, requestPathPrefix = ".."): 66 def configureIndexContent (self, indexContent, requestPathPrefix = ".."):
67 result = indexContent 67 result = indexContent
68 result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] ) 68 result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] )
69 result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) 69 result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] )
70 70
71 return result 71 return result
72 72
73 73
74 def logChecksums (self, content, message): 74 def logChecksums (self, content, message):
75 md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest() 75 md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest()
76 shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest() 76 shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest()
77 sha256Digest= hashlib.sha256(content.encode('utf-8')).hexdigest() 77 sha256Digest= hashlib.sha256(content.encode('utf-8')).hexdigest()
78 print message + ": " + md5Digest + " (md5)" 78 print message + ": " + md5Digest + " (md5)"
79 print message + ": " + shaDigest + " (sha1)" 79 print message + ": " + shaDigest + " (sha1)"
80 print message + ": " + sha256Digest + " (sha256)" 80 print message + ": " + sha256Digest + " (sha256)"
81 81
82 82
83 def shouldCompileCode (self): 83 def shouldCompileCode (self):
84 return ('debug' in self.versions) or ('install' in self.versions) 84 return ('debug' in self.versions) or ('install' in self.versions)
85 85
86 86
87 def run (self): 87 def run (self):
88 print self.name() + " - RUN" 88 print self.name() + " - RUN"
89 89
90 if self.shouldCompileCode(): 90 if self.shouldCompileCode():
91 self.compileCode() 91 self.compileCode()
92 92
93 for frontend in self.frontends: 93 for frontend in self.frontends:
94 main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) 94 main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module))
95 95
96 if 'debug' in self.versions: 96 if 'debug' in self.versions:
97 frontend.copyResourcesToFolder(self.frontEndTempFolder()) 97 frontend.copyResourcesToFolder(self.frontEndTempFolder())
98 98
99 index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) 99 index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))
100 self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug.html'), index) 100 self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug.html'), index)
101 101
102 if 'install' in self.versions: 102 if 'install' in self.versions:
103 index = self.configureIndexContent(frontend.assemble()) 103 index = self.configureIndexContent(frontend.assemble())
104 self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index.html'), index) 104 self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index.html'), index)
105 105
106 self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") 106 self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum")
107 107
108 self.createPackage() 108 self.createPackage()
109 109
110 if 'development' in self.versions: 110 if 'development' in self.versions:
111 for frontend in self.frontends: 111 for frontend in self.frontends:
112 main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) 112 main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module))
113 113
114 index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) 114 index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url'])
115 self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development.html'), index) 115 self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index.html'), index)
116 116
117 117
118#=================================================================== 118#===================================================================