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: Rebasing against current master (502:7e896c368056) Created Oct. 17, 2017, 12:39 p.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 | « package.json ('k') | tests/README.md » ('j') | no next file with comments »
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 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
11 from StringIO import StringIO
12 import struct 11 import struct
13 import subprocess 12 import subprocess
14 import sys 13 import sys
15 14
16 from packager import (readMetadata, getDefaultFileName, getBuildVersion, 15 from packager import (readMetadata, getDefaultFileName, getBuildVersion,
17 getTemplate, Files) 16 getTemplate, Files)
18 17
19 defaultLocale = 'en_US' 18 defaultLocale = 'en_US'
20 19
21 20
(...skipping 15 matching lines...) Expand all
37 return result 36 return result
38 37
39 38
40 def processFile(path, data, params): 39 def processFile(path, data, params):
41 # 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
42 # that it can be overridden if necessary. 41 # that it can be overridden if necessary.
43 return data 42 return data
44 43
45 44
46 def makeIcons(files, filenames): 45 def makeIcons(files, filenames):
47 try:
48 from PIL import Image
49 except ImportError:
50 import Image
51 icons = {} 46 icons = {}
52 for filename in filenames: 47 for filename in filenames:
53 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.')
54 if(width != height): 55 if(width != height):
55 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)
56 icons[width] = filename 57 icons[width] = filename
57 return icons 58 return icons
58 59
59 60
60 def createScriptPage(params, template_name, script_option): 61 def createScriptPage(params, template_name, script_option):
61 template = getTemplate(template_name, autoEscape=True) 62 template = getTemplate(template_name, autoEscape=True)
62 return template.render( 63 return template.render(
63 basename=params['metadata'].get('general', 'basename'), 64 basename=params['metadata'].get('general', 'basename'),
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 params, 'testIndex.html.tmpl', ('general', 'testScripts') 374 params, 'testIndex.html.tmpl', ('general', 'testScripts')
374 ) 375 )
375 376
376 zipdata = files.zipToString() 377 zipdata = files.zipToString()
377 signature = None 378 signature = None
378 pubkey = None 379 pubkey = None
379 if keyFile != None: 380 if keyFile != None:
380 signature = signBinary(zipdata, keyFile) 381 signature = signBinary(zipdata, keyFile)
381 pubkey = getPublicKey(keyFile) 382 pubkey = getPublicKey(keyFile)
382 writePackage(outFile, pubkey, signature, zipdata) 383 writePackage(outFile, pubkey, signature, zipdata)
OLDNEW
« no previous file with comments | « package.json ('k') | tests/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld