Make SpiceClientGtk optional

Not all architectures supported by Debian have it. This will allow to
make VNC work nevertheless.
This commit is contained in:
Guido Günther 2015-08-13 22:00:33 +02:00 committed by Cole Robinson
parent 22022d95dc
commit a1383faff3
2 changed files with 14 additions and 5 deletions

View File

@ -29,7 +29,7 @@ from .baseclass import vmmGObjectUI
from .details import DETAILS_PAGE_CONSOLE
from .serialcon import vmmSerialConsole
from .sshtunnels import ConnectionInfo
from .viewers import SpiceViewer, VNCViewer
from .viewers import SpiceViewer, VNCViewer, have_spice_gtk
# console-pages IDs
@ -665,7 +665,12 @@ class vmmConsolePages(vmmGObjectUI):
if ginfo.gtype == "vnc":
viewer_class = VNCViewer
elif ginfo.gtype == "spice":
if have_spice_gtk:
viewer_class = SpiceViewer
else:
raise RuntimeError("Error opening Spice console, "
"SpiceClientGtk missing")
self._viewer = viewer_class(ginfo)
self._connect_viewer_signals()

View File

@ -25,9 +25,13 @@ from gi.repository import Gdk
import gi
gi.require_version('GtkVnc', '2.0')
from gi.repository import GtkVnc
try:
gi.require_version('SpiceClientGtk', '3.0')
from gi.repository import SpiceClientGtk
from gi.repository import SpiceClientGLib
have_spice_gtk = True
except (ValueError, ImportError):
have_spice_gtk = False
import logging
import socket