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

Side by Side Diff: client/cros/login.py

Issue 6546062: Up process priority during login. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Upped priority to 20. Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 errno, logging, os, re, signal, subprocess, time 5 import errno, logging, os, re, signal, subprocess, time
6 import common 6 import common
7 import constants, cros_logging, cros_ui, cryptohome 7 import constants, cros_logging, cros_ui, cryptohome
8 from autotest_lib.client.bin import utils 8 from autotest_lib.client.bin import utils
9 from autotest_lib.client.common_lib import error 9 from autotest_lib.client.common_lib import error
10 10
11 11
12 _DEFAULT_TIMEOUT = 30 12 _DEFAULT_TIMEOUT = 30
13 13
14 # Priority increase to use when logging in to make sure we aren't descheduled at
15 # inopportune times.
16 _LOGIN_NICE = 20
17
14 # Log messages used to signal when we're in a logout situation. Used to detect 18 # Log messages used to signal when we're in a logout situation. Used to detect
15 # crashes by cros_ui_test.UITest. 19 # crashes by cros_ui_test.UITest.
16 LOGOUT_ATTEMPT_MSG = 'cros/login.py: Attempting logout...' 20 LOGOUT_ATTEMPT_MSG = 'cros/login.py: Attempting logout...'
17 LOGOUT_COMPLETE_MSG = 'cros/login.py: Logout complete.' 21 LOGOUT_COMPLETE_MSG = 'cros/login.py: Logout complete.'
18 22
19 23
20 class TimeoutError(error.TestError): 24 class TimeoutError(error.TestError):
21 """Error raised when we time out while waiting on a condition.""" 25 """Error raised when we time out while waiting on a condition."""
22 pass 26 pass
23 27
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 raise UnexpectedCondition("Session manager is not running") 143 raise UnexpectedCondition("Session manager is not running")
140 144
141 if logged_in(): 145 if logged_in():
142 raise UnexpectedCondition("Already logged in") 146 raise UnexpectedCondition("Already logged in")
143 147
144 # Mark /var/log/messages now; we'll run through all subsequent log messages 148 # Mark /var/log/messages now; we'll run through all subsequent log messages
145 # if we couldn't log in to see if the browser crashed. 149 # if we couldn't log in to see if the browser crashed.
146 log_reader = cros_logging.LogReader() 150 log_reader = cros_logging.LogReader()
147 log_reader.set_start_by_current() 151 log_reader.set_start_by_current()
148 152
149 ax = cros_ui.get_autox() 153 # Up our priority so we don't get descheduled in the middle of sending key
150 # navigate to login screen 154 # press and key release events.
151 ax.send_hotkey("Ctrl+Alt+L") 155 utils.system('renice +%d -p %d' % (_LOGIN_NICE, os.getpid()))
152 # escape out of any login screen menus (e.g., the network selection menu) 156 try:
153 ax.send_hotkey("Escape") 157 ax = cros_ui.get_autox()
154 time.sleep(0.5) 158 # navigate to login screen
155 if (username): 159 ax.send_hotkey("Ctrl+Alt+L")
156 # focus username 160 # escape out of any login screen menus (e.g., the network selection menu)
157 ax.send_hotkey("Alt+U") 161 ax.send_hotkey("Escape")
158 ax.send_text(username) 162 time.sleep(0.5)
159 # TODO(rginda): remove Tab after http://codereview.chromium.org/1390003 163 if (username):
160 ax.send_hotkey("Tab") 164 # focus username
161 # focus password 165 ax.send_hotkey("Alt+U")
162 ax.send_hotkey("Alt+P") 166 ax.send_text(username)
163 ax.send_text(password) 167 # focus password
164 ax.send_hotkey("Return") 168 ax.send_hotkey("Alt+P")
165 else: 169 ax.send_text(password)
166 ax.send_hotkey("Alt+B") # Browse without signing-in 170 ax.send_hotkey("Return")
171 else:
172 ax.send_hotkey("Alt+B") # Browse without signing-in
173 finally:
174 utils.system('renice -%d -p %d' % (_LOGIN_NICE, os.getpid()))
167 175
168 wait_for_condition(condition=logged_in, 176 wait_for_condition(condition=logged_in,
169 timeout_msg='Timed out waiting for login', 177 timeout_msg='Timed out waiting for login',
170 timeout=timeout, 178 timeout=timeout,
171 process='chrome', 179 process='chrome',
172 log_reader=log_reader, 180 log_reader=log_reader,
173 crash_msg='Chrome crashed during login') 181 crash_msg='Chrome crashed during login')
174 182
175 183
176 def attempt_logout(timeout=_DEFAULT_TIMEOUT): 184 def attempt_logout(timeout=_DEFAULT_TIMEOUT):
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 except (IOError, OSError) as error: 400 except (IOError, OSError) as error:
393 logging.error(error) 401 logging.error(error)
394 402
395 # Restart the UI. 403 # Restart the UI.
396 nuke_login_manager() 404 nuke_login_manager()
397 utils.poll_for_condition( 405 utils.poll_for_condition(
398 lambda: __session_manager_restarted(oldpid), 406 lambda: __session_manager_restarted(oldpid),
399 TimeoutError('Timed out waiting for logout'), 407 TimeoutError('Timed out waiting for logout'),
400 timeout) 408 timeout)
401 wait_for_login_prompt() 409 wait_for_login_prompt()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698