1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-12-19 04:47:02 +01:00

5 Commits

Author SHA1 Message Date
Graham Eades
ad13fffb07 Tidy up key test 2020-03-03 11:43:50 +00:00
Graham Eades
1f38736b37 Fixed print in repository check 2020-03-02 18:03:03 +00:00
Graham Eades
6f22b5eb6e Updated to python 3 compatible code 2020-03-02 18:01:27 +00:00
Graham Eades
fcd6e4863a Updated print function in file 2020-03-02 17:42:47 +00:00
Graham Eades
81a8565710 Updated scripts for python3 2020-03-02 17:40:55 +00:00
7 changed files with 56 additions and 50 deletions

View File

@@ -7,7 +7,7 @@ import hashlib
from functools import reduce from functools import reduce
from operator import add from operator import add
from itertools import izip #from itertools import izip
import main import main
@@ -63,7 +63,7 @@ class BackendBuilder(object):
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
def writeToFolder (self, folder, filename, content): def writeToFolder (self, folder, filename, content):
file = open(os.path.join(folder, filename), 'w') file = open(os.path.join(folder, filename), 'wb')
file.write(content.encode('utf-8')) file.write(content.encode('utf-8'))
file.close() file.close()
@@ -81,19 +81,19 @@ class BackendBuilder(object):
def formatMAC (self, value): def formatMAC (self, value):
x = iter(value) x = iter(value)
return ' '.join([reduce(add, tup) for tup in izip(x, x, x, x)]) return ' '.join([reduce(add, tup) for tup in zip(x, x, x, x)])
def logChecksums (self, content, message): def logChecksums (self, content, message):
md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest())
shaDigest = self.formatMAC(hashlib.sha1(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()) sha256Digest = self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest())
print "-----" print ( "-----" )
print message + ": " + md5Digest + " (md5)" print ( message + ": " + md5Digest + " (md5)" )
print message + ": " + shaDigest + " (sha1)" print ( message + ": " + shaDigest + " (sha1)" )
print message + ": " + sha256Digest + " (sha256)" print ( message + ": " + sha256Digest + " (sha256)" )
print "file size: " + "{:,}".format(len(content)) print ( "file size: " + "{:,}".format(len(content)) )
print "=====" print ( "=====" )
def shouldCompileCode (self): def shouldCompileCode (self):
@@ -101,7 +101,7 @@ class BackendBuilder(object):
def run (self): def run (self):
print self.name() + " - RUN" print ( self.name() + " - RUN" )
if self.shouldCompileCode(): if self.shouldCompileCode():
self.compileCode() self.compileCode()

View File

@@ -4,7 +4,7 @@
"""`cssmin` - A Python port of the YUI CSS compressor.""" """`cssmin` - A Python port of the YUI CSS compressor."""
from StringIO import StringIO # The pure-Python StringIO supports unicode. from io import StringIO # The pure-Python StringIO supports unicode.
import re import re

View File

