OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Virtual Me2Me implementation. This script runs and manages the processes | 6 # Virtual Me2Me implementation. This script runs and manages the processes |
7 # required for a Virtual Me2Me desktop, which are: X server, X desktop | 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop |
8 # session, and Host process. | 8 # session, and Host process. |
9 # This script is intended to run continuously as a background daemon | 9 # This script is intended to run continuously as a background daemon |
10 # process, running under an ordinary (non-root) user account. | 10 # process, running under an ordinary (non-root) user account. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 # multiple DISPLAYs, but Chrome Sync allows for a reasonable compromise. | 388 # multiple DISPLAYs, but Chrome Sync allows for a reasonable compromise. |
389 chrome_profile = os.path.join(CONFIG_DIR, "chrome-profile") | 389 chrome_profile = os.path.join(CONFIG_DIR, "chrome-profile") |
390 self.child_env["CHROME_USER_DATA_DIR"] = chrome_profile | 390 self.child_env["CHROME_USER_DATA_DIR"] = chrome_profile |
391 | 391 |
392 # Set SSH_AUTH_SOCK to the file name to listen on. | 392 # Set SSH_AUTH_SOCK to the file name to listen on. |
393 if self.ssh_auth_sockname: | 393 if self.ssh_auth_sockname: |
394 self.child_env["SSH_AUTH_SOCK"] = self.ssh_auth_sockname | 394 self.child_env["SSH_AUTH_SOCK"] = self.ssh_auth_sockname |
395 | 395 |
396 # Wait for X to be active. | 396 # Wait for X to be active. |
397 for _test in range(20): | 397 for _test in range(20): |
398 proc = subprocess.Popen("xdpyinfo", env=self.child_env, stdout=devnull) | 398 retcode = subprocess.call("xdpyinfo", env=self.child_env, stdout=devnull) |
399 _pid, retcode = os.waitpid(proc.pid, 0) | |
400 if retcode == 0: | 399 if retcode == 0: |
401 break | 400 break |
402 time.sleep(0.5) | 401 time.sleep(0.5) |
403 if retcode != 0: | 402 if retcode != 0: |
404 raise Exception("Could not connect to Xvfb.") | 403 raise Exception("Could not connect to Xvfb.") |
405 else: | 404 else: |
406 logging.info("Xvfb is active.") | 405 logging.info("Xvfb is active.") |
407 | 406 |
408 # The remoting host expects the server to use "evdev" keycodes, but Xvfb | 407 # The remoting host expects the server to use "evdev" keycodes, but Xvfb |
409 # starts configured to use the "base" ruleset, resulting in XKB configuring | 408 # starts configured to use the "base" ruleset, resulting in XKB configuring |
410 # for "xfree86" keycodes, and screwing up some keys. See crbug.com/119013. | 409 # for "xfree86" keycodes, and screwing up some keys. See crbug.com/119013. |
411 # Reconfigure the X server to use "evdev" keymap rules. The X server must | 410 # Reconfigure the X server to use "evdev" keymap rules. The X server must |
412 # be started with -noreset otherwise it'll reset as soon as the command | 411 # be started with -noreset otherwise it'll reset as soon as the command |
413 # completes, since there are no other X clients running yet. | 412 # completes, since there are no other X clients running yet. |
414 proc = subprocess.Popen("setxkbmap -rules evdev", env=self.child_env, | 413 retcode = subprocess.call("setxkbmap -rules evdev", env=self.child_env, |
415 shell=True) | 414 shell=True) |
416 _pid, retcode = os.waitpid(proc.pid, 0) | |
417 if retcode != 0: | 415 if retcode != 0: |
418 logging.error("Failed to set XKB to 'evdev'") | 416 logging.error("Failed to set XKB to 'evdev'") |
419 | 417 |
420 # Register the screen sizes if the X server's RANDR extension supports it. | 418 # Register the screen sizes if the X server's RANDR extension supports it. |
421 # Errors here are non-fatal; the X server will continue to run with the | 419 # Errors here are non-fatal; the X server will continue to run with the |
422 # dimensions from the "-screen" option. | 420 # dimensions from the "-screen" option. |
423 for width, height in self.sizes: | 421 for width, height in self.sizes: |
424 label = "%dx%d" % (width, height) | 422 label = "%dx%d" % (width, height) |
425 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", | 423 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", |
426 str(height), "0", "0", "0"] | 424 str(height), "0", "0", "0"] |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 else: | 1250 else: |
1253 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) | 1251 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) |
1254 elif os.WIFSIGNALED(status): | 1252 elif os.WIFSIGNALED(status): |
1255 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) | 1253 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) |
1256 | 1254 |
1257 | 1255 |
1258 if __name__ == "__main__": | 1256 if __name__ == "__main__": |
1259 logging.basicConfig(level=logging.DEBUG, | 1257 logging.basicConfig(level=logging.DEBUG, |
1260 format="%(asctime)s:%(levelname)s:%(message)s") | 1258 format="%(asctime)s:%(levelname)s:%(message)s") |
1261 sys.exit(main()) | 1259 sys.exit(main()) |
OLD | NEW |