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

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/inspector_runtime.py

Issue 10984018: [chrome_remote_control] Add pylint to PRESUMMIT and fix lint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 class EvaluateException(Exception): 4 class EvaluateException(Exception):
5 pass 5 pass
6 6
7 class InspectorRuntime(object): 7 class InspectorRuntime(object):
8 def __init__(self, inspector_backend): 8 def __init__(self, inspector_backend):
9 self._inspector_backend = inspector_backend 9 self._inspector_backend = inspector_backend
10 self._inspector_backend.RegisterDomain( 10 self._inspector_backend.RegisterDomain(
11 'Runtime', 11 'Runtime',
12 self._OnNotification, 12 self._OnNotification,
13 self._OnClose) 13 self._OnClose)
14 14
15 def _OnNotification(self, msg): 15 def _OnNotification(self, msg):
16 pass 16 pass
17 17
18 def _OnClose(self): 18 def _OnClose(self):
19 pass 19 pass
20 20
21 def Execute(self, expr, timeout=60): 21 def Execute(self, expr, timeout=60):
22 """Executes expr in javascript. Does not return the result. 22 """Executes expr in javascript. Does not return the result.
23 23
24 If the expression failed to evaluate, EvaluateException will be raised. 24 If the expression failed to evaluate, EvaluateException will be raised.
25 """ 25 """
26 self.Evaluate(expr + '; 0;', timeout=60) 26 self.Evaluate(expr + '; 0;', timeout)
27 27
28 def Evaluate(self, expr, timeout=60): 28 def Evaluate(self, expr, timeout=60):
29 """Evalutes expr in javascript and returns the JSONized result. 29 """Evalutes expr in javascript and returns the JSONized result.
30 30
31 Consider using Execute for cases where the result of the expression is not 31 Consider using Execute for cases where the result of the expression is not
32 needed. 32 needed.
33 33
34 If evaluation throws in javascript, a python EvaluateException will 34 If evaluation throws in javascript, a python EvaluateException will
35 be raised. 35 be raised.
36 36
(...skipping 11 matching lines...) Expand all
48 if 'error' in res: 48 if 'error' in res:
49 raise EvaluateException(res['error']['message']) 49 raise EvaluateException(res['error']['message'])
50 50
51 if 'wasThrown' in res['result'] and res['result']['wasThrown']: 51 if 'wasThrown' in res['result'] and res['result']['wasThrown']:
52 # TODO(nduca): propagate stacks from javascript up to the python 52 # TODO(nduca): propagate stacks from javascript up to the python
53 # exception. 53 # exception.
54 raise EvaluateException(res['result']['result']['description']) 54 raise EvaluateException(res['result']['result']['description'])
55 if res['result']['result']['type'] == 'undefined': 55 if res['result']['result']['type'] == 'undefined':
56 return None 56 return None
57 return res['result']['result']['value'] 57 return res['result']['result']['value']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698