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: Refactoring commands Created Oct. 20, 2017, 11:51 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
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 import random 14 import random
16 15
17 from packager import (readMetadata, getDefaultFileName, getBuildVersion, 16 from packager import (readMetadata, getDefaultFileName, getBuildVersion,
18 getTemplate, Files) 17 getTemplate, Files)
19 18
20 defaultLocale = 'en_US' 19 defaultLocale = 'en_US'
21 20
(...skipping 16 matching lines...) Expand all
38 return result 37 return result
39 38
40 39
41 def processFile(path, data, params): 40 def processFile(path, data, params):
42 # 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
43 # that it can be overridden if necessary. 42 # that it can be overridden if necessary.
44 return data 43 return data
45 44
46 45
47 def makeIcons(files, filenames): 46 def makeIcons(files, filenames):
48 try:
49 from PIL import Image
50 except ImportError:
51 import Image
52 icons = {} 47 icons = {}
53 for filename in filenames: 48 for filename in filenames:
54 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.')
55 if(width != height): 56 if(width != height):
56 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)
57 icons[width] = filename 58 icons[width] = filename
58 return icons 59 return icons
59 60
60 61
61 def createScriptPage(params, template_name, script_option): 62 def createScriptPage(params, template_name, script_option):
62 template = getTemplate(template_name, autoEscape=True) 63 template = getTemplate(template_name, autoEscape=True)
63 return template.render( 64 return template.render(
64 basename=params['metadata'].get('general', 'basename'), 65 basename=params['metadata'].get('general', 'basename'),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if devenv: 380 if devenv:
380 add_devenv_requirements(files, metadata, params) 381 add_devenv_requirements(files, metadata, params)
381 382
382 zipdata = files.zipToString() 383 zipdata = files.zipToString()
383 signature = None 384 signature = None
384 pubkey = None 385 pubkey = None
385 if keyFile != None: 386 if keyFile != None:
386 signature = signBinary(zipdata, keyFile) 387 signature = signBinary(zipdata, keyFile)
387 pubkey = getPublicKey(keyFile) 388 pubkey = getPublicKey(keyFile)
388 writePackage(outFile, pubkey, signature, zipdata) 389 writePackage(outFile, pubkey, signature, zipdata)
OLDNEW
« no previous file with comments | « package.json ('k') | tests/README.md » ('j') | tests/test_packagerEdge.py » ('J')

Powered by Google App Engine
This is Rietveld