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

Side by Side Diff: remoting/host/linux/linux_me2me_host.py

Issue 1885483003: Copy Linux me2me script to output dir for GN builds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove GYP copies, and copy script and host wrapper to remoting/ build directory Created 4 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
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 # defaults can be overridden in ~/.profile. 48 # defaults can be overridden in ~/.profile.
49 DEFAULT_SIZES = "1600x1200,3840x2560" 49 DEFAULT_SIZES = "1600x1200,3840x2560"
50 50
51 # If RANDR is not available, use a smaller default size. Only a single 51 # If RANDR is not available, use a smaller default size. Only a single
52 # resolution is supported in this case. 52 # resolution is supported in this case.
53 DEFAULT_SIZE_NO_RANDR = "1600x1200" 53 DEFAULT_SIZE_NO_RANDR = "1600x1200"
54 54
55 SCRIPT_PATH = os.path.abspath(sys.argv[0]) 55 SCRIPT_PATH = os.path.abspath(sys.argv[0])
56 SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) 56 SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
57 57
58 IS_INSTALLED = (os.path.basename(sys.argv[0]) != 'linux_me2me_host.py') 58 HOST_BINARY_NAME = "chrome-remote-desktop-host"
59
60 if IS_INSTALLED:
61 HOST_BINARY_NAME = "chrome-remote-desktop-host"
62 else:
63 HOST_BINARY_NAME = "remoting_me2me_host"
64
65 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop" 59 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop"
66 60
67 HOME_DIR = os.environ["HOME"] 61 HOME_DIR = os.environ["HOME"]
68 CONFIG_DIR = os.path.join(HOME_DIR, ".config/chrome-remote-desktop") 62 CONFIG_DIR = os.path.join(HOME_DIR, ".config/chrome-remote-desktop")
69 SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session") 63 SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session")
70 SYSTEM_SESSION_FILE_PATH = "/etc/chrome-remote-desktop-session" 64 SYSTEM_SESSION_FILE_PATH = "/etc/chrome-remote-desktop-session"
71 65
72 X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock" 66 X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
73 FIRST_X_DISPLAY_NUMBER = 20 67 FIRST_X_DISPLAY_NUMBER = 20
74 68
(...skipping 25 matching lines...) Expand all
100 # The host has been tested only on Ubuntu. 94 # The host has been tested only on Ubuntu.
101 distribution = platform.linux_distribution() 95 distribution = platform.linux_distribution()
102 return (distribution[0]).lower() == 'ubuntu' 96 return (distribution[0]).lower() == 'ubuntu'
103 97
104 98
105 def get_randr_supporting_x_server(): 99 def get_randr_supporting_x_server():
106 """Returns a path to an X server that supports the RANDR extension, if this 100 """Returns a path to an X server that supports the RANDR extension, if this
107 is found on the system. Otherwise returns None.""" 101 is found on the system. Otherwise returns None."""
108 try: 102 try:
109 xvfb = "/usr/bin/Xvfb-randr" 103 xvfb = "/usr/bin/Xvfb-randr"
110 if not os.path.exists(xvfb): 104 if not os.path.exists(xvfb):
Sergey Ulanov 2016/04/18 22:48:01 merge this check with the one in locate_executable
Lambros 2016/04/18 23:45:53 Re-written this.
111 xvfb = locate_executable("Xvfb-randr") 105 xvfb = locate_executable("Xvfb-randr")
112 return xvfb 106 return xvfb
113 except Exception: 107 except Exception:
114 return None 108 return None
115 109
116 110
117 class Config: 111 class Config:
118 def __init__(self, path): 112 def __init__(self, path):
119 self.path = path 113 self.path = path
120 self.data = {} 114 self.data = {}
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 # corrupt displays). So if the ubuntu-2d session is available, 617 # corrupt displays). So if the ubuntu-2d session is available,
624 # choose it explicitly. 618 # choose it explicitly.
625 return [session_wrapper, "/usr/bin/gnome-session --session=ubuntu-2d"] 619 return [session_wrapper, "/usr/bin/gnome-session --session=ubuntu-2d"]
626 else: 620 else:
627 # Use the session wrapper by itself, and let the system choose a 621 # Use the session wrapper by itself, and let the system choose a
628 # session. 622 # session.
629 return [session_wrapper] 623 return [session_wrapper]
630 return None 624 return None
631 625
632 626
633 def locate_executable(exe_name): 627 def locate_executable(exe_name):
Sergey Ulanov 2016/04/18 22:48:01 I don't think we need this function anymore. Parti
Lambros 2016/04/18 23:45:53 Removed. I slightly tweaked the logging in one of
634 if IS_INSTALLED: 628 exe_path = os.path.join(SCRIPT_DIR, exe_name)
635 # If the script is running from its installed location, search the host 629 if os.path.exists(exe_path):
636 # binary only in the same directory. 630 return exe_path
637 paths_to_try = [ SCRIPT_DIR ]
638 else:
639 paths_to_try = map(lambda p: os.path.join(SCRIPT_DIR, p),
640 [".",
641 "../../../out/Debug",
642 "../../../out/Default",
643 "../../../out/Release"])
644 for path in paths_to_try:
645 exe_path = os.path.join(path, exe_name)
646 if os.path.exists(exe_path):
647 return exe_path
648 631
649 raise Exception("Could not locate executable '%s'" % exe_name) 632 raise Exception("Executable not found at '%s'" % exe_path)
650 633
651 634
652 class ParentProcessLogger(object): 635 class ParentProcessLogger(object):
653 """Redirects logs to the parent process, until the host is ready or quits. 636 """Redirects logs to the parent process, until the host is ready or quits.
654 637
655 This class creates a pipe to allow logging from the daemon process to be 638 This class creates a pipe to allow logging from the daemon process to be
656 copied to the parent process. The daemon process adds a log-handler that 639 copied to the parent process. The daemon process adds a log-handler that
657 directs logging output to the pipe. The parent process reads from this pipe 640 directs logging output to the pipe. The parent process reads from this pipe
658 until and writes the content to stderr. When the pipe is no longer needed 641 until and writes the content to stderr. When the pipe is no longer needed
659 (for example, the host signals successful launch or permanent failure), the 642 (for example, the host signals successful launch or permanent failure), the
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 else: 1382 else:
1400 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1383 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1401 elif os.WIFSIGNALED(status): 1384 elif os.WIFSIGNALED(status):
1402 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1385 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1403 1386
1404 1387
1405 if __name__ == "__main__": 1388 if __name__ == "__main__":
1406 logging.basicConfig(level=logging.DEBUG, 1389 logging.basicConfig(level=logging.DEBUG,
1407 format="%(asctime)s:%(levelname)s:%(message)s") 1390 format="%(asctime)s:%(levelname)s:%(message)s")
1408 sys.exit(main()) 1391 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698