Index: remoting/tools/me2me_virtual_host.py |
diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py |
index 7a9567233d44245802e3b5921230297a557040cc..6207afb4dcf52258e55eba3319c183e57f49a924 100755 |
--- a/remoting/tools/me2me_virtual_host.py |
+++ b/remoting/tools/me2me_virtual_host.py |
@@ -14,6 +14,7 @@ import getpass |
import hashlib |
import json |
import logging |
+import optparse |
import os |
import random |
import signal |
@@ -201,8 +202,10 @@ def signal_handler(signum, stackframe): |
class Desktop: |
"""Manage a single virtual desktop""" |
- def __init__(self): |
+ def __init__(self, width, height): |
self.x_proc = None |
+ self.width = width |
+ self.height = height |
g_desktops.append(self) |
@staticmethod |
@@ -222,10 +225,11 @@ class Desktop: |
raise Exception("xauth failed with code %d" % ret_code) |
logging.info("Starting Xvfb on display :%d" % display); |
+ screen_option = "%dx%dx24" % (self.width, self.height) |
self.x_proc = subprocess.Popen(["Xvfb", ":%d" % display, |
"-auth", X_AUTH_FILE, |
"-nolisten", "tcp", |
- "-screen", "0", "1024x768x24", |
+ "-screen", "0", screen_option |
]) |
if not self.x_proc.pid: |
raise Exception("Could not start Xvfb.") |
@@ -274,6 +278,26 @@ class Desktop: |
def main(): |
+ parser = optparse.OptionParser() |
+ parser.add_option("-s", "--size", dest="size", default="1280x1024", |
+ help="dimensions of virtual desktop (default: %default)") |
+ (options, args) = parser.parse_args() |
+ |
+ size_components = options.size.split("x") |
+ if len(size_components) != 2: |
+ parser.error("Incorrect size format, should be WIDTHxHEIGHT"); |
+ |
+ try: |
+ width = int(size_components[0]) |
+ height = int(size_components[1]) |
+ |
+ # Enforce minimum desktop size, as a sanity-check. The limit of 100 will |
+ # detect typos of 2 instead of 3 digits. |
+ if width < 100 or height < 100: |
+ raise ValueError |
+ except ValueError: |
+ parser.error("Dimensions should be 100 pixels or greater") |
Wez
2011/12/13 01:43:52
nit: I'd actually use "Width and height" rather th
|
+ |
atexit.register(cleanup) |
for s in [signal.SIGHUP, signal.SIGINT, signal.SIGTERM]: |
@@ -301,7 +325,7 @@ def main(): |
logging.info("Using host_id: " + host.host_id) |
- desktop = Desktop() |
+ desktop = Desktop(width, height) |
desktop.launch_x_server() |
desktop.launch_x_session() |
desktop.launch_host(host) |