@@ -6,7 +6,7 @@ import cssmin
import jsmin import jsmin
import codecs import codecs
import shutil import shutil
import StringIO from io import StringIO
import urllib import urllib
import main import main
@@ -53,7 +53,7 @@ class FrontendBuilder(object):
module = self.module module = self.module
if (self.module != self.submodule): if (self.module != self.submodule):
module = module + "." + self.submodule module = module + "." + self.submodule
print "frontend [" + module + "]: " + message print ( "frontend [" + module + "]: " + message )
def absolutePathForSources (self): def absolutePathForSources (self):
@@ -117,7 +117,7 @@ class FrontendBuilder(object):
try: try:
fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8') fileHandler = codecs.open(self.absolutePathForSourceFile(basePath, file), 'r', 'utf-8')
except: except:
print "FILE: " + file print ( "FILE: " + file )
result[file] = fileHandler.read() result[file] = fileHandler.read()
fileHandler.close() fileHandler.close()
@@ -146,7 +146,7 @@ class FrontendBuilder(object):
def template (self): def template (self):
processedFile = 'html_template' processedFile = 'html_template'
if not self.processedFiles.has_key(processedFile): if processedFile not in self.processedFiles:
# self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) # self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html'])
self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']]) self.processedFiles[processedFile] = self.loadFilesContent('html', [self.settings['html.template']])
@@ -197,7 +197,7 @@ class FrontendBuilder(object):
# output rule if it contains any declarations # output rule if it contains any declarations
if properties: if properties:
print "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) print ( "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) )
return css return css
@@ -218,8 +218,8 @@ class FrontendBuilder(object):
def compressJS_jsmin (self, js, description): def compressJS_jsmin (self, js, description):
self.log("compressing " + description + " code") self.log("compressing " + description + " code")
original = StringIO.StringIO(js) original = StringIO(js)
output = StringIO.StringIO() output = StringIO()
jsMinifier = jsmin.JavascriptMinify() jsMinifier = jsmin.JavascriptMinify()
jsMinifier.minify(original, output) jsMinifier.minify(original, output)
@@ -287,7 +287,8 @@ class FrontendBuilder(object):
def bookmarklet (self): def bookmarklet (self):
cacheKey = 'bookmarklet' cacheKey = 'bookmarklet'
if not self.processedFiles.has_key(cacheKey): # if not self.processedFiles.has_key(cacheKey):
if cacheKey not in self.processedFiles:
result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js']), "regular") + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js']), "IE") + '";' result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js']), "regular") + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js']), "IE") + '";'
self.processedFiles[cacheKey] = result self.processedFiles[cacheKey] = result
else: else:
@@ -316,7 +317,8 @@ class FrontendBuilder(object):
def assembleCopyrightHeader (self): def assembleCopyrightHeader (self):
processedFile = 'copyright' processedFile = 'copyright'
if not self.processedFiles.has_key(processedFile): # if not self.processedFiles.has_key(processedFile):
if processedFile not in self.processedFiles:
#self.log("assembling copyright header") #self.log("assembling copyright header")
copyrightValues = self.settings['copyright.values'] copyrightValues = self.settings['copyright.values']
license = self.loadFilesContent('../../properties', ['license.txt']) license = self.loadFilesContent('../../properties', ['license.txt'])
@@ -351,7 +353,8 @@ class FrontendBuilder(object):
def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType): def assembleVersion (self, pageTitle, copyright, css, js, jsLoadMode, version, versionType):
cacheKey = version + "-" + versionType cacheKey = version + "-" + versionType
if not self.processedFiles.has_key(cacheKey): # if not self.processedFiles.has_key(cacheKey):
if cacheKey not in self.processedFiles:
result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType) result = self.replaceTemplatePlaceholders(pageTitle, copyright, css, js, jsLoadMode, version, versionType)
self.processedFiles[cacheKey] = result self.processedFiles[cacheKey] = result
else: else:

View File

@@ -30,7 +30,7 @@ class DeltaBuilder(FrontendBuilder):
content = content.replace('@request.path@', backendSettings['request.path']) content = content.replace('@request.path@', backendSettings['request.path'])
dst = self.absolutePathForTargetFile(targetFolder, '', resource['target']) dst = self.absolutePathForTargetFile(targetFolder, '', resource['target'])
file = open(dst, 'w') file = open(dst, 'wb')
file.write(content.encode('utf-8')) file.write(content.encode('utf-8'))
file.close() file.close()

View File

