| OLD | NEW |
| 1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
| 2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | 4 |
| 5 import errno | 5 import errno |
| 6 import io | 6 import io |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 from StringIO import StringIO | 10 from StringIO import StringIO |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return result | 36 return result |
| 37 | 37 |
| 38 | 38 |
| 39 def processFile(path, data, params): | 39 def processFile(path, data, params): |
| 40 # We don't change anything yet, this function currently only exists here so | 40 # We don't change anything yet, this function currently only exists here so |
| 41 # that it can be overridden if necessary. | 41 # that it can be overridden if necessary. |
| 42 return data | 42 return data |
| 43 | 43 |
| 44 | 44 |
| 45 def makeIcons(files, filenames): | 45 def makeIcons(files, filenames): |
| 46 try: | |
| 47 from PIL import Image | |
| 48 except ImportError: | |
| 49 import Image | |
| 50 icons = {} | 46 icons = {} |
| 51 for filename in filenames: | 47 for filename in filenames: |
| 52 width, height = Image.open(StringIO(files[filename])).size | 48 try: |
| 49 magic, width, height = struct.unpack_from('>8s8xii', |
| 50 files[filename]) |
| 51 except struct.error: |
| 52 magic = None |
| 53 if magic != '\x89PNG\r\n\x1a\n': |
| 54 raise Exception(filename + ' is no valid PNG.') |
| 53 if(width != height): | 55 if(width != height): |
| 54 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar
e' % (filename, width, height) | 56 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar
e' % (filename, width, height) |
| 55 icons[width] = filename | 57 icons[width] = filename |
| 56 return icons | 58 return icons |
| 57 | 59 |
| 58 | 60 |
| 59 def createScriptPage(params, template_name, script_option): | 61 def createScriptPage(params, template_name, script_option): |
| 60 template = getTemplate(template_name, autoEscape=True) | 62 template = getTemplate(template_name, autoEscape=True) |
| 61 return template.render( | 63 return template.render( |
| 62 basename=params['metadata'].get('general', 'basename'), | 64 basename=params['metadata'].get('general', 'basename'), |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 params, 'testIndex.html.tmpl', ('general', 'testScripts') | 418 params, 'testIndex.html.tmpl', ('general', 'testScripts') |
| 417 ) | 419 ) |
| 418 | 420 |
| 419 zipdata = files.zipToString() | 421 zipdata = files.zipToString() |
| 420 signature = None | 422 signature = None |
| 421 pubkey = None | 423 pubkey = None |
| 422 if keyFile != None: | 424 if keyFile != None: |
| 423 signature = signBinary(zipdata, keyFile) | 425 signature = signBinary(zipdata, keyFile) |
| 424 pubkey = getPublicKey(keyFile) | 426 pubkey = getPublicKey(keyFile) |
| 425 writePackage(outFile, pubkey, signature, zipdata) | 427 writePackage(outFile, pubkey, signature, zipdata) |
| OLD | NEW |