Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin M. Schwartz <bens@alum.mit.edu>2010-07-25 20:13:33 (GMT)
committer Benjamin M. Schwartz <bens@alum.mit.edu>2010-07-25 20:13:33 (GMT)
commitd6cc894cd714354f0ca4aaf754d4b11536cc385d (patch)
tree85cabd8743d49646877f4f4f19bd909b44f386f1
parent43445d6a39c1c350e604b795aa78adac7374124c (diff)
Display error message if deps are not installed.
-rw-r--r--watchme.py79
1 files changed, 44 insertions, 35 deletions
diff --git a/watchme.py b/watchme.py
index 38ecd8a..e89fd95 100644
--- a/watchme.py
+++ b/watchme.py
@@ -57,7 +57,7 @@ class WatchMeActivity(activity.Activity):
self.set_toolbox(toolbox)
toolbox.show()
- label = gtk.Label(gettext("If you want people to be able to see everything on your screen, invite them to this activity"))
+ self._label = gtk.Label(gettext("If you want people to be able to see everything on your screen, invite them to this activity"))
self._connected = True
# The initiator is "connected" without actually connecting to the VNC
@@ -67,13 +67,13 @@ class WatchMeActivity(activity.Activity):
#A GUI is not created for a joiner. Hopefully, the vncviewer window
#will be the first window created by the activity, and so will get
#a working icon, etc.
- label = gtk.Label(gettext("Please wait while you are connected to the shared session"))
+ self._label = gtk.Label(gettext("Please wait while you are connected to the shared session"))
self._connected = False
if self.get_shared(): #Already joined for some reason
self._joined_cb()
else:
self.connect('joined', self._joined_cb)
- self.set_canvas(label)
+ self.set_canvas(self._label)
self.show_all()
def _sharing_setup(self):
@@ -87,42 +87,47 @@ class WatchMeActivity(activity.Activity):
# allowing multiple viewers to join
# continue running indefinitely
# allow connections only from localhost
- self._vncdaemon = subprocess.Popen(['x11vnc', #search the PATH
+ try:
+ self._vncdaemon = subprocess.Popen(['x11vnc', #search the PATH
'-autoport',str(port),
'-viewonly',
'-shared',
'-forever',
'-localhost'], stdout=subprocess.PIPE)
-
- # When run with -autoport, x11vnc finds an open port, opens it, and
- # prints a line of the form
- # PORT=5972
- # to stdout.
- x = self._vncdaemon.stdout.readline()
- success = 'PORT='
- if x[:len(success)] == success:
- port = int(x[len(success):])
- logging.debug('started VNC daemon successfully on port %d' % port)
- else:
- self._vncdaemon.terminate()
- self._vncdaemon.wait()
- self._logger.error('unable to find an open port!')
- self.close()
- return (params, port)
+ # When run with -autoport, x11vnc finds an open port, opens it, and
+ # prints a line of the form
+ # PORT=5972
+ # to stdout.
+ x = self._vncdaemon.stdout.readline()
+ success = 'PORT='
+ if x[:len(success)] == success:
+ port = int(x[len(success):])
+ logging.debug('started VNC daemon successfully on port %d' % port)
+ else:
+ self._vncdaemon.terminate()
+ self._vncdaemon.wait()
+ self._logger.error('unable to find an open port!')
+ self.close()
+ return (params, port)
+ except OSError:
+ self._label.set_text("x11vnc is required, but not properly installed. Please install x11vnc and restart this activity.")
+ return (None, None)
+
def _shared_cb(self, activity):
self._logger.debug('My activity was shared')
self.initiating = True
(params, port) = self._sharing_setup()
- self._logger.debug('This is my activity: making a tube...')
-
- address = ('127.0.0.1', dbus.UInt16(port))
-
- tubes_chan = self._shared_activity.telepathy_tubes_chan
- id = tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferStreamTube(
- SERVICE, params, telepathy.SOCKET_ADDRESS_TYPE_IPV4, address,
- telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0)
+ if port is not None:
+ self._logger.debug('This is my activity: making a tube...')
+
+ address = ('127.0.0.1', dbus.UInt16(port))
+
+ tubes_chan = self._shared_activity.telepathy_tubes_chan
+ id = tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferStreamTube(
+ SERVICE, params, telepathy.SOCKET_ADDRESS_TYPE_IPV4, address,
+ telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0)
def _joined_cb(self, also_self):
tubes_chan = self._shared_activity.telepathy_tubes_chan
@@ -151,13 +156,17 @@ class WatchMeActivity(activity.Activity):
# 'localhost::%d' % port,
# '-ViewOnly',
# '-Shared'])
- import gtkvnc
- vncwidget = gtkvnc.Display()
- self.set_canvas(vncwidget)
- vncwidget.realize() # I don't know what this does
- vncwidget.open_host('localhost',str(port))
- self._connected = True
- self.show_all()
+ try:
+ import gtkvnc
+ vncwidget = gtkvnc.Display()
+ self.set_canvas(vncwidget)
+ vncwidget.realize() # I don't know what this does
+ vncwidget.open_host('localhost',str(port))
+ self._connected = True
+ self.show_all()
+ except ImportError:
+ self._label.set_text("gtk-vnc-python is not properly installed. You must install gtk-vnc-python and restart this activity.")
+
def can_close(self):
#if self._vncviewer is not None: