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

Unified Diff: packagerChrome.py

Issue 5732684932317184: Issue 143 - Use chrome.runtime.reload() to reload Adblock Plus in (Closed)
Patch Set: Created April 16, 2014, 10:03 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeDevenvPoller__.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
===================================================================
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -123,20 +123,16 @@ def createManifest(params, files):
licenseComment = re.compile(r'/\*.*?\*/', re.S)
data = json.loads(re.sub(licenseComment, '', manifest, 1))
if '_dummy' in data:
del data['_dummy']
manifest = json.dumps(data, sort_keys=True, indent=2)
return manifest.encode('utf-8')
-def createPoller(params):
- template = getTemplate('chromeDevenvPoller__.js.tmpl')
- return template.render(params).encode('utf-8');
-
def createInfoModule(params):
template = getTemplate('chromeInfo.js.tmpl')
return template.render(params).encode('utf-8');
def convertJS(params, files):
from jshydra.abp_rewrite import doRewrite
for item in params['metadata'].items('convert_js'):
@@ -344,17 +340,17 @@ def createBuild(baseDir, type='chrome',
'version': version,
'experimentalAPI': experimentalAPI,
'devenv': devenv,
'metadata': metadata,
}
files = Files(getPackageFiles(params), getIgnoredFiles(params),
process=lambda path, data: processFile(path, data, params))
-
+
if metadata.has_section('mapping'):
files.readMappedFiles(metadata.items('mapping'))
files.read(baseDir)
if metadata.has_section('convert_js'):
convertJS(params, files)
if metadata.has_section('convert_img'):
@@ -364,22 +360,25 @@ def createBuild(baseDir, type='chrome',
if metadata.has_section('preprocess'):
files.preprocess(
[f for f, _ in metadata.items('preprocess')],
{'needsExt': True}
)
if metadata.has_section('import_locales'):
importGeckoLocales(params, files)
-
+
files['manifest.json'] = createManifest(params, files)
fixMissingTranslations(files)
if devenv:
- files['devenvPoller__.js'] = createPoller(params)
+ import buildtools
+ import random
+ files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js')
+ files['devenvVersion__'] = str(random.random())
if (metadata.has_option('general', 'backgroundScripts') and
'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScripts')) and
'lib/info.js' not in files):
files['lib/info.js'] = createInfoModule(params)
zipdata = files.zipToString()
signature = None
@@ -392,32 +391,8 @@ def createBuild(baseDir, type='chrome',
def createDevEnv(baseDir, type):
fileBuffer = StringIO()
createBuild(baseDir, type=type, outFile=fileBuffer, devenv=True, releaseBuild=True)
from zipfile import ZipFile
zip = ZipFile(StringIO(fileBuffer.getvalue()), 'r')
zip.extractall(os.path.join(baseDir, 'devenv'))
zip.close()
-
- print 'Development environment created, waiting for connections from active extensions...'
- metadata = readMetadata(baseDir, type)
- connections = [0]
-
- import SocketServer, time, thread
-
- class ConnectionHandler(SocketServer.BaseRequestHandler):
- def handle(self):
- connections[0] += 1
- self.request.sendall('HTTP/1.0 OK\nConnection: close\n\n%s' % metadata.get('general', 'basename'))
-
- server = SocketServer.TCPServer(('localhost', 43816), ConnectionHandler)
-
- def shutdown_server(server):
- time.sleep(10)
- server.shutdown()
- thread.start_new_thread(shutdown_server, (server,))
- server.serve_forever()
-
- if connections[0] == 0:
- print 'Warning: No incoming connections, extension probably not active in the browser yet'
- else:
- print 'Handled %i connection(s)' % connections[0]
« no previous file with comments | « chromeDevenvPoller__.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld