author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-05 22:54:04 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-05 22:54:04 (UTC) |
commit | 13ebf1b1987a1566d081ff1ba89b4dca197b7d2e (patch) (side-by-side diff) | |
tree | dcd7121febab3bd2c1436d2f55a5a2ac07ad2e83 | |
parent | bbd415769410aac765f889e74a28992bc8483f94 (diff) | |
parent | 2a98e81b954ab84efc8d3f4e1d837bf190f77d7d (diff) | |
download | clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.zip clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.gz clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.bz2 |
Merge pull request #7 from themiurgo/master
Fixes shebang for python builder scripts
-rw-r--r-- | scripts/builder/backendBuilder.py | 2 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 2 | ||||
-rwxr-xr-x | scripts/builder/main.py | 2 | ||||
-rw-r--r-- | scripts/builder/phpBuilder.py | 2 | ||||
-rw-r--r-- | scripts/builder/pythonBuilder.py | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index f5dc7b2..16dbe2f 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py @@ -1,89 +1,89 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys, os, json import shutil import main import hashlib class BackendBuilder: 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): pass def copyCompiledCodeToTargetDir (self): src = self.sourceFolder() dst = self.targetFolder() main.createFolder(os.path.dirname(dst)) shutil.copytree(src, dst) def sourceFolder (self): return main.projectBaseDir() + '/backend/' + self.relativePath() + '/src' def targetFolder (self): return self.projectTargetDir + self.relativePath() def createTargetFolder (self): main.createFolder(self.targetFolder()) # def copyFrontendResources (self, frontend): # print "copying resources for frontend: " + frontend # print "SETTINGS: " + str(self.settings) def writeToTargetFolder (self, filename, content): file = open(self.targetFolder() + '/' + filename, 'w') file.write(content.encode('utf-8')) file.close() def configureIndexContent (self, indexContent): result = indexContent result = result.replace( '@request.path@', 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 run (self): print self.name() + " - RUN" self.compileCode() self.copyCompiledCodeToTargetDir() for frontend in self.frontends: frontendPath = frontend.module + '/' if 'debug' in self.versions: frontend.copyResourcesToTargetFolder(self.targetFolder()) #self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assembleDebugVersion())) self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))) if 'install' in self.versions: index = self.configureIndexContent(frontend.assemble()) self.writeToTargetFolder(frontendPath + 'index.html', index) self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py index b796438..55054ee 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py @@ -1,97 +1,97 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys, os, re import cssmin import jsmin import codecs import shutil import StringIO import urllib #from mercurial import ui, hg #from mercurial.node import hex from dulwich.repo import Repo import main class FrontendBuilder: def __init__ (self, frontend, settings): if '.' in frontend: moduleComponents = frontend.split('.') self.module = moduleComponents[0] self.submodule = moduleComponents[1] else: self.module = frontend self.submodule = frontend self.settings = settings self.projectDir = main.projectBaseDir() self.processedFiles = {} def mercurialRepositoryVersion (self): repo = hg.repository(ui.ui(), self.projectDir) context = repo['tip'] result = str(context) return result def gitRepositoryVersion (self): repo = Repo(self.projectDir) #if repo.is_dirty(): # print "WARNING: build run with dirty repository" result = repo.refs['HEAD'] return result def repositoryVersion (self): cacheKey = 'repositoryVersion' if not self.processedFiles.has_key(cacheKey): #result = self.mercurialRepositoryVersion() result = self.gitRepositoryVersion() self.processedFiles[cacheKey] = result else: result = self.processedFiles[cacheKey] return result #def relativePath (self): # return self.module # def log (self, message): print "frontend [" + self.module + "]: " + message def absolutePathForSourceFile (self, folder, basePath, file): return folder + '/frontend/' + self.module + '/' + basePath + '/' + file def absolutePathForTargetFile (self, folder, basePath, file): return folder + '/' + self.module + '/' + basePath + '/' + file def filterFiles (self, files): result = [] for file in files: if file.startswith('--'): pass else: result.append(file) return result def copyResources (self, sourceFolder, destinationFolder, fileType): for file in self.filterFiles(self.settings[fileType]): src = self.absolutePathForSourceFile(sourceFolder, fileType, file) dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) main.createFolder(os.path.dirname(dst)) diff --git a/scripts/builder/main.py b/scripts/builder/main.py index ba0c72a..94f738f 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py @@ -1,97 +1,97 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys, os, json import shutil import pprint import frontendBuilder import codecs import itertools from collections import deque from phpBuilder import PhpBuilder from pythonBuilder import PythonBuilder pp = pprint.PrettyPrinter(indent=4, depth=4) #-------------------------------------------------------------------- def scriptDir (): return os.path.dirname(sys.argv[0]) def projectBaseDir (): return os.path.abspath(scriptDir() + '/../..') def projectTargetDir(): return projectBaseDir() + '/target/' #-------------------------------------------------------------------- def createFolder (path): if not os.path.exists(path): os.makedirs(path) #-------------------------------------------------------------------- def loadSettings (component, module): print "MODULE: " + module if '.' in module: moduleComponents = module.split('.') module = moduleComponents[0] submodule = moduleComponents[1] else: submodule = module settings = codecs.open(projectBaseDir() + '/' + component + '/' + module + '/properties/' + submodule + '.properties.json', 'r', 'utf-8') result = json.load(settings) settings.close return result #==================================================================== # # def assembleFrontend (frontend, versions): # result = {} # settings = loadSettings('frontend', frontend) # builder = frontendBuilder.FrontendBuilder(frontend, settings, projectBaseDir()) # # for version in versions: # if version == 'install': # result[version] = builder.assembleInstallVersion() # elif version == 'debug': # result[version] = builder.assembleDebugVersion() # else: # raise Exception('unrecognized version: ' + version) # # return result # #==================================================================== def assembleBackend (backend, frontends, versions): settings = loadSettings('backend', backend) if backend == 'php': backendBuilder = PhpBuilder(projectTargetDir(), frontends, versions, settings) elif backend == 'python': backendBuilder = PythonBuilder(projectTargetDir(), frontends, versions, settings) #elif backend == 'java': # buildJavaBackend (frontends, versions, settings) else: raise Exception('unrecognized backend: ' + backend) backendBuilder.run() #==================================================================== def build (settings): frontends = [] for frontend in settings['frontends']: frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend))) for backend in settings['backends']: assembleBackend(backend, frontends, settings['versions']) #-------------------------------------------------------------------- diff --git a/scripts/builder/phpBuilder.py b/scripts/builder/phpBuilder.py index 9512192..cb4661d 100644 --- a/scripts/builder/phpBuilder.py +++ b/scripts/builder/phpBuilder.py @@ -1,14 +1,14 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: UTF-8 -*- from backendBuilder import BackendBuilder class PhpBuilder(BackendBuilder): def name(self): return "PHP builder" def relativePath(self): return 'php' diff --git a/scripts/builder/pythonBuilder.py b/scripts/builder/pythonBuilder.py index 44c62a8..a84598d 100644 --- a/scripts/builder/pythonBuilder.py +++ b/scripts/builder/pythonBuilder.py @@ -1,14 +1,14 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: UTF-8 -*- from backendBuilder import BackendBuilder class PythonBuilder(BackendBuilder): def name(self): return "Python builder" def relativePath(self): return 'python' |