From 48c9280c9a255f2a85ad5729830df884e64a9c5d Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Wed, 17 Apr 2013 17:45:39 +0200 Subject: [PATCH] Updated build script to handle 'checksum' target The build script can now be invoked, for example, with the following options: > ./scripts/build checksum --frontend beta gamma --- .../properties/checksum.properties.json | 4 ++ scripts/builder/backendBuilder.py | 2 + scripts/builder/backends/checksumBuilder.py | 50 +++++++++++++++++++ scripts/builder/backends/devBuilder.py | 8 --- scripts/builder/main.py | 7 ++- scripts/builder/repository.py | 0 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 backend/checksum/properties/checksum.properties.json mode change 100644 => 100755 scripts/builder/backendBuilder.py create mode 100755 scripts/builder/backends/checksumBuilder.py mode change 100644 => 100755 scripts/builder/backends/devBuilder.py mode change 100644 => 100755 scripts/builder/repository.py diff --git a/backend/checksum/properties/checksum.properties.json b/backend/checksum/properties/checksum.properties.json new file mode 100644 index 0000000..1c2dae5 --- /dev/null +++ b/backend/checksum/properties/checksum.properties.json @@ -0,0 +1,4 @@ +{ + "request.path": "json", + "should.pay.toll": "true" +} \ No newline at end of file diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py old mode 100644 new mode 100755 index 20b4bd0..b4ee990 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py @@ -85,9 +85,11 @@ class BackendBuilder(object): md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) sha256Digest = self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) + print "-----" print message + ": " + md5Digest + " (md5)" print message + ": " + shaDigest + " (sha1)" print message + ": " + sha256Digest + " (sha256)" + print "=====" def shouldCompileCode (self): diff --git a/scripts/builder/backends/checksumBuilder.py b/scripts/builder/backends/checksumBuilder.py new file mode 100755 index 0000000..5f44c8a --- /dev/null +++ b/scripts/builder/backends/checksumBuilder.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +import os +import shutil +import subprocess +import main + +from backendBuilder import BackendBuilder + +class ChecksumBuilder(BackendBuilder): + + def name(self): + return "Checksum builder" + + + def relativePath(self): + return 'checksum' + + + def compileCode (self): + pass + + + def createPackage (self): + src = self.tempFolder() + dst = self.targetFolder() + + shutil.copytree(src, dst) + + + def run (self): + print self.name() + " - RUN (checksum)" + + 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()) + self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) + self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index" + submoduleExtension + ".html checksum") + print "" + + self.createPackage() + + diff --git a/scripts/builder/backends/devBuilder.py b/scripts/builder/backends/devBuilder.py old mode 100644 new mode 100755 index 671765e..354e014 --- a/scripts/builder/backends/devBuilder.py +++ b/scripts/builder/backends/devBuilder.py @@ -18,14 +18,6 @@ class DevBuilder(BackendBuilder): return 'dev' -# def frontEndTempFolder (self): -# return os.path.join(self.tempFolder(), 'src', 'main', 'webapp') - - -# def targetFolder (self): -# return self.projectTargetDir - - def compileCode (self): pass diff --git a/scripts/builder/main.py b/scripts/builder/main.py index b9fe04a..ecdbf6a 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py @@ -152,7 +152,7 @@ def main (): clean() versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) - settings['versions'] = versions; #['debug', 'install', 'development'] + settings['versions'] = versions; #['debug', 'install', 'development', 'checksum'] parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) if len(parameters) > 0: @@ -175,6 +175,11 @@ def main (): else: parameter = None + if 'checksum' in settings['versions']: + if not 'backends' in settings: + settings['backends'] = [] + settings['backends'].append('checksum') + if (not settings.has_key('versions')): usage("missing 'versions'") if (not settings.has_key('frontends')): diff --git a/scripts/builder/repository.py b/scripts/builder/repository.py old mode 100644 new mode 100755