-rw-r--r-- | scripts/builder/backendBuilder.py | 37 | ||||
-rw-r--r-- | scripts/builder/backends/devBuilder.py | 56 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 58 | ||||
-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 | ||||
-rwxr-xr-x | scripts/dev-proxy | 7 | ||||
-rwxr-xr-x | scripts/proxy/main.py | 95 |
9 files changed, 291 insertions, 37 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 | |||
@@ -9,7 +9,6 @@ import main | |||
9 | 9 | ||
10 | #=================================================================== | 10 | #=================================================================== |
11 | 11 | ||
12 | |||
13 | class BackendBuilder(object): | 12 | class BackendBuilder(object): |
14 | 13 | ||
15 | def __init__ (self, projectTargetDir, frontends, versions, settings): | 14 | def __init__ (self, projectTargetDir, frontends, versions, settings): |
@@ -50,10 +49,12 @@ class BackendBuilder(object): | |||
50 | 49 | ||
51 | 50 | ||
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 | ||
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 | ||
@@ -103,7 +104,7 @@ class BackendBuilder(object): | |||
103 | 104 | ||
104 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) | 105 | index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) |
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: |
108 | index = self.configureIndexContent(frontend.assemble()) | 109 | index = self.configureIndexContent(frontend.assemble()) |
109 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) | 110 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) |
@@ -112,20 +113,22 @@ class BackendBuilder(object): | |||
112 | 113 | ||
113 | self.createPackage() | 114 | self.createPackage() |
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 | ||
130 | 133 | ||
131 | #=================================================================== | 134 | #=================================================================== |
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..e52c31e 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py | |||
@@ -11,6 +11,8 @@ import urllib | |||
11 | 11 | ||
12 | import main | 12 | import main |
13 | 13 | ||
14 | #=============================================================================== | ||
15 | |||
14 | class FrontendBuilder(object): | 16 | class FrontendBuilder(object): |
15 | 17 | ||
16 | def __init__ (self, frontend, settings, repositoryVersion): | 18 | def __init__ (self, frontend, settings, repositoryVersion): |
@@ -27,10 +29,23 @@ class FrontendBuilder(object): | |||
27 | # self.repository = repository.repositoryWithPath(self.projectDir) | 29 | # self.repository = repository.repositoryWithPath(self.projectDir) |
28 | self.repositoryVersion = repositoryVersion | 30 | self.repositoryVersion = repositoryVersion |
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 | ||
35 | 50 | ||
36 | def absolutePathForSources (self): | 51 | def absolutePathForSources (self): |
@@ -58,16 +73,30 @@ class FrontendBuilder(object): | |||
58 | 73 | ||
59 | 74 | ||
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 | ||
67 | 94 | ||
68 | def copyResourcesToFolder (self, targetFolder): | 95 | def copyResourcesToFolder (self, targetFolder): |
69 | self.copyResources(self.projectDir, targetFolder, 'css') | 96 | self.copyResources(self.projectDir, targetFolder, 'css') |
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 | ||
72 | 101 | ||
73 | def loadFilesContent (self, basePath, files): | 102 | def loadFilesContent (self, basePath, files): |
@@ -279,13 +308,13 @@ class FrontendBuilder(object): | |||
279 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): | 308 | def replaceTemplatePlaceholders (self, pageTitle, copyright, css, code, jsLoadMode, version, versionType): |
280 | result = self.template() | 309 | result = self.template() |
281 | 310 | ||
282 | result = result.replace('@page.title@', pageTitle, 1) | 311 | result = result.replace('@page.title@', pageTitle) |
283 | result = result.replace('@copyright@', copyright, 1) | 312 | result = result.replace('@copyright@', copyright) |
284 | result = result.replace('@css@', css, 1) | 313 | result = result.replace('@css@', css) |
285 | #result = result.replace('@bookmarklet@', bookmarklet,1) | 314 | #result = result.replace('@bookmarklet@', bookmarklet) |
286 | result = result.replace('@application.version@', version, 1) | 315 | result = result.replace('@application.version@', version) |
287 | result = result.replace('@application.version.type@', versionType,1) | 316 | result = result.replace('@application.version.type@',versionType) |
288 | result = result.replace('@js_' + jsLoadMode + '@', code, 1) | 317 | result = result.replace('@js_' + jsLoadMode + '@', code) |
289 | 318 | ||
290 | result = re.sub('@js_[^@]+@', '', result) | 319 | result = re.sub('@js_[^@]+@', '', result) |
291 | 320 | ||
@@ -371,6 +400,7 @@ class FrontendBuilder(object): | |||
371 | '\n' + \ | 400 | '\n' + \ |
372 | self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])) | 401 | self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js'])) |
373 | jsLoadMode = 'LINKED' | 402 | jsLoadMode = 'LINKED' |
403 | versionType = 'development' | ||
374 | 404 | ||
375 | else: | 405 | else: |
376 | raise NotImplementedError() | 406 | raise NotImplementedError() |
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 | |||
@@ -10,7 +10,7 @@ import codecs | |||
10 | import itertools | 10 | import itertools |
11 | from collections import deque | 11 | from collections import deque |
12 | 12 | ||
13 | import frontendBuilder | 13 | #import frontendBuilder |
14 | import repository | 14 | import repository |
15 | 15 | ||
16 | pp = pprint.PrettyPrinter(indent=4, depth=4) | 16 | pp = pprint.PrettyPrinter(indent=4, depth=4) |
@@ -75,7 +75,7 @@ def assembleBackend (backend, frontends, versions): | |||
75 | 75 | ||
76 | builderModuleName = backend + 'Builder' | 76 | builderModuleName = backend + 'Builder' |
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) |
80 | builderClass = getattr(builderModule, builderClassName) | 80 | builderClass = getattr(builderModule, builderClassName) |
81 | 81 | ||
@@ -88,10 +88,22 @@ def build (settings, repository): | |||
88 | frontends = [] | 88 | frontends = [] |
89 | 89 | ||
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 | ||
96 | for backend in settings['backends']: | 108 | for backend in settings['backends']: |
97 | assembleBackend(backend, frontends, settings['versions']) | 109 | assembleBackend(backend, frontends, settings['versions']) |
@@ -114,6 +126,7 @@ def usage (message): | |||
114 | # print "build clean install" | 126 | # print "build clean install" |
115 | print "build install --ALL" | 127 | print "build install --ALL" |
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" |
118 | print "build install debug --backends php python --frontends beta gamma" | 131 | print "build install debug --backends php python --frontends beta gamma" |
119 | print "build install debug development --backends php python --frontends beta gamma gamma.mobile" | 132 | print "build install debug development --backends php python --frontends beta gamma gamma.mobile" |
@@ -122,7 +135,7 @@ def usage (message): | |||
122 | #-------------------------------------------------------------------- | 135 | #-------------------------------------------------------------------- |
123 | 136 | ||
124 | def allFrontends (): | 137 | def allFrontends (): |
125 | return ['beta', 'gamma', 'mobile'] | 138 | return ['beta', 'gamma', 'gamma.mobile'] |
126 | 139 | ||
127 | def allBackends (): | 140 | def allBackends (): |
128 | return ['php', 'python'] | 141 | return ['php', 'python'] |
@@ -134,6 +147,7 @@ def main (): | |||
134 | parameters = list(itertools.islice(sys.argv, 1, None)) | 147 | parameters = list(itertools.islice(sys.argv, 1, None)) |
135 | 148 | ||
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()) |
138 | 152 | ||
139 | clean() | 153 | clean() |
@@ -174,4 +188,4 @@ def main (): | |||
174 | 188 | ||
175 | 189 | ||
176 | if __name__ == "__main__": | 190 | if __name__ == "__main__": |
177 | main() | 191 | main() |
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 | |||