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

Side by Side Diff: packagerGecko.py

Issue 4777306409140224: Issue 2607 - Clear currentVersion on uninstallation (Closed)
Patch Set: Use json.loads rather than re.search Created May 29, 2015, 8:02 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import re 9 import re
10 import hashlib 10 import hashlib
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 224 }
225 225
226 def checkScript(name): 226 def checkScript(name):
227 content = files[name] 227 content = files[name]
228 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', content): 228 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', content):
229 templateData['requires'][match.group(1)] = True 229 templateData['requires'][match.group(1)] = True
230 if name.startswith('chrome/content/'): 230 if name.startswith('chrome/content/'):
231 templateData['hasChromeRequires'] = True 231 templateData['hasChromeRequires'] = True
232 if name.startswith('lib/') and re.search(r'\bXMLHttpRequest\b', content): 232 if name.startswith('lib/') and re.search(r'\bXMLHttpRequest\b', content):
233 templateData['hasXMLHttpRequest'] = True 233 templateData['hasXMLHttpRequest'] = True
234 if name == 'defaults/prefs.js':
235 if re.search(r'\.currentVersion"', content):
236 templateData['hasVersionPref'] = True
237 if not '/' in name or name.startswith('lib/'): 234 if not '/' in name or name.startswith('lib/'):
238 if re.search(r'(?:^|\s)onShutdown\.', content): 235 if re.search(r'(?:^|\s)onShutdown\.', content):
239 templateData['hasShutdownHandlers'] = True 236 templateData['hasShutdownHandlers'] = True
240 237
241 for name, content in files.iteritems(): 238 for name, content in files.iteritems():
242 if name == 'chrome.manifest': 239 if name == 'chrome.manifest':
243 templateData['hasChrome'] = True 240 templateData['hasChrome'] = True
241 elif name == 'defaults/prefs.json':
242 templateData['hasVersionPref'] = 'currentVersion' in json.loads(content).g et('defaults', {})
244 elif name.endswith('.js'): 243 elif name.endswith('.js'):
245 checkScript(name) 244 checkScript(name)
246 elif name.endswith('.xul'): 245 elif name.endswith('.xul'):
247 match = re.search(r'<(?:window|dialog)\s[^>]*\bwindowtype="([^">]+)"', con tent) 246 match = re.search(r'<(?:window|dialog)\s[^>]*\bwindowtype="([^">]+)"', con tent)
248 if match: 247 if match:
249 templateData['chromeWindows'].append(match.group(1)) 248 templateData['chromeWindows'].append(match.group(1))
250 249
251 while True: 250 while True:
252 missing = [] 251 missing = []
253 for module in templateData['requires']: 252 for module in templateData['requires']:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if metadata.has_section('preprocess'): 354 if metadata.has_section('preprocess'):
356 files.preprocess([f for f, _ in metadata.items('preprocess')]) 355 files.preprocess([f for f, _ in metadata.items('preprocess')])
357 if keyFile: 356 if keyFile:
358 signFiles(files, keyFile) 357 signFiles(files, keyFile)
359 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x ) 358 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x )
360 359
361 def autoInstall(baseDir, type, host, port, multicompartment=False): 360 def autoInstall(baseDir, type, host, port, multicompartment=False):
362 fileBuffer = StringIO() 361 fileBuffer = StringIO()
363 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment) 362 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment)
364 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) 363 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld