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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """
8 HTTP server for handling requests to open files.
9 """
10
11 from bottle import Bottle, install, get, response, request, run
12 import logging
13 import sys
14 import sh
15
16 logfile = "/tmp/omed.log"
17 # Get it a path for log.
18 if len(sys.argv) == 2:
19 logfile = sys.argv[1]
20
21 logging.basicConfig(filename=logfile, level=logging.INFO)
22 logger = logging.getLogger('omed')
23
24 def log(func):
25 def wrapper(*args, **kwargs):
26 logger.info(
27 '%s %s %s %s' %
28 (request.remote_addr, request.method, request.url, response.status))
29
30 req = func(*args, **kwargs)
31 return req
32 return wrapper
33
34 install(log)
35
36 @get('/file')
37 def open_file():
38 filepath = request.query.f
39 line = request.query.l
40
41 logger.info("open file: " + filepath + ":" + line)
42
43 sh.myeditor("-f", filepath, "-l", line)
44 return
45
46 @get('/files')
47 def open_files():
48 filepaths = request.query.f
49
50 logger.info("open files: " + filepaths)
51
52 sh.myeditor("-m", filepaths)
53 return
54
55 run(port=8989, host='127.0.0.1')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698