Updated builder script
This commit is contained in:
parent
596e94dca4
commit
25bd3085c5
@ -9,7 +9,6 @@ import main
|
|||||||
|
|
||||||
#===================================================================
|
#===================================================================
|
||||||
|
|
||||||
|
|
||||||
class BackendBuilder(object):
|
class BackendBuilder(object):
|
||||||
|
|
||||||
def __init__ (self, projectTargetDir, frontends, versions, settings):
|
def __init__ (self, projectTargetDir, frontends, versions, settings):
|
||||||
@ -50,11 +49,13 @@ class BackendBuilder(object):
|
|||||||
|
|
||||||
|
|
||||||
def developmentTargetFolder (self):
|
def developmentTargetFolder (self):
|
||||||
return os.path.join(self.projectTargetDir, 'development', self.relativePath())
|
return os.path.join(self.projectTargetDir, 'development')
|
||||||
|
|
||||||
|
|
||||||
def targetFolder (self):
|
def targetFolder (self):
|
||||||
return os.path.join(self.projectTargetDir, self.relativePath())
|
return os.path.join(self.projectTargetDir, self.relativePath())
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
def writeToFolder (self, folder, filename, content):
|
def writeToFolder (self, folder, filename, content):
|
||||||
@ -112,20 +113,22 @@ class BackendBuilder(object):
|
|||||||
|
|
||||||
self.createPackage()
|
self.createPackage()
|
||||||
|
|
||||||
if 'development' in self.versions:
|
# if 'development' in self.versions:
|
||||||
for frontend in self.frontends:
|
# for frontend in self.frontends:
|
||||||
if (frontend.module == frontend.submodule):
|
# if (frontend.module == frontend.submodule):
|
||||||
submoduleExtension = ''
|
# submoduleExtension = ''
|
||||||
else:
|
# else:
|
||||||
submoduleExtension = '.' + frontend.submodule
|
# submoduleExtension = '.' + frontend.submodule
|
||||||
|
#
|
||||||
print "FRONTEND module: " + frontend.module
|
# print "FRONTEND module: " + frontend.module
|
||||||
print "FRONTEND submodule: " + frontend.submodule
|
# print "FRONTEND submodule: " + frontend.submodule
|
||||||
|
#
|
||||||
main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module))
|
## main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module))
|
||||||
|
# main.createFolder(self.developmentTargetFolder())
|
||||||
index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url'])
|
#
|
||||||
self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index)
|
# 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' + submoduleExtension + '.html'), index)
|
||||||
|
# self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module + submoduleExtension + '.html'), index)
|
||||||
|
|
||||||
|
|
||||||
#===================================================================
|
#===================================================================
|
||||||
|
56
scripts/builder/backends/devBuilder.py
Normal file
56
scripts/builder/backends/devBuilder.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import main
|
||||||
|
|
||||||
|
from backendBuilder import BackendBuilder
|
||||||
|
|
||||||
|
class DevBuilder(BackendBuilder):
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return "Dev builder"
|
||||||
|
|
||||||
|
|
||||||
|
def relativePath(self):
|
||||||
|
return 'dev'
|
||||||
|
|
||||||
|
|
||||||
|
# def frontEndTempFolder (self):
|
||||||
|
# return os.path.join(self.tempFolder(), 'src', 'main', 'webapp')
|
||||||
|
|
||||||
|
|
||||||
|
# def targetFolder (self):
|
||||||
|
# return self.projectTargetDir
|
||||||
|
|
||||||
|
|
||||||
|
def compileCode (self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def createPackage (self):
|
||||||
|
src = self.tempFolder()
|
||||||
|
dst = self.targetFolder()
|
||||||
|
|
||||||
|
shutil.copytree(src, dst)
|
||||||
|
|
||||||
|
|
||||||
|
def run (self):
|
||||||
|
print self.name() + " - RUN (dev)"
|
||||||
|
|
||||||
|
for frontend in self.frontends:
|
||||||
|
if (frontend.module == frontend.submodule):
|
||||||
|
submoduleExtension = ''
|
||||||
|
else:
|
||||||
|
submoduleExtension = '.' + frontend.submodule
|
||||||
|
|
||||||
|
main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module))
|
||||||
|
|
||||||
|
index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))
|
||||||
|
self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index)
|
||||||
|
|
||||||
|
self.createPackage()
|
||||||
|
|
||||||
|
|
@ -11,6 +11,8 @@ import urllib
|
|||||||
|
|
||||||
import main
|
import main
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
class FrontendBuilder(object):
|
class FrontendBuilder(object):
|
||||||
|
|
||||||
def __init__ (self, frontend, settings, repositoryVersion):
|
def __init__ (self, frontend, settings, repositoryVersion):
|
||||||
@ -28,9 +30,22 @@ class FrontendBuilder(object):
|
|||||||
self.repositoryVersion = repositoryVersion
|
self.repositoryVersion = repositoryVersion
|
||||||
self.processedFiles = {}
|
self.processedFiles = {}
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def name (self):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
def copyStaticResources (self, targetFolder):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def log (self, message):
|
def log (self, message):
|
||||||
print "frontend [" + self.module + "]: " + message
|
module = self.module
|
||||||
|
if (self.module != self.submodule):
|
||||||
|
module = module + "." + self.submodule
|
||||||
|
print "frontend [" + module + "]: " + message
|
||||||
|
|
||||||
|
|
||||||
def absolutePathForSources (self):
|
def absolutePathForSources (self):
|
||||||
@ -58,16 +73,30 @@ class FrontendBuilder(object):
|
|||||||
|
|
||||||
|
|
||||||
def copyResources (self, sourceFolder, destinationFolder, fileType):
|
def copyResources (self, sourceFolder, destinationFolder, fileType):
|
||||||
|
if fileType in self.settings:
|
||||||
for file in self.filterFiles(self.settings[fileType]):
|
for file in self.filterFiles(self.settings[fileType]):
|
||||||
src = self.absolutePathForSourceFile(fileType, file)
|
src = self.absolutePathForSourceFile(fileType, file)
|
||||||
dst = self.absolutePathForTargetFile(destinationFolder, fileType, file)
|
dst = self.absolutePathForTargetFile(destinationFolder, fileType, file)
|
||||||
main.createFolder(os.path.dirname(dst))
|
main.createFolder(os.path.dirname(dst))
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
else:
|
||||||
|
srcFolder = os.path.join(self.absolutePathForSources(), fileType)
|
||||||
|
dstFolder = os.path.join(destinationFolder, self.module, fileType)
|
||||||
|
if not(os.path.exists(dstFolder)):
|
||||||
|
shutil.copytree(srcFolder, dstFolder)
|
||||||
|
|
||||||
|
# try:
|
||||||
|
# shutil.copytree(srcFolder, dstFolder)
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def copyResourcesToFolder (self, targetFolder):
|
def copyResourcesToFolder (self, targetFolder):
|
||||||
self.copyResources(self.projectDir, targetFolder, 'css')
|
self.copyResources(self.projectDir, targetFolder, 'css')
|
||||||
self.copyResources(self.projectDir, targetFolder, 'js')
|
self.copyResources(self.projectDir, targetFolder, 'js')
|
||||||
|
self.copyResources(self.projectDir, targetFolder, 'images')
|
||||||
|
self.copyStaticResources(targetFolder)
|
||||||
|
|
||||||
|
|
||||||
def loadFilesContent (self, basePath, files):
|
def loadFilesContent (self, basePath, files):
|
||||||
@ -371,6 +400,7 @@ class FrontendBuilder(object):
|
|||||||
'\n' + \
|
'\n' + \
|
||||||
self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js']))
|
self.scriptTagsForFiles('file://' + str(os.path.join(self.absolutePathForSources(), 'js')), self.filterFiles(self.settings['js']))
|
||||||
jsLoadMode = 'LINKED'
|
jsLoadMode = 'LINKED'
|
||||||
|
versionType = 'development'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
14
scripts/builder/frontends/betaBuilder.py
Normal file
14
scripts/builder/frontends/betaBuilder.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from frontendBuilder import FrontendBuilder
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
class BetaBuilder(FrontendBuilder):
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return "/beta builder"
|
||||||
|
|
||||||
|
def copyStaticResources (self, targetFolder):
|
||||||
|
for file in self.filterFiles(self.settings['staticResources']):
|
||||||
|
src = self.absolutePathForSourceFile('staticResources', file)
|
||||||
|
dst = self.absolutePathForTargetFile(targetFolder, '', file)
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
|
26
scripts/builder/frontends/gammaBuilder.py
Normal file
26
scripts/builder/frontends/gammaBuilder.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from frontendBuilder import FrontendBuilder
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
class GammaBuilder(FrontendBuilder):
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return "/gamma builder"
|
||||||
|
|
||||||
|
def copyStaticResources (self, targetFolder):
|
||||||
|
resourcesToCopy = [
|
||||||
|
{'folder': 'html', 'source': 'exit_template.html', 'target': 'exit.html'},
|
||||||
|
{'folder': 'css', 'source': 'static.css', 'target': 'static.css'}
|
||||||
|
]
|
||||||
|
|
||||||
|
for resource in resourcesToCopy:
|
||||||
|
src = self.absolutePathForSourceFile(resource['folder'], resource['source'])
|
||||||
|
dst = self.absolutePathForTargetFile(targetFolder, '', resource['target'])
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
# src = self.absolutePathForSourceFile('html', 'exit_template.html')
|
||||||
|
# dst = self.absolutePathForTargetFile(targetFolder, '', 'exit.html')
|
||||||
|
# shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
# src = self.absolutePathForSourceFile('css', 'static.css')
|
||||||
|
# dst = self.absolutePathForTargetFile(targetFolder, '', 'static.css')
|
||||||
|
# shutil.copy2(src, dst)
|
9
scripts/builder/frontends/gamma_mobileBuilder.py
Normal file
9
scripts/builder/frontends/gamma_mobileBuilder.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from frontendBuilder import FrontendBuilder
|
||||||
|
|
||||||
|
class Gamma_MobileBuilder(FrontendBuilder):
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return "/gamma.mobile builder"
|
||||||
|
|
||||||
|
def copyStaticResources (self, targetFolder):
|
||||||
|
pass
|
@ -10,7 +10,7 @@ import codecs
|
|||||||
import itertools
|
import itertools
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
import frontendBuilder
|
#import frontendBuilder
|
||||||
import repository
|
import repository
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(indent=4, depth=4)
|
pp = pprint.PrettyPrinter(indent=4, depth=4)
|
||||||
@ -75,7 +75,7 @@ def assembleBackend (backend, frontends, versions):
|
|||||||
|
|
||||||
builderModuleName = backend + 'Builder'
|
builderModuleName = backend + 'Builder'
|
||||||
builderClassName = backend.capitalize() + 'Builder'
|
builderClassName = backend.capitalize() + 'Builder'
|
||||||
|
#print ("BUILD BACKENDS - module: " + builderModuleName + " , class: " + builderClassName)
|
||||||
builderModule = __import__(builderModuleName)
|
builderModule = __import__(builderModuleName)
|
||||||
builderClass = getattr(builderModule, builderClassName)
|
builderClass = getattr(builderModule, builderClassName)
|
||||||
|
|
||||||
@ -88,10 +88,22 @@ def build (settings, repository):
|
|||||||
frontends = []
|
frontends = []
|
||||||
|
|
||||||
if repository.areTherePendingChanges():
|
if repository.areTherePendingChanges():
|
||||||
|
if 'install' in settings['versions']:
|
||||||
|
raise Exception("repository has pending changes, can't 'install'")
|
||||||
|
else:
|
||||||
print "\nWARNING: repository has pending changes\n"
|
print "\nWARNING: repository has pending changes\n"
|
||||||
|
|
||||||
for frontend in settings['frontends']:
|
for frontend in settings['frontends']:
|
||||||
frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version()))
|
normalizedFrontendName = frontend.replace(".", "_")
|
||||||
|
builderModuleName = normalizedFrontendName + 'Builder'
|
||||||
|
builderClassName = normalizedFrontendName.title() + 'Builder'
|
||||||
|
|
||||||
|
#print ("BUILD FRONTEND - module: " + builderModuleName + " , class: " + builderClassName)
|
||||||
|
builderModule = __import__(builderModuleName)
|
||||||
|
builderClass = getattr(builderModule, builderClassName)
|
||||||
|
builder = builderClass(frontend, loadSettings('frontend', frontend), repository.version())
|
||||||
|
#builder = frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version())
|
||||||
|
frontends.append(builder)
|
||||||
|
|
||||||
for backend in settings['backends']:
|
for backend in settings['backends']:
|
||||||
assembleBackend(backend, frontends, settings['versions'])
|
assembleBackend(backend, frontends, settings['versions'])
|
||||||
@ -114,6 +126,7 @@ def usage (message):
|
|||||||
# print "build clean install"
|
# print "build clean install"
|
||||||
print "build install --ALL"
|
print "build install --ALL"
|
||||||
print "build install debug --ALL"
|
print "build install debug --ALL"
|
||||||
|
print "build install debug development --ALL"
|
||||||
# print "build clean install debug --ALL"
|
# print "build clean install debug --ALL"
|
||||||
print "build install debug --backends php python --frontends beta gamma"
|
print "build install debug --backends php python --frontends beta gamma"
|
||||||
print "build install debug development --backends php python --frontends beta gamma gamma.mobile"
|
print "build install debug development --backends php python --frontends beta gamma gamma.mobile"
|
||||||
@ -122,7 +135,7 @@ def usage (message):
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
def allFrontends ():
|
def allFrontends ():
|
||||||
return ['beta', 'gamma', 'mobile']
|
return ['beta', 'gamma', 'gamma.mobile']
|
||||||
|
|
||||||
def allBackends ():
|
def allBackends ():
|
||||||
return ['php', 'python']
|
return ['php', 'python']
|
||||||
@ -134,6 +147,7 @@ def main ():
|
|||||||
parameters = list(itertools.islice(sys.argv, 1, None))
|
parameters = list(itertools.islice(sys.argv, 1, None))
|
||||||
|
|
||||||
sys.path.append(os.path.join(scriptDir(), 'backends'))
|
sys.path.append(os.path.join(scriptDir(), 'backends'))
|
||||||
|
sys.path.append(os.path.join(scriptDir(), 'frontends'))
|
||||||
currentRepository = repository.repositoryWithPath(projectBaseDir())
|
currentRepository = repository.repositoryWithPath(projectBaseDir())
|
||||||
|
|
||||||
clean()
|
clean()
|
||||||
|
@ -56,11 +56,18 @@ class GitRepository(Repository):
|
|||||||
# http://gitorious.org/git-python
|
# http://gitorious.org/git-python
|
||||||
|
|
||||||
def revision (self):
|
def revision (self):
|
||||||
|
try:
|
||||||
return self.repository.head.commit.hexsha
|
return self.repository.head.commit.hexsha
|
||||||
|
except:
|
||||||
|
return self.repository.commits()[0].id
|
||||||
|
|
||||||
|
|
||||||
def areTherePendingChanges (self):
|
def areTherePendingChanges (self):
|
||||||
|
try:
|
||||||
return self.repository.is_dirty()
|
return self.repository.is_dirty()
|
||||||
|
except TypeError, te:
|
||||||
|
return self.repository.is_dirty
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===================================================================
|
#===================================================================
|
||||||
|
7
scripts/dev-proxy
Executable file
7
scripts/dev-proxy
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
readonly CURR_DIR=$(cd "$(dirname "$0")"; pwd -P)
|
||||||
|
|
||||||
|
#${CURR_DIR}/proxy/main.py $@
|
||||||
|
python ${CURR_DIR}/proxy/main.py $@
|
||||||
|
#twistd -y ${CURR_DIR}/proxy/main.py --pidfile=${CURR_DIR}/../target/proxy/proxy.pid --logfile=${CURR_DIR}/../target/proxy/logs/proxy.log
|
95
scripts/proxy/main.py
Executable file
95
scripts/proxy/main.py
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
from twisted.internet import reactor
|
||||||
|
from twisted.web import proxy, server, http, resource, static
|
||||||
|
from posixpath import basename, dirname
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
def scriptDir ():
|
||||||
|
return os.path.dirname(sys.argv[0])
|
||||||
|
|
||||||
|
def projectBaseDir ():
|
||||||
|
return os.path.abspath(scriptDir() + '/../..')
|
||||||
|
|
||||||
|
def projectTargetDir():
|
||||||
|
return projectBaseDir() + '/target/'
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class ClipperzTestSite(server.Site):
|
||||||
|
|
||||||
|
def __init__(self, resource, logPath=None, timeout=60 * 60 * 12):
|
||||||
|
server.Site.__init__(self, resource, logPath, timeout)
|
||||||
|
|
||||||
|
|
||||||
|
def getResourceFor(self, request):
|
||||||
|
if request.uri.startswith('/json') or request.uri.startswith('/dump'):
|
||||||
|
request.site = self
|
||||||
|
request.sitepath = copy.copy(request.prepath)
|
||||||
|
result = resource.getChildForRequest(self.resource, request)
|
||||||
|
|
||||||
|
else:
|
||||||
|
pathParts = request.uri.split('/')
|
||||||
|
version = pathParts[1]
|
||||||
|
|
||||||
|
if pathParts[2].startswith('index.'):
|
||||||
|
contentType = 'text/html'
|
||||||
|
absoluteFilePath = os.path.join(projectTargetDir(), 'dev', version, pathParts[2])
|
||||||
|
result = static.File(absoluteFilePath, contentType)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# http://homer.local:8888/beta/css/clipperz/images/loginInfoBackground.png
|
||||||
|
# pathParts: ['', 'beta', 'css', 'clipperz', 'images', 'loginInfoBackground.png']
|
||||||
|
try:
|
||||||
|
imagePathIndex = pathParts.index('images')
|
||||||
|
resourceType = 'images'
|
||||||
|
for _ in range(2, imagePathIndex):
|
||||||
|
del pathParts[2]
|
||||||
|
except:
|
||||||
|
resourceType = pathParts[2]
|
||||||
|
|
||||||
|
basePath = projectBaseDir() + '/frontend'
|
||||||
|
if resourceType == 'images':
|
||||||
|
fileExtension = os.path.splitext(request.uri)[1]
|
||||||
|
if fileExtension == '.png':
|
||||||
|
contentType = 'image/png'
|
||||||
|
elif fileExtension == '.jpg':
|
||||||
|
contentType = 'image/jpeg'
|
||||||
|
elif fileExtension == '.gif':
|
||||||
|
contentType = 'image/gif'
|
||||||
|
else:
|
||||||
|
print "ERROR - unknown image extension: " + fileExtension
|
||||||
|
|
||||||
|
absoluteFilePath = basePath + '/'.join(pathParts)
|
||||||
|
else:
|
||||||
|
resourceType = pathParts[2]
|
||||||
|
|
||||||
|
if resourceType == 'css':
|
||||||
|
contentType = 'text/css'
|
||||||
|
elif resourceType == 'js':
|
||||||
|
contentType = 'text/javascript'
|
||||||
|
else:
|
||||||
|
contentType = 'text/html'
|
||||||
|
|
||||||
|
absoluteFilePath = basePath + request.uri
|
||||||
|
|
||||||
|
result = static.File(absoluteFilePath, contentType)
|
||||||
|
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main ():
|
||||||
|
site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8084, '/java-backend'))
|
||||||
|
reactor.listenTCP(8888, site)
|
||||||
|
reactor.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user