author | Clipperz <info@clipperz.com> | 2013-01-08 15:12:19 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-08 15:12:19 (UTC) |
commit | 25bd3085c5464862172c5bd921deca550185fe83 (patch) (unidiff) | |
tree | 2ea95bdd3606e9721fac81ab072d093fd46005fe /scripts | |
parent | 596e94dca490619acced2e38fb3221cc7237b1ce (diff) | |
download | clipperz-25bd3085c5464862172c5bd921deca550185fe83.zip clipperz-25bd3085c5464862172c5bd921deca550185fe83.tar.gz clipperz-25bd3085c5464862172c5bd921deca550185fe83.tar.bz2 |
Updated builder script
-rw-r--r-- | scripts/builder/backendBuilder.py | 37 | ||||
-rw-r--r-- | scripts/builder/backends/devBuilder.py | 56 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 44 | ||||
-rw-r--r-- | scripts/builder/frontends/betaBuilder.py | 14 | ||||
-rw-r--r-- | scripts/builder/frontends/gammaBuilder.py | 26 | ||||
-rw-r--r-- | scripts/builder/frontends/gamma_mobileBuilder.py | 9 | ||||
-rwxr-xr-x | scripts/builder/main.py | 26 | ||||
-rw-r--r-- | scripts/builder/repository.py | 11 | ||||
-rwxr-xr-x | scripts/dev-proxy | 7 | ||||
-rwxr-xr-x | scripts/proxy/main.py | 95 |
10 files changed, 293 insertions, 32 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index 5b91678..36b28ca 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py | |||
@@ -11,3 +11,2 @@ import main | |||
11 | 11 | ||
12 | |||
13 | class BackendBuilder(object): | 12 | class BackendBuilder(object): |
@@ -52,3 +51,4 @@ class BackendBuilder(object): | |||
52 | def developmentTargetFolder (self): | 51 | def developmentTargetFolder (self): |
53 | return os.path.join(self.projectTargetDir, 'development', self.relativePath()) | 52 | return os.path.join(self.projectTargetDir, 'development') |
53 | |||
54 | 54 | ||
@@ -56,2 +56,3 @@ class BackendBuilder(object): | |||
56 | return os.path.join(self.projectTargetDir, self.relativePath()) | 56 | return os.path.join(self.projectTargetDir, self.relativePath()) |
57 | |||
57 | 58 | ||
@@ -105,3 +106,3 @@ class BackendBuilder(object): | |||
105 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug' + submoduleExtension + '.html'), index) | 106 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug' + submoduleExtension + '.html'), index) |
106 | 107 | ||
107 | if 'install' in self.versions: | 108 | if 'install' in self.versions: |
@@ -114,16 +115,18 @@ class BackendBuilder(object): | |||
114 | 115 | ||
115 | if 'development' in self.versions: | 116 | # if 'development' in self.versions: |
116 | for frontend in self.frontends: | 117 | # for frontend in self.frontends: |
117 | if (frontend.module == frontend.submodule): | 118 | # if (frontend.module == frontend.submodule): |
118 | submoduleExtension = '' | 119 | # submoduleExtension = '' |
119 | else: | 120 | # else: |
120 | submoduleExtension = '.' + frontend.submodule | 121 | # submoduleExtension = '.' + frontend.submodule |
121 | 122 | # | |
122 | print "FRONTEND module: " + frontend.module | 123 | # print "FRONTEND module: " + frontend.module |
123 | print "FRONTEND submodule: " + frontend.submodule | 124 | # print "FRONTEND submodule: " + frontend.submodule |
124 | 125 | # | |
125 | main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) | 126 | ## main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) |
126 | 127 | # main.createFolder(self.developmentTargetFolder()) | |
127 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) | 128 | # |
128 | self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) | 129 | # index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) |
130 | ## self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development' + submoduleExtension + '.html'), index) | ||
131 | # self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module + submoduleExtension + '.html'), index) | ||
129 | 132 | ||
diff --git a/scripts/builder/backends/devBuilder.py b/scripts/builder/backends/devBuilder.py new file mode 100644 index 0000000..671765e --- a/dev/null +++ b/scripts/builder/backends/devBuilder.py | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # -*- coding: UTF-8 -*- | ||
3 | |||
4 | import os | ||
5 | import shutil | ||
6 | import subprocess | ||
7 | import main | ||
8 | |||
9 | from backendBuilder import BackendBuilder | ||
10 | |||
11 | class DevBuilder(BackendBuilder): | ||
12 | |||
13 | def name(self): | ||
14 | return "Dev builder" | ||
15 | |||
16 | |||
17 | def relativePath(self): | ||
18 | return 'dev' | ||
19 | |||
20 | |||
21 | #def frontEndTempFolder (self): | ||
22 | # return os.path.join(self.tempFolder(), 'src', 'main', 'webapp') | ||
23 | |||
24 | |||
25 | #def targetFolder (self): | ||
26 | # return self.projectTargetDir | ||
27 | |||
28 | |||
29 | def compileCode (self): | ||
30 | pass | ||
31 | |||
32 | |||
33 | def createPackage (self): | ||
34 | src = self.tempFolder() | ||
35 | dst = self.targetFolder() | ||
36 | |||
37 | shutil.copytree(src, dst) | ||
38 | |||
39 | |||
40 | def run (self): | ||
41 | print self.name() + " - RUN (dev)" | ||
42 | |||
43 | for frontend in self.frontends: | ||
44 | if (frontend.module == frontend.submodule): | ||
45 | submoduleExtension = '' | ||
46 | else: | ||
47 | submoduleExtension = '.' + frontend.submodule | ||
48 | |||
49 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) | ||
50 | |||
51 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) | ||
52 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) | ||
53 | |||
54 | self.createPackage() | ||
55 | |||
56 | |||
diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py index 1f0f92f..fc603c4 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py | |||
@@ -13,2 +13,4 @@ import main | |||
13 | 13 | ||
14 | #=============================================================================== | ||
15 | |||
14 | class FrontendBuilder(object): | 16 | class FrontendBuilder(object): |
@@ -29,6 +31,19 @@ class FrontendBuilder(object): | |||
29 | self.processedFiles = {} | 31 | self.processedFiles = {} |
30 | 32 | ||
33 | #--------------------------------------------------------------------------- | ||
34 | |||
35 | def name (self): | ||
36 | raise NotImplementedError() | ||
37 | |||
38 | |||
39 | def copyStaticResources (self, targetFolder): | ||
40 | raise NotImplementedError() | ||
41 | |||
42 | #--------------------------------------------------------------------------- | ||
31 | 43 | ||
32 | def log (self, message): | 44 | def log (self, message): |
33 | print "frontend [" + self.module + "]: " + message | 45 | module = self.module |
46 | if (self.module != self.submodule): | ||
47 | module = module + "." + self.submodule | ||
48 | print "frontend [" + module + "]: " + message | ||
34 | 49 | ||
@@ -60,7 +75,19 @@ class FrontendBuilder(object): | |||
60 | def copyResources (self, sourceFolder, destinationFolder, fileType): | 75 | def copyResources (self, sourceFolder, destinationFolder, fileType): |
61 | for file in self.filterFiles(self.settings[fileType]): | 76 | if fileType in self.settings: |
62 | src = self.absolutePathForSourceFile(fileType, file) | 77 | for file in self.filterFiles(self.settings[fileType]): |
63 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) | 78 | src = self.absolutePathForSourceFile(fileType, file) |
64 | main.createFolder(os.path.dirname(dst)) | 79 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) |
65 | shutil.copy2(src, dst) | 80 | main.createFolder(os.path.dirname(dst)) |
81 | shutil.copy2(src, dst) | ||
82 | else: | ||
83 | srcFolder = os.path.join(self.absolutePathForSources(), fileType) | ||
84 | dstFolder = os.path.join(destinationFolder, self.module, fileType) | ||
85 | if not(os.path.exists(dstFolder)): | ||
86 | shutil.copytree(srcFolder, dstFolder) | ||
87 | |||
88 | # try: | ||
89 | # shutil.copytree(srcFolder, dstFolder) | ||
90 | # except: | ||
91 | # pass | ||
92 | |||
66 | 93 | ||
@@ -70,2 +97,4 @@ class FrontendBuilder(object): | |||
70 | self.copyResources(self.projectDir, targetFolder, 'js') | 97 | self.copyResources(self.projectDir, targetFolder, 'js') |
98 | self.copyResources(self.projectDir, targetFolder, 'images') | ||
99 | self.copyStaticResources(targetFolder) | ||
71 | 100 | ||
@@ -373,2 +402,3 @@ class FrontendBuilder(object): | |||
373 | jsLoadMode = 'LINKED' | 402 | jsLoadMode = 'LINKED' |
403 | versionType = 'development' | ||
374 | 404 | ||
diff --git a/scripts/builder/frontends/betaBuilder.py b/scripts/builder/frontends/betaBuilder.py new file mode 100644 index 0000000..c5a3e76 --- a/dev/null +++ b/scripts/builder/frontends/betaBuilder.py | |||
@@ -0,0 +1,14 @@ | |||
1 | from frontendBuilder import FrontendBuilder | ||
2 | import shutil | ||
3 | |||
4 | class BetaBuilder(FrontendBuilder): | ||
5 | |||
6 | def name(self): | ||
7 | return "/beta builder" | ||
8 | |||
9 | def copyStaticResources (self, targetFolder): | ||
10 | for file in self.filterFiles(self.settings['staticResources']): | ||
11 | src = self.absolutePathForSourceFile('staticResources', file) | ||
12 | dst = self.absolutePathForTargetFile(targetFolder, '', file) | ||
13 | shutil.copy2(src, dst) | ||
14 | |||
diff --git a/scripts/builder/frontends/gammaBuilder.py b/scripts/builder/frontends/gammaBuilder.py new file mode 100644 index 0000000..35fa68b --- a/dev/null +++ b/scripts/builder/frontends/gammaBuilder.py | |||
@@ -0,0 +1,26 @@ | |||
1 | from frontendBuilder import FrontendBuilder | ||
2 | import shutil | ||
3 | |||
4 | class GammaBuilder(FrontendBuilder): | ||
5 | |||
6 | def name(self): | ||
7 | return "/gamma builder" | ||
8 | |||
9 | def copyStaticResources (self, targetFolder): | ||
10 | resourcesToCopy = [ | ||
11 | {'folder': 'html', 'source': 'exit_template.html','target': 'exit.html'}, | ||
12 | {'folder': 'css', 'source': 'static.css', 'target': 'static.css'} | ||
13 | ] | ||
14 | |||
15 | for resource in resourcesToCopy: | ||
16 | src = self.absolutePathForSourceFile(resource['folder'], resource['source']) | ||
17 | dst = self.absolutePathForTargetFile(targetFolder, '', resource['target']) | ||
18 | shutil.copy2(src, dst) | ||
19 | |||
20 | # src = self.absolutePathForSourceFile('html', 'exit_template.html') | ||
21 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'exit.html') | ||
22 | # shutil.copy2(src, dst) | ||
23 | |||
24 | # src = self.absolutePathForSourceFile('css', 'static.css') | ||
25 | # dst = self.absolutePathForTargetFile(targetFolder, '', 'static.css') | ||
26 | # shutil.copy2(src, dst) | ||
diff --git a/scripts/builder/frontends/gamma_mobileBuilder.py b/scripts/builder/frontends/gamma_mobileBuilder.py new file mode 100644 index 0000000..f2e80c9 --- a/dev/null +++ b/scripts/builder/frontends/gamma_mobileBuilder.py | |||
@@ -0,0 +1,9 @@ | |||
1 | from frontendBuilder import FrontendBuilder | ||
2 | |||
3 | class Gamma_MobileBuilder(FrontendBuilder): | ||
4 | |||
5 | def name(self): | ||
6 | return "/gamma.mobile builder" | ||
7 | |||
8 | def copyStaticResources (self, targetFolder): | ||
9 | pass | ||
diff --git a/scripts/builder/main.py b/scripts/builder/main.py index 6fce65d..b9fe04a 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py | |||
@@ -12,3 +12,3 @@ from collections import deque | |||
12 | 12 | ||
13 | import frontendBuilder | 13 | #import frontendBuilder |
14 | import repository | 14 | import repository |
@@ -77,3 +77,3 @@ def assembleBackend (backend, frontends, versions): | |||
77 | builderClassName = backend.capitalize() + 'Builder' | 77 | builderClassName = backend.capitalize() + 'Builder' |
78 | 78 | #print ("BUILD BACKENDS - module: " + builderModuleName + " , class: " + builderClassName) | |
79 | builderModule = __import__(builderModuleName) | 79 | builderModule = __import__(builderModuleName) |
@@ -90,6 +90,18 @@ def build (settings, repository): | |||
90 | if repository.areTherePendingChanges(): | 90 | if repository.areTherePendingChanges(): |
91 | print "\nWARNING: repository has pending changes\n" | 91 | if 'install' in settings['versions']: |
92 | raise Exception("repository has pending changes, can't 'install'") | ||
93 | else: | ||
94 | print "\nWARNING: repository has pending changes\n" | ||
92 | 95 | ||
93 | for frontend in settings['frontends']: | 96 | for frontend in settings['frontends']: |
94 | frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version())) | 97 | normalizedFrontendName = frontend.replace(".", "_") |
98 | builderModuleName = normalizedFrontendName + 'Builder' | ||
99 | builderClassName = normalizedFrontendName.title() + 'Builder' | ||
100 | |||
101 | #print ("BUILD FRONTEND - module: " + builderModuleName + " , class: " + builderClassName) | ||
102 | builderModule = __import__(builderModuleName) | ||
103 | builderClass = getattr(builderModule, builderClassName) | ||
104 | builder = builderClass(frontend, loadSettings('frontend', frontend), repository.version()) | ||
105 | #builder = frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version()) | ||
106 | frontends.append(builder) | ||
95 | 107 | ||
@@ -116,2 +128,3 @@ def usage (message): | |||
116 | print "build install debug --ALL" | 128 | print "build install debug --ALL" |
129 | print "build install debug development --ALL" | ||
117 | # print "build clean install debug --ALL" | 130 | # print "build clean install debug --ALL" |
@@ -124,3 +137,3 @@ def usage (message): | |||
124 | def allFrontends (): | 137 | def allFrontends (): |
125 | return ['beta', 'gamma', 'mobile'] | 138 | return ['beta', 'gamma', 'gamma.mobile'] |
126 | 139 | ||
@@ -136,2 +149,3 @@ def main (): | |||
136 | sys.path.append(os.path.join(scriptDir(), 'backends')) | 149 | sys.path.append(os.path.join(scriptDir(), 'backends')) |
150 | sys.path.append(os.path.join(scriptDir(), 'frontends')) | ||
137 | currentRepository = repository.repositoryWithPath(projectBaseDir()) | 151 | currentRepository = repository.repositoryWithPath(projectBaseDir()) |
@@ -176,2 +190,2 @@ def main (): | |||
176 | if __name__ == "__main__": | 190 | if __name__ == "__main__": |
177 | main() | 191 | main() |
diff --git a/scripts/builder/repository.py b/scripts/builder/repository.py index 0045de7..a47e249 100644 --- a/scripts/builder/repository.py +++ b/scripts/builder/repository.py | |||
@@ -58,3 +58,6 @@ class GitRepository(Repository): | |||
58 | def revision (self): | 58 | def revision (self): |
59 | return self.repository.head.commit.hexsha | 59 | try: |
60 | return self.repository.head.commit.hexsha | ||
61 | except: | ||
62 | return self.repository.commits()[0].id | ||
60 | 63 | ||
@@ -62,3 +65,7 @@ class GitRepository(Repository): | |||
62 | def areTherePendingChanges (self): | 65 | def areTherePendingChanges (self): |
63 | return self.repository.is_dirty() | 66 | try: |
67 | return self.repository.is_dirty() | ||
68 | except TypeError, te: | ||
69 | return self.repository.is_dirty | ||
70 | |||
64 | 71 | ||
diff --git a/scripts/dev-proxy b/scripts/dev-proxy new file mode 100755 index 0000000..e5980e3 --- a/dev/null +++ b/scripts/dev-proxy | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | readonly CURR_DIR=$(cd "$(dirname "$0")"; pwd -P) | ||
4 | |||
5 | #${CURR_DIR}/proxy/main.py $@ | ||
6 | python ${CURR_DIR}/proxy/main.py $@ | ||
7 | #twistd -y ${CURR_DIR}/proxy/main.py --pidfile=${CURR_DIR}/../target/proxy/proxy.pid --logfile=${CURR_DIR}/../target/proxy/logs/proxy.log \ No newline at end of file | ||
diff --git a/scripts/proxy/main.py b/scripts/proxy/main.py new file mode 100755 index 0000000..107ba16 --- a/dev/null +++ b/scripts/proxy/main.py | |||
@@ -0,0 +1,95 @@ | |||
1 | from twisted.internet import reactor | ||
2 | from twisted.web import proxy, server, http, resource, static | ||
3 | from posixpath import basename, dirname | ||
4 | |||
5 | import copy | ||
6 | import sys | ||
7 | import os | ||
8 | import pprint | ||
9 | |||
10 | #-------------------------------------------------------------------- | ||
11 | |||
12 | def scriptDir (): | ||
13 | return os.path.dirname(sys.argv[0]) | ||
14 | |||
15 | def projectBaseDir (): | ||
16 | return os.path.abspath(scriptDir() + '/../..') | ||
17 | |||
18 | def projectTargetDir(): | ||
19 | return projectBaseDir() + '/target/' | ||
20 | |||
21 | #-------------------------------------------------------------------- | ||
22 | |||
23 | class ClipperzTestSite(server.Site): | ||
24 | |||
25 | def __init__(self, resource, logPath=None, timeout=60 * 60 * 12): | ||
26 | server.Site.__init__(self, resource, logPath, timeout) | ||
27 | |||
28 | |||
29 | def getResourceFor(self, request): | ||
30 | if request.uri.startswith('/json') or request.uri.startswith('/dump'): | ||
31 | request.site = self | ||
32 | request.sitepath = copy.copy(request.prepath) | ||
33 | result = resource.getChildForRequest(self.resource, request) | ||
34 | |||
35 | else: | ||
36 | pathParts = request.uri.split('/') | ||
37 | version = pathParts[1] | ||
38 | |||
39 | if pathParts[2].startswith('index.'): | ||
40 | contentType = 'text/html' | ||
41 | absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2]) | ||
42 | result = static.File(absoluteFilePath, contentType) | ||
43 | |||
44 | else: | ||
45 | #http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png | ||
46 | #pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png'] | ||
47 | try: | ||
48 | imagePathIndex = pathParts.index('images') | ||
49 | resourceType = 'images' | ||
50 | for _ in range(2, imagePathIndex): | ||
51 | del pathParts[2] | ||
52 | except: | ||
53 | resourceType = pathParts[2] | ||
54 | |||
55 | basePath = projectBaseDir() + '/frontend' | ||
56 | if resourceType == 'images': | ||
57 | fileExtension = os.path.splitext(request.uri)[1] | ||
58 | if fileExtension == '.png': | ||
59 | contentType = 'image/png' | ||
60 | elif fileExtension == '.jpg': | ||
61 | contentType = 'image/jpeg' | ||
62 | elif fileExtension == '.gif': | ||
63 | contentType = 'image/gif' | ||
64 | else: | ||
65 | print "ERROR - unknown image extension: " + fileExtension | ||
66 | |||
67 | absoluteFilePath = basePath + '/'.join(pathParts) | ||
68 | else: | ||
69 | resourceType = pathParts[2] | ||
70 | |||
71 | if resourceType == 'css': | ||
72 | contentType = 'text/css' | ||
73 | elif resourceType == 'js': | ||
74 | contentType = 'text/javascript' | ||
75 | else: | ||
76 | contentType = 'text/html' | ||
77 | |||
78 | absoluteFilePath = basePath + request.uri | ||
79 | |||
80 | result = static.File(absoluteFilePath, contentType) | ||
81 | |||
82 | |||
83 | return result | ||
84 | |||
85 | |||
86 | |||
87 | def main (): | ||
88 | site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8084, '/java-backend')) | ||
89 | reactor.listenTCP(8888, site) | ||
90 | reactor.run() | ||
91 | |||
92 | |||
93 | if __name__ == "__main__": | ||
94 | main() | ||
95 | |||