Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: packagerChrome.py

Issue 29501558: Issue 5383 - Add tests for the Chrome and Firefox packagers (Closed)
Patch Set: Adressing comments Created Sept. 20, 2017, 8:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « README.md ('k') | tests/README.md » ('j') | tests/tools.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 magic, width, height = struct.unpack('>8s8xii', files[filename][:24])
Sebastian Noack 2017/09/20 21:36:10 This is different from my suggestion: 1. If you u
tlucas 2017/09/21 11:34:55 Sorry, i somehow overlooked this part from your co
49 if magic != '\x89PNG\r\n\x1a\n':
50 raise TypeError('{} is no valid PNG.'.format(filename))
Sebastian Noack 2017/09/20 21:36:10 Nit; from https://adblockplus.org/coding-style#pyt
tlucas 2017/09/21 11:34:55 Done.
53 if(width != height): 51 if(width != height):
54 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar e' % (filename, width, height) 52 print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be squar e' % (filename, width, height)
55 icons[width] = filename 53 icons[width] = filename
56 return icons 54 return icons
57 55
58 56
59 def createScriptPage(params, template_name, script_option): 57 def createScriptPage(params, template_name, script_option):
60 template = getTemplate(template_name, autoEscape=True) 58 template = getTemplate(template_name, autoEscape=True)
61 return template.render( 59 return template.render(
62 basename=params['metadata'].get('general', 'basename'), 60 basename=params['metadata'].get('general', 'basename'),
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 params, 'testIndex.html.tmpl', ('general', 'testScripts') 414 params, 'testIndex.html.tmpl', ('general', 'testScripts')
417 ) 415 )
418 416
419 zipdata = files.zipToString() 417 zipdata = files.zipToString()
420 signature = None 418 signature = None
421 pubkey = None 419 pubkey = None
422 if keyFile != None: 420 if keyFile != None:
423 signature = signBinary(zipdata, keyFile) 421 signature = signBinary(zipdata, keyFile)
424 pubkey = getPublicKey(keyFile) 422 pubkey = getPublicKey(keyFile)
425 writePackage(outFile, pubkey, signature, zipdata) 423 writePackage(outFile, pubkey, signature, zipdata)
OLDNEW
« no previous file with comments | « README.md ('k') | tests/README.md » ('j') | tests/tools.py » ('J')

Powered by Google App Engine
This is Rietveld