Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: tools/chrome_extensions/open_my_editor/omed.py

Issue 2720793005: Add Open my editor (Closed)
Patch Set: change python2 to python Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/chrome_extensions/open_my_editor/omed.py
diff --git a/tools/chrome_extensions/open_my_editor/omed.py b/tools/chrome_extensions/open_my_editor/omed.py
new file mode 100755
index 0000000000000000000000000000000000000000..2998c6803f70fe735a52212b0dd77cdbdebba7fe
--- /dev/null
+++ b/tools/chrome_extensions/open_my_editor/omed.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+#
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+HTTP server for handling requests to open files.
+"""
+
+from bottle import Bottle, install, get, response, request, run
+import logging
+import sys
+import sh
+
+logfile = "/tmp/omed.log"
+# Get it a path for log.
+if len(sys.argv) == 2:
+ logfile = sys.argv[1]
+
+logging.basicConfig(filename=logfile, level=logging.INFO)
+logger = logging.getLogger('omed')
+
+def log(func):
+ def wrapper(*args, **kwargs):
+ logger.info(
+ '%s %s %s %s' %
+ (request.remote_addr, request.method, request.url, response.status))
+
+ req = func(*args, **kwargs)
+ return req
+ return wrapper
+
+install(log)
+
+@get('/file')
+def open_file():
+ filepath = request.query.f
+ line = request.query.l
+
+ logger.info("open file: " + filepath + ":" + line)
+
+ sh.myeditor("-f", filepath, "-l", line)
+ return
+
+@get('/files')
+def open_files():
+ filepaths = request.query.f
+
+ logger.info("open files: " + filepaths)
+
+ sh.myeditor("-m", filepaths)
+ return
+
+run(port=8989, host='127.0.0.1')

Powered by Google App Engine
This is Rietveld 408576698