mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-13 13:17:57 +03:00
Merge heads
This commit is contained in:
commit
7aa98ee19c
@ -1,5 +1,5 @@
|
||||
|
||||
SUBDIRS = virtManager vncViewer graphWidgets
|
||||
SUBDIRS = vncViewer graphWidgets virtManager
|
||||
|
||||
bin_SOURCES = virt-manager.in
|
||||
bin_SCRIPTS = virt-manager
|
||||
|
@ -24,6 +24,7 @@ import sys
|
||||
|
||||
import locale
|
||||
import gettext
|
||||
import logging
|
||||
|
||||
gettext_app = "virt-manager"
|
||||
gettext_dir = "::GETTEXTDIR::"
|
||||
@ -31,6 +32,21 @@ gettext_dir = "::GETTEXTDIR::"
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext.install(gettext_app, gettext_dir)
|
||||
|
||||
# set up logging
|
||||
vm_dir = os.path.expanduser("~/.virt-manager")
|
||||
if not os.access(vm_dir,os.W_OK):
|
||||
try:
|
||||
os.mkdir(vm_dir)
|
||||
except IOError, e:
|
||||
raise RuntimeError, "Could not create %d directory: " % vm_dir, e
|
||||
|
||||
# XXX should we get logging level from gconf, or command line args ?
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format="%(asctime)s %(levelname)-8s %(message)s",
|
||||
datefmt="%a, %d %b %Y %H:%M:%S",
|
||||
filename="%s/virt-manager.log" % vm_dir,
|
||||
filemode='w')
|
||||
|
||||
# Urgh, pygtk merely logs a warning when failing to open
|
||||
# the X11 display connection, and lets everything carry
|
||||
# on as if all were fine. Ultimately bad stuff happens,
|
||||
@ -104,6 +120,8 @@ def main():
|
||||
else:
|
||||
bus = None
|
||||
try:
|
||||
if os.getenv("DBUS_STARTER_ADDRESS") == None and os.getenv("DBUS_SESSION_BUS_ADDRESS") == None:
|
||||
raise RuntimeError, "DBus session/starter bus address not defined"
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
dbusProxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
||||
@ -124,8 +142,8 @@ def main():
|
||||
# yes, we exit completely now - remote service is in charge
|
||||
return
|
||||
except:
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
print _("Could not connection to session bus, disabling DBus service")
|
||||
logging.warning("Could not connection to session bus, disabling DBus service " + \
|
||||
str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
|
||||
if options.uri != None:
|
||||
engine.show_manager(options.uri)
|
||||
else:
|
||||
|
@ -3,3 +3,14 @@ pythondir = $(pkgdatadir)/virtManager
|
||||
python_DATA = $(wildcard $(srcdir)/*.py)
|
||||
|
||||
EXTRA_DIST = $(python_DATA)
|
||||
|
||||
SYNTAX_CHECK_TSTAMPS = $(python_DATA:$(srcdir)/%.py=.tstamp.%.py)
|
||||
|
||||
|
||||
check-local: $(SYNTAX_CHECK_TSTAMPS)
|
||||
|
||||
clean-local:
|
||||
rm -f $(SYNTAX_CHECK_TSTAMPS)
|
||||
|
||||
.tstamp.%.py: %.py
|
||||
PYTHONPATH=$(srcdir)/..:../graphWidgets/.libs python $< && touch $@
|
||||
|
@ -18,7 +18,6 @@
|
||||
#
|
||||
import gconf
|
||||
import os
|
||||
import logging
|
||||
|
||||
import gtk.gdk
|
||||
import libvirt
|
||||
@ -33,21 +32,7 @@ class vmmConfig:
|
||||
self.conf = gconf.client_get_default()
|
||||
self.conf.add_dir (gconf_dir,
|
||||
gconf.CLIENT_PRELOAD_NONE)
|
||||
# set up logging
|
||||
vm_dir = "%s/.virt-manager" % os.environ['HOME']
|
||||
if not os.access(vm_dir,os.W_OK):
|
||||
try:
|
||||
os.mkdir(vm_dir)
|
||||
except IOError, e:
|
||||
raise RuntimeError, "Could not create %d directory: " % vm_dir, e
|
||||
|
||||
# XXX should get logging level from gconf
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format="%(asctime)s %(levelname)-8s %(message)s",
|
||||
datefmt="%a, %d %b %Y %H:%M:%S",
|
||||
filename="%s/virt-manager.log" % vm_dir,
|
||||
filemode='w')
|
||||
logging.debug("Initialized Python logger")
|
||||
self.glade_dir = glade_dir
|
||||
self.icon_dir = icon_dir
|
||||
# We don't create it straight away, since we don't want
|
||||
|
@ -22,6 +22,7 @@ import cairo
|
||||
import gtk.glade
|
||||
import libvirt
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from vncViewer.vnc import GRFBViewer
|
||||
|
||||
@ -131,7 +132,7 @@ class vmmConsole(gobject.GObject):
|
||||
try:
|
||||
self.vncViewer.disconnect_from_host()
|
||||
except:
|
||||
print "Failure when disconnecting"
|
||||
logging.error("Failure when disconnecting from VNC server")
|
||||
return 1
|
||||
|
||||
def control_vm_run(self, src):
|
||||
@ -147,7 +148,7 @@ class vmmConsole(gobject.GObject):
|
||||
if self.vm.get_id() == 0:
|
||||
return
|
||||
|
||||
#print protocol + "://" + host + ":" + str(port)
|
||||
logging.debug("Graphics " + protocol + "://" + host + ":" + str(port))
|
||||
if protocol != "vnc":
|
||||
self.activate_unavailable_page()
|
||||
return
|
||||
@ -156,7 +157,7 @@ class vmmConsole(gobject.GObject):
|
||||
try:
|
||||
self.vncViewer.connect_to_host(host, port)
|
||||
except:
|
||||
print _("Unable to activate console") + " " + str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1])
|
||||
logging.error("Unable to activate console " + str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1]))
|
||||
self.activate_unavailable_page()
|
||||
return
|
||||
|
||||
@ -255,7 +256,7 @@ class vmmConsole(gobject.GObject):
|
||||
if not(status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]):
|
||||
self.vm.shutdown()
|
||||
else:
|
||||
print _("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
logging.warning("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
|
||||
def control_vm_pause(self, src):
|
||||
if self.ignorePause:
|
||||
@ -263,18 +264,18 @@ class vmmConsole(gobject.GObject):
|
||||
|
||||
status = self.vm.status()
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
print _("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
logging.warning("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
else:
|
||||
if status in [ libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
if not src.get_active():
|
||||
self.vm.resume()
|
||||
else:
|
||||
print _("Pause requested, but machine is already paused")
|
||||
logging.warning("Pause requested, but machine is already paused")
|
||||
else:
|
||||
if src.get_active():
|
||||
self.vm.suspend()
|
||||
else:
|
||||
print _("Resume requested, but machine is already running")
|
||||
logging.warning("Resume requested, but machine is already running")
|
||||
|
||||
self.window.get_widget("control-pause").set_active(src.get_active())
|
||||
self.window.get_widget("menu-vm-pause").set_active(src.get_active())
|
||||
@ -356,7 +357,7 @@ class vmmConsole(gobject.GObject):
|
||||
try:
|
||||
self.try_login()
|
||||
except:
|
||||
print _("Couldn't open console: ") + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
logging.error("Couldn't open console " + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
|
||||
self.ignorePause = False
|
||||
else:
|
||||
self.activate_unavailable_page()
|
||||
|
@ -22,6 +22,7 @@ import gtk
|
||||
import gtk.glade
|
||||
import libvirt
|
||||
import sparkline
|
||||
import logging
|
||||
|
||||
class vmmDetails(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
@ -176,7 +177,7 @@ class vmmDetails(gobject.GObject):
|
||||
if not(status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]):
|
||||
self.vm.shutdown()
|
||||
else:
|
||||
print _("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
logging.warning("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
|
||||
def control_vm_pause(self, src):
|
||||
if self.ignorePause:
|
||||
@ -184,18 +185,18 @@ class vmmDetails(gobject.GObject):
|
||||
|
||||
status = self.vm.status()
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
print _("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
logging.warning("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
else:
|
||||
if status in [ libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
if not src.get_active():
|
||||
self.vm.resume()
|
||||
else:
|
||||
print _("Pause requested, but machine is already paused")
|
||||
logging.warning("Pause requested, but machine is already paused")
|
||||
else:
|
||||
if src.get_active():
|
||||
self.vm.suspend()
|
||||
else:
|
||||
print _("Resume requested, but machine is already running")
|
||||
logging.warning("Resume requested, but machine is already running")
|
||||
|
||||
self.window.get_widget("control-pause").set_active(src.get_active())
|
||||
self.window.get_widget("details-menu-pause").set_active(src.get_active())
|
||||
|
@ -22,6 +22,7 @@ import libvirt
|
||||
import libxml2
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
class vmmDomain(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
@ -394,8 +395,8 @@ class vmmDomain(gobject.GObject):
|
||||
|
||||
def set_memory(self, memory):
|
||||
memory = int(memory)
|
||||
if(memory > self.maximum_memory()):
|
||||
print "XXX add proper error handling here. You may not set vm memory larger than the maximum set for the vm."
|
||||
if (memory > self.maximum_memory()):
|
||||
logging.warning("Requested memory " + str(memory) + " over maximum " + self.maximum_memory())
|
||||
self.vm.setMemory(memory)
|
||||
return self.vm.info()[2]
|
||||
|
||||
|
@ -20,6 +20,7 @@ import gobject
|
||||
import gtk
|
||||
import sys
|
||||
import libvirt
|
||||
import logging
|
||||
|
||||
from virtManager.about import vmmAbout
|
||||
from virtManager.connect import vmmConnect
|
||||
@ -63,8 +64,8 @@ class vmmEngine:
|
||||
conn = self.get_connection(uri, readOnly)
|
||||
self.show_manager(uri)
|
||||
except:
|
||||
print _("Unable to open connection to hypervisor URI '%s'") % str(uri)
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
logging.error((("Unable to open connection to hypervisor URI '%s'") % str(uri)) + \
|
||||
str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
|
||||
|
||||
if len(self.connections.keys()) == 0:
|
||||
gtk.main_quit()
|
||||
@ -105,8 +106,7 @@ class vmmEngine:
|
||||
except KeyboardInterrupt:
|
||||
raise KeyboardInterrupt
|
||||
except:
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
print _("Error refreshing connection '%s'") % uri
|
||||
logging.error(("Could not refresh connection %s" % (uri)) + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
|
||||
return 1
|
||||
|
||||
def change_timer_interval(self,ignore1,ignore2,ignore3,ignore4):
|
||||
@ -240,7 +240,7 @@ class vmmEngine:
|
||||
libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED,
|
||||
libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
print _("Save requested, but machine is shutdown / shutoff / paused")
|
||||
logging.warning("Save requested, but machine is shutdown / shutoff / paused")
|
||||
else:
|
||||
self.fcdialog = gtk.FileChooserDialog(_("Save Virtual Machine"),
|
||||
src.window.get_widget("vmm-details"),
|
||||
|
@ -19,6 +19,7 @@
|
||||
from virtManager.secret import *
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
haveKeyring = False
|
||||
|
||||
@ -26,7 +27,7 @@ try:
|
||||
import gnomekeyring
|
||||
haveKeyring = True
|
||||
except:
|
||||
print _("No support for gnome-keyring")
|
||||
logging.warning("No support for gnome-keyring")
|
||||
pass
|
||||
|
||||
class vmmKeyring:
|
||||
@ -38,7 +39,7 @@ class vmmKeyring:
|
||||
gnomekeyring.create_sync("default", None)
|
||||
self.keyring = gnomekeyring.get_default_keyring_sync()
|
||||
except:
|
||||
print _("Keyring unavailable: '%s'") % (str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1]))
|
||||
logging.warning(("Keyring unavailable: '%s'") % (str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1])))
|
||||
self.keyring = None
|
||||
else:
|
||||
self.keyring = None
|
||||
|
Loading…
Reference in New Issue
Block a user