Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 # By default this script will try to determine the most appropriate X session | 28 # By default this script will try to determine the most appropriate X session |
| 29 # command for the system. To use a specific session instead, set this variable | 29 # command for the system. To use a specific session instead, set this variable |
| 30 # to the executable filename, or a list containing the executable and any | 30 # to the executable filename, or a list containing the executable and any |
| 31 # arguments, for example: | 31 # arguments, for example: |
| 32 # XSESSION_COMMAND = "/usr/bin/gnome-session-fallback" | 32 # XSESSION_COMMAND = "/usr/bin/gnome-session-fallback" |
| 33 # XSESSION_COMMAND = ["/usr/bin/gnome-session", "--session=ubuntu-2d"] | 33 # XSESSION_COMMAND = ["/usr/bin/gnome-session", "--session=ubuntu-2d"] |
| 34 XSESSION_COMMAND = None | 34 XSESSION_COMMAND = None |
| 35 | 35 |
| 36 LOG_FILE_ENV_VAR = "CHROME_REMOTE_DESKTOP_LOG_FILE" | 36 LOG_FILE_ENV_VAR = "CHROME_REMOTE_DESKTOP_LOG_FILE" |
| 37 DEFAULT_SIZES_ENV_VAR = "CHROME_REMOTE_DESKTOP_DEFAULT_DESKTOP_SIZES" | |
|
Wez
2012/12/14 19:49:03
nit: Consider describing the format this variable
Jamie
2012/12/14 21:13:17
Done. The usage output doesn't mention this variab
| |
| 37 | 38 |
| 38 SCRIPT_PATH = sys.path[0] | 39 SCRIPT_PATH = sys.path[0] |
| 39 | 40 |
| 40 DEFAULT_INSTALL_PATH = "/opt/google/chrome-remote-desktop" | 41 DEFAULT_INSTALL_PATH = "/opt/google/chrome-remote-desktop" |
| 41 if SCRIPT_PATH == DEFAULT_INSTALL_PATH: | 42 if SCRIPT_PATH == DEFAULT_INSTALL_PATH: |
| 42 HOST_BINARY_NAME = "chrome-remote-desktop-host" | 43 HOST_BINARY_NAME = "chrome-remote-desktop-host" |
| 43 else: | 44 else: |
| 44 HOST_BINARY_NAME = "remoting_me2me_host" | 45 HOST_BINARY_NAME = "remoting_me2me_host" |
| 45 | 46 |
| 46 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop" | 47 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop" |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 raise | 742 raise |
| 742 elif deadline > now: | 743 elif deadline > now: |
| 743 time.sleep(deadline - now) | 744 time.sleep(deadline - now) |
| 744 return (0, 0) | 745 return (0, 0) |
| 745 else: | 746 else: |
| 746 # Anything else is an unexpected error. | 747 # Anything else is an unexpected error. |
| 747 raise | 748 raise |
| 748 | 749 |
| 749 | 750 |
| 750 def main(): | 751 def main(): |
| 751 DEFAULT_SIZE = "2560x1600" | |
| 752 EPILOG = """This script is not intended for use by end-users. To configure | 752 EPILOG = """This script is not intended for use by end-users. To configure |
| 753 Chrome Remote Desktop, please install the app from the Chrome | 753 Chrome Remote Desktop, please install the app from the Chrome |
| 754 Web Store: https://chrome.google.com/remotedesktop""" | 754 Web Store: https://chrome.google.com/remotedesktop""" |
| 755 parser = optparse.OptionParser( | 755 parser = optparse.OptionParser( |
| 756 usage="Usage: %prog [options] [ -- [ X server options ] ]", | 756 usage="Usage: %prog [options] [ -- [ X server options ] ]", |
| 757 epilog=EPILOG) | 757 epilog=EPILOG) |
| 758 parser.add_option("-s", "--size", dest="size", action="append", | 758 parser.add_option("-s", "--size", dest="size", action="append", |
| 759 help="Dimensions of virtual desktop (default: %s). " | 759 help="Dimensions of virtual desktop. This can be specified " |
| 760 "This can be specified multiple times to make multiple " | 760 "multiple times to make multiple screen resolutions " |
| 761 "screen resolutions available (if the Xvfb server " | 761 "available (if the Xvfb server supports this).") |
| 762 "supports this)" % DEFAULT_SIZE) | |
| 763 parser.add_option("-f", "--foreground", dest="foreground", default=False, | 762 parser.add_option("-f", "--foreground", dest="foreground", default=False, |
| 764 action="store_true", | 763 action="store_true", |
| 765 help="Don't run as a background daemon.") | 764 help="Don't run as a background daemon.") |
| 766 parser.add_option("", "--start", dest="start", default=False, | 765 parser.add_option("", "--start", dest="start", default=False, |
| 767 action="store_true", | 766 action="store_true", |
| 768 help="Start the host.") | 767 help="Start the host.") |
| 769 parser.add_option("-k", "--stop", dest="stop", default=False, | 768 parser.add_option("-k", "--stop", dest="stop", default=False, |
| 770 action="store_true", | 769 action="store_true", |
| 771 help="Stop the daemon currently running.") | 770 help="Stop the daemon currently running.") |
| 772 parser.add_option("", "--check-running", dest="check_running", default=False, | 771 parser.add_option("", "--check-running", dest="check_running", default=False, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 | 823 |
| 825 if options.host_version: | 824 if options.host_version: |
| 826 # TODO(sergeyu): Also check RPM package version once we add RPM package. | 825 # TODO(sergeyu): Also check RPM package version once we add RPM package. |
| 827 return os.system(locate_executable(HOST_BINARY_NAME) + " --version") >> 8 | 826 return os.system(locate_executable(HOST_BINARY_NAME) + " --version") >> 8 |
| 828 | 827 |
| 829 if not options.start: | 828 if not options.start: |
| 830 # If no modal command-line options specified, print an error and exit. | 829 # If no modal command-line options specified, print an error and exit. |
| 831 print >> sys.stderr, EPILOG | 830 print >> sys.stderr, EPILOG |
| 832 return 1 | 831 return 1 |
| 833 | 832 |
| 834 # Collate the list of sizes that XRANDR should support. | 833 # Collate the list of sizes that XRANDR should support. If no sizes were |
| 834 # specified on the command-line, provide a relatively small size to handle | |
|
Lambros
2012/12/14 19:59:05
In the non-RANDR case, we are taking the box-union
Jamie
2012/12/14 21:13:17
I don't think that the non-RANDR case is something
| |
| 835 # the case where resize-to-client is disabled or not supported, and a much | |
| 836 # larger size to support clients with large or mulitple monitors. These | |
| 837 # defaults can be overridden by the user by defining a variable in .profile. | |
| 835 if not options.size: | 838 if not options.size: |
| 836 options.size = [DEFAULT_SIZE] | 839 default_sizes = "1600x1200,3840x1600" |
|
Wez
2012/12/14 19:49:03
nit: This still feels like something that should b
Lambros
2012/12/14 19:59:05
It's a strange letter-boxy default. I'd be incline
Jamie
2012/12/14 21:13:17
That increases Xvfb memory usage from 34 to 48Mb,
Jamie
2012/12/14 21:13:17
Done.
Wez
2012/12/14 21:19:20
Linux will only actually commit pages that we touc
Jamie
2012/12/14 21:23:19
Is this a vote for increasing the height or just a
| |
| 840 if os.environ.has_key(DEFAULT_SIZES_ENV_VAR): | |
| 841 default_sizes = os.environ[DEFAULT_SIZES_ENV_VAR] | |
|
Wez
2012/12/14 19:49:03
Do we get enough of the user's environment for thi
Jamie
2012/12/14 21:13:17
Yes, Lambros did a test and confirmed that .profil
| |
| 842 options.size = default_sizes.split(","); | |
| 837 | 843 |
| 838 sizes = [] | 844 sizes = [] |
| 839 for size in options.size: | 845 for size in options.size: |
| 840 size_components = size.split("x") | 846 size_components = size.split("x") |
| 841 if len(size_components) != 2: | 847 if len(size_components) != 2: |
| 842 parser.error("Incorrect size format '%s', should be WIDTHxHEIGHT" % size) | 848 parser.error("Incorrect size format '%s', should be WIDTHxHEIGHT" % size) |
| 843 | 849 |
| 844 try: | 850 try: |
| 845 width = int(size_components[0]) | 851 width = int(size_components[0]) |
| 846 height = int(size_components[1]) | 852 height = int(size_components[1]) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 host_config.clear_auth() | 1043 host_config.clear_auth() |
| 1038 host_config.clear_host_info() | 1044 host_config.clear_host_info() |
| 1039 host_config.save() | 1045 host_config.save() |
| 1040 return 0 | 1046 return 0 |
| 1041 | 1047 |
| 1042 | 1048 |
| 1043 if __name__ == "__main__": | 1049 if __name__ == "__main__": |
| 1044 logging.basicConfig(level=logging.DEBUG, | 1050 logging.basicConfig(level=logging.DEBUG, |
| 1045 format="%(asctime)s:%(levelname)s:%(message)s") | 1051 format="%(asctime)s:%(levelname)s:%(message)s") |
| 1046 sys.exit(main()) | 1052 sys.exit(main()) |
| OLD | NEW |