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

Side by Side Diff: tools/chrome_extensions/open_my_editor/omed.py

Issue 2720793005: Add Open my editor (Closed)
Patch Set: add owners and change to py2 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 python2
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 '''
watk 2017/03/02 23:13:49 newline before
7 Http Server handle file open request
watk 2017/03/02 23:13:49 "HTTP server for handling requests to open files."
8 '''
9
10 from bottle import Bottle, install, get, response, request, run
11 import logging
12 import sys
13 import sh
14
15 logfile = "/tmp/omed.log"
16 # Get it a path for log
17 if len(sys.argv) == 2:
18 logfile = sys.argv[1]
19
20 logging.basicConfig(filename=logfile, level=logging.INFO)
21 logger = logging.getLogger('omed')
22
23
24 def log(func):
25
26 def wrapper(*args, **kwargs):
27 logger.info(
28 '%s %s %s %s' %
29 (request.remote_addr, request.method, request.url, response.status))
30
31 req = func(*args, **kwargs)
32 return req
33
34 return wrapper
35
36
37 install(log)
38
39
40 @get('/file')
41 def open_file():
42 filepath = request.query.f
43 line = request.query.l
44
45 logger.info("open file: " + filepath + ":" + line)
46
47 sh.myeditor("-f", filepath, "-l", line)
48 return
49
50
51 @get('/files')
52 def open_files():
53 filepaths = request.query.f
54
55 logger.info("open files: " + filepaths)
56
57 sh.myeditor("-m", filepaths)
58 return
59
60
61 run(port=8989, host='127.0.0.1')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698