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

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

Issue 883063002: Fix linux_me2me_host.py to handle relative path to self. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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 #!/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 # By default, provide a maximum size that is large enough to support clients 42 # By default, provide a maximum size that is large enough to support clients
43 # with large or multiple monitors. This is a comma-separated list of 43 # with large or multiple monitors. This is a comma-separated list of
44 # resolutions that will be made available if the X server supports RANDR. These 44 # resolutions that will be made available if the X server supports RANDR. These
45 # defaults can be overridden in ~/.profile. 45 # defaults can be overridden in ~/.profile.
46 DEFAULT_SIZES = "1600x1200,3840x2560" 46 DEFAULT_SIZES = "1600x1200,3840x2560"
47 47
48 # If RANDR is not available, use a smaller default size. Only a single 48 # If RANDR is not available, use a smaller default size. Only a single
49 # resolution is supported in this case. 49 # resolution is supported in this case.
50 DEFAULT_SIZE_NO_RANDR = "1600x1200" 50 DEFAULT_SIZE_NO_RANDR = "1600x1200"
51 51
52 SCRIPT_PATH = sys.path[0] 52 SCRIPT_PATH = os.path.abspath(sys.argv[0])
53 SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
53 54
54 IS_INSTALLED = (os.path.basename(sys.argv[0]) != 'linux_me2me_host.py') 55 IS_INSTALLED = (os.path.basename(sys.argv[0]) != 'linux_me2me_host.py')
55 56
56 if IS_INSTALLED: 57 if IS_INSTALLED:
57 HOST_BINARY_NAME = "chrome-remote-desktop-host" 58 HOST_BINARY_NAME = "chrome-remote-desktop-host"
58 else: 59 else:
59 HOST_BINARY_NAME = "remoting_me2me_host" 60 HOST_BINARY_NAME = "remoting_me2me_host"
60 61
61 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop" 62 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop"
62 63
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 args = ["xrandr", "-s", label] 439 args = ["xrandr", "-s", label]
439 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) 440 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull)
440 441
441 # Set the physical size of the display so that the initial mode is running 442 # Set the physical size of the display so that the initial mode is running
442 # at approximately 96 DPI, since some desktops require the DPI to be set to 443 # at approximately 96 DPI, since some desktops require the DPI to be set to
443 # something realistic. 444 # something realistic.
444 args = ["xrandr", "--dpi", "96"] 445 args = ["xrandr", "--dpi", "96"]
445 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) 446 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull)
446 447
447 # Monitor for any automatic resolution changes from the desktop environment. 448 # Monitor for any automatic resolution changes from the desktop environment.
448 args = [sys.argv[0], "--watch-resolution", str(initial_size[0]), 449 args = [SCRIPT_PATH, "--watch-resolution", str(initial_size[0]),
449 str(initial_size[1])] 450 str(initial_size[1])]
450 451
451 # It is not necessary to wait() on the process here, as this script's main 452 # It is not necessary to wait() on the process here, as this script's main
452 # loop will reap the exit-codes of all child processes. 453 # loop will reap the exit-codes of all child processes.
453 subprocess.Popen(args, env=self.child_env, stdout=devnull, stderr=devnull) 454 subprocess.Popen(args, env=self.child_env, stdout=devnull, stderr=devnull)
454 455
455 devnull.close() 456 devnull.close()
456 457
457 def _launch_x_session(self): 458 def _launch_x_session(self):
458 # Start desktop session. 459 # Start desktop session.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 # Use the session wrapper by itself, and let the system choose a 602 # Use the session wrapper by itself, and let the system choose a
602 # session. 603 # session.
603 return [session_wrapper] 604 return [session_wrapper]
604 return None 605 return None
605 606
606 607
607 def locate_executable(exe_name): 608 def locate_executable(exe_name):
608 if IS_INSTALLED: 609 if IS_INSTALLED:
609 # If the script is running from its installed location, search the host 610 # If the script is running from its installed location, search the host
610 # binary only in the same directory. 611 # binary only in the same directory.
611 paths_to_try = [ SCRIPT_PATH ] 612 paths_to_try = [ SCRIPT_DIR ]
612 else: 613 else:
613 paths_to_try = map(lambda p: os.path.join(SCRIPT_PATH, p), 614 paths_to_try = map(lambda p: os.path.join(SCRIPT_DIR, p),
614 [".", "../../../out/Debug", "../../../out/Release" ]) 615 [".", "../../../out/Debug", "../../../out/Release" ])
615 for path in paths_to_try: 616 for path in paths_to_try:
616 exe_path = os.path.join(path, exe_name) 617 exe_path = os.path.join(path, exe_name)
617 if os.path.exists(exe_path): 618 if os.path.exists(exe_path):
618 return exe_path 619 return exe_path
619 620
620 raise Exception("Could not locate executable '%s'" % exe_name) 621 raise Exception("Could not locate executable '%s'" % exe_name)
621 622
622 623
623 class ParentProcessLogger(object): 624 class ParentProcessLogger(object):
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 self.running = False 879 self.running = False
879 if time.time() < self.earliest_successful_termination: 880 if time.time() < self.earliest_successful_termination:
880 self.failures += 1 881 self.failures += 1
881 else: 882 else:
882 self.failures = 0 883 self.failures = 0
883 logging.info("Failure count for '%s' is now %d", self.label, self.failures) 884 logging.info("Failure count for '%s' is now %d", self.label, self.failures)
884 885
885 886
886 def relaunch_self(): 887 def relaunch_self():
887 cleanup() 888 cleanup()
888 os.execvp(sys.argv[0], sys.argv) 889 os.execvp(SCRIPT_PATH, sys.argv)
889 890
890 891
891 def waitpid_with_timeout(pid, deadline): 892 def waitpid_with_timeout(pid, deadline):
892 """Wrapper around os.waitpid() which waits until either a child process dies 893 """Wrapper around os.waitpid() which waits until either a child process dies
893 or the deadline elapses. 894 or the deadline elapses.
894 895
895 Args: 896 Args:
896 pid: Process ID to wait for, or -1 to wait for any child process. 897 pid: Process ID to wait for, or -1 to wait for any child process.
897 deadline: Waiting stops when time.time() exceeds this value. 898 deadline: Waiting stops when time.time() exceeds this value.
898 899
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 else: 1311 else:
1311 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1312 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1312 elif os.WIFSIGNALED(status): 1313 elif os.WIFSIGNALED(status):
1313 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1314 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1314 1315
1315 1316
1316 if __name__ == "__main__": 1317 if __name__ == "__main__":
1317 logging.basicConfig(level=logging.DEBUG, 1318 logging.basicConfig(level=logging.DEBUG,
1318 format="%(asctime)s:%(levelname)s:%(message)s") 1319 format="%(asctime)s:%(levelname)s:%(message)s")
1319 sys.exit(main()) 1320 sys.exit(main())
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