-rw-r--r-- | scripts/builder/backendBuilder.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index 36b28ca..20b4bd0 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py | |||
@@ -1,19 +1,23 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, json | 4 | import sys, os, json |
5 | import shutil | 5 | import shutil |
6 | import hashlib | 6 | import hashlib |
7 | 7 | ||
8 | from functools import reduce | ||
9 | from operator import add | ||
10 | from itertools import izip | ||
11 | |||
8 | import main | 12 | import main |
9 | 13 | ||
10 | #=================================================================== | 14 | #=================================================================== |
11 | 15 | ||
12 | class BackendBuilder(object): | 16 | class BackendBuilder(object): |
13 | 17 | ||
14 | def __init__ (self, projectTargetDir, frontends, versions, settings): | 18 | def __init__ (self, projectTargetDir, frontends, versions, settings): |
15 | self.projectTargetDir = projectTargetDir | 19 | self.projectTargetDir = projectTargetDir |
16 | self.frontends = frontends | 20 | self.frontends = frontends |
17 | self.versions = versions | 21 | self.versions = versions |
18 | self.settings = settings | 22 | self.settings = settings |
19 | 23 | ||
@@ -63,28 +67,33 @@ class BackendBuilder(object): | |||
63 | file.write(content.encode('utf-8')) | 67 | file.write(content.encode('utf-8')) |
64 | file.close() | 68 | file.close() |
65 | 69 | ||
66 | 70 | ||
67 | def configureIndexContent (self, indexContent, requestPathPrefix = ".."): | 71 | def configureIndexContent (self, indexContent, requestPathPrefix = ".."): |
68 | result = indexContent | 72 | result = indexContent |
69 | result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] ) | 73 | result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] ) |
70 | result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) | 74 | result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) |
71 | 75 | ||
72 | return result | 76 | return result |
73 | 77 | ||
74 | 78 | ||
79 | def formatMAC (self, value): | ||
80 | x = iter(value) | ||
81 | return ' '.join([reduce(add, tup) for tup in izip(x, x, x, x)]) | ||
82 | |||
83 | |||
75 | def logChecksums (self, content, message): | 84 | def logChecksums (self, content, message): |
76 | md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest() | 85 | md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) |
77 | shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest() | 86 | shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) |
78 | sha256Digest= hashlib.sha256(content.encode('utf-8')).hexdigest() | 87 | sha256Digest= self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) |
79 | print message + ": " + md5Digest + " (md5)" | 88 | print message + ": " + md5Digest + " (md5)" |
80 | print message + ": " + shaDigest + " (sha1)" | 89 | print message + ": " + shaDigest + " (sha1)" |
81 | print message + ": " + sha256Digest + " (sha256)" | 90 | print message + ": " + sha256Digest + " (sha256)" |
82 | 91 | ||
83 | 92 | ||
84 | def shouldCompileCode (self): | 93 | def shouldCompileCode (self): |
85 | return ('debug' in self.versions) or ('install' in self.versions) | 94 | return ('debug' in self.versions) or ('install' in self.versions) |
86 | 95 | ||
87 | 96 | ||
88 | def run (self): | 97 | def run (self): |
89 | print self.name() + " - RUN" | 98 | print self.name() + " - RUN" |
90 | 99 | ||