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

Side by Side Diff: client/common_lib/site_ui.py

Issue 1534001: switch to autox.py and robustify login/logout code (Closed)
Patch Set: merge with head Created 10 years, 8 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
« no previous file with comments | « client/bin/site_utils.py ('k') | client/deps/autox/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS 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 4
5 import logging, shutil 5 import logging, os, shutil
6 from autotest_lib.client.common_lib import site_httpd, utils 6 from autotest_lib.client.common_lib import site_httpd, utils
7 7
8 8
9 def xcommand(cmd): 9 def xcommand(cmd):
10 """ 10 """
11 Add the necessary X setup to a shell command that needs to connect to the X 11 Add the necessary X setup to a shell command that needs to connect to the X
12 server. 12 server.
13 13
14 @param cmd: the command line string 14 @param cmd: the command line string
15 @return a modified command line string with necessary X setup 15 @return a modified command line string with necessary X setup
(...skipping 21 matching lines...) Expand all
37 def xsystem_as(cmd, user='chronos', timeout=None, ignore_status=False): 37 def xsystem_as(cmd, user='chronos', timeout=None, ignore_status=False):
38 """ 38 """
39 Run the command cmd as the given user, using utils.system, after adding 39 Run the command cmd as the given user, using utils.system, after adding
40 the necessary setup to connect to the X server. 40 the necessary setup to connect to the X server.
41 """ 41 """
42 42
43 return utils.system(xcommand_as(cmd, user=user), timeout=timeout, 43 return utils.system(xcommand_as(cmd, user=user), timeout=timeout,
44 ignore_status=ignore_status) 44 ignore_status=ignore_status)
45 45
46 46
47 def get_autox():
48 """Return a new autox instance."""
49 # we're running as root, but need to connect to chronos' X session
50 os.environ.setdefault('XAUTHORITY', '/home/chronos/.Xauthority')
51 os.environ.setdefault('DISPLAY', ':0.0')
52
53 import autox
54 return autox.AutoX()
55
56
47 class ChromeSession(object): 57 class ChromeSession(object):
48 """ 58 """
49 A class to start and close Chrome sessions. 59 A class to start and close Chrome sessions.
50 """ 60 """
51 61
52 def __init__(self, args='', clean_state=True, suid=True): 62 def __init__(self, args='', clean_state=True, suid=True):
53 self._clean_state = clean_state 63 self._clean_state = clean_state
54 self.start(args, suid=suid) 64 self.start(args, suid=suid)
55 65
56 66
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 http_server.stop() 155 http_server.stop()
146 156
147 # Return None if timeout. 157 # Return None if timeout.
148 if not latch.is_set(): 158 if not latch.is_set():
149 http_server.stop() 159 http_server.stop()
150 return None 160 return None
151 161
152 result = http_server.get_form_entries()['result'] 162 result = http_server.get_form_entries()['result']
153 http_server.stop() 163 http_server.stop()
154 return result 164 return result
OLDNEW
« no previous file with comments | « client/bin/site_utils.py ('k') | client/deps/autox/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698