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 glob | 6 import glob |
7 import io | 7 import io |
8 import json | 8 import json |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 26 matching lines...) Expand all Loading... |
37 return result | 37 return result |
38 | 38 |
39 | 39 |
40 def processFile(path, data, params): | 40 def processFile(path, data, params): |
41 # We don't change anything yet, this function currently only exists here so | 41 # We don't change anything yet, this function currently only exists here so |
42 # that it can be overridden if necessary. | 42 # that it can be overridden if necessary. |
43 return data | 43 return data |
44 | 44 |
45 | 45 |
46 def makeIcons(files, filenames): | 46 def makeIcons(files, filenames): |
47 try: | |
48 from PIL import Image | |
49 except ImportError: | |
50 import Image | |
51 icons = {} | 47 icons = {} |
52 for filename in filenames: | 48 for filename in filenames: |
53 width, height = Image.open(StringIO(files[filename])).size | 49 try: |
| 50 magic, width, height = struct.unpack_from('>8s8xii', |
| 51 files[filename]) |
| 52 except struct.error: |
| 53 magic = None |
| 54 if magic != '\x89PNG\r\n\x1a\n': |
| 55 raise Exception(filename + ' is no valid PNG.') |
54 if(width != height): | 56 if(width != height): |
55 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar
e' % (filename, width, height) | 57 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar
e' % (filename, width, height) |
56 icons[width] = filename | 58 icons[width] = filename |
57 return icons | 59 return icons |
58 | 60 |
59 | 61 |
60 def createScriptPage(params, template_name, script_option): | 62 def createScriptPage(params, template_name, script_option): |
61 template = getTemplate(template_name, autoEscape=True) | 63 template = getTemplate(template_name, autoEscape=True) |
62 return template.render( | 64 return template.render( |
63 basename=params['metadata'].get('general', 'basename'), | 65 basename=params['metadata'].get('general', 'basename'), |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 params, 'testIndex.html.tmpl', ('general', 'testScripts') | 370 params, 'testIndex.html.tmpl', ('general', 'testScripts') |
369 ) | 371 ) |
370 | 372 |
371 zipdata = files.zipToString() | 373 zipdata = files.zipToString() |
372 signature = None | 374 signature = None |
373 pubkey = None | 375 pubkey = None |
374 if keyFile != None: | 376 if keyFile != None: |
375 signature = signBinary(zipdata, keyFile) | 377 signature = signBinary(zipdata, keyFile) |
376 pubkey = getPublicKey(keyFile) | 378 pubkey = getPublicKey(keyFile) |
377 writePackage(outFile, pubkey, signature, zipdata) | 379 writePackage(outFile, pubkey, signature, zipdata) |
OLD | NEW |