@@ -33,7 +33,7 @@ import os, os.path, shutil
# SOFTWARE. # SOFTWARE.
# */ # */
from StringIO import StringIO from io import StringIO
def jsmin(js): def jsmin(js):
ins = StringIO(js) ins = StringIO(js)
@@ -224,7 +224,7 @@ def compress(in_files, out_file, in_type='js', verbose=False, temp_file='.temp')
temp.write(data) temp.write(data)
print ' + %s' % f print ( ' + %s' % f )
temp.close() temp.close()
out = open(out_file, 'w') out = open(out_file, 'w')
@@ -237,10 +237,11 @@ def compress(in_files, out_file, in_type='js', verbose=False, temp_file='.temp')
org_size = os.path.getsize(temp_file) org_size = os.path.getsize(temp_file)
new_size = os.path.getsize(out_file) new_size = os.path.getsize(out_file)
print '=> %s' % out_file print ( '=> %s' % out_file )
print 'Original: %.2f kB' % (org_size / 1024.0) print ( 'Original: %.2f kB' )% (org_size / 1024.0)
print 'Compressed: %.2f kB' % (new_size / 1024.0) print ( 'Compressed: %.2f kB' )% (new_size / 1024.0)
print 'Reduction: %.1f%%' % (float(org_size - new_size) / org_size * 100) # print ( 'Reduction: %.1f%%' % (f )loat(org_size - new_size) / org_size * 100)
print '' print ( 'Reduction: %.1f%%' % (org_size - new_size) / org_size * 100)
print ( '' )
os.remove(temp_file) os.remove(temp_file)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import sys import sys
@@ -89,10 +89,10 @@ def build (settings, repository):
if repository.areTherePendingChanges(): if repository.areTherePendingChanges():
if 'install' in settings['versions']: if 'install' in settings['versions']:
# print "\nWARNING: repository has pending changes\n" # print ( "\nWARNING: repository has pending changes\n" )
raise Exception("repository has pending changes, can't 'install'") raise Exception("repository has pending changes, can't 'install'")
else: 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']:
normalizedFrontendName = frontend.replace(".", "_") normalizedFrontendName = frontend.replace(".", "_")
@@ -120,17 +120,17 @@ def clean ():
def usage (message): def usage (message):
if message != None: if message != None:
print "ERROR: " + message print ( "ERROR: " + message )
print print ()
# print "build clean" # print "build clean"
# 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 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" )
exit(1) exit(1)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@@ -181,11 +181,11 @@ def main ():
settings['backends'] = [] settings['backends'] = []
settings['backends'].append('checksum') settings['backends'].append('checksum')
if (not settings.has_key('versions')): if 'versions' not in settings:
usage("missing 'versions'") usage("missing 'versions'")
if (not settings.has_key('frontends')): if 'frontends' not in settings:
usage("missing 'frontends'") usage("missing 'frontends'")
if (not settings.has_key('backends')): if 'backends' not in settings:
usage("missing 'backends'") usage("missing 'backends'")
build(settings, currentRepository) build(settings, currentRepository)

View File

@@ -14,11 +14,13 @@ def repositoryWithPath (path):
from git import Repo from git import Repo
repo = Repo(path) repo = Repo(path)
result = GitRepository(repo, path) result = GitRepository(repo, path)
except ImportError, exception: except ImportError as exception:
print "Failed to import git, please install http://gitorious.org/git-python" import sys
print "Use sudo apt-get install python-git for Ubuntu/Debian" print ( sys.version )
print "Use sudo yum install GitPython for Fedora/RHEL/CentOS" print ( "Failed to import git, please install http://gitorious.org/git-python" )
print "Or manually running the following command: easy_install gitpython" print ( "Use sudo apt-get install python-git for Ubuntu/Debian" )
print ( "Use sudo yum install GitPython for Fedora/RHEL/CentOS" )
print ( "Or manually running the following command: easy_install gitpython" )
except: except:
result = SnapshotRepository('', path) result = SnapshotRepository('', path)
@@ -68,7 +70,7 @@ class GitRepository(Repository):
def areTherePendingChanges (self): def areTherePendingChanges (self):
try: try:
return self.repository.is_dirty() return self.repository.is_dirty()
except TypeError, te: except TypeError as te:
return self.repository.is_dirty return self.repository.is_dirty