Fix up various remaining pylint.

This commit is contained in:
Cole Robinson 2008-11-18 17:01:22 -05:00
parent a14b844b20
commit 0187458ba9
13 changed files with 59 additions and 52 deletions

View File

@ -143,7 +143,6 @@ def setup_logging():
# Log uncaught exceptions
def exception_log(typ, val, tb):
import traceback
s = traceback.format_exception(typ, val, tb)
logging.exception("".join(s))
sys.__excepthook__(typ, val, tb)
@ -261,11 +260,9 @@ def main():
except Warning, e:
# ...the risk is we catch too much though
# Damned if we do, damned if we dont :-)(
print _("Unable to initialize GTK: ") + str(e)
sys.exit(1)
raise RuntimeError(_("Unable to initialize GTK: %s") % str(e))
warnings.resetwarnings()
import gtk
gtk.gdk.threads_init()
import dbus
@ -345,6 +342,6 @@ def main():
if __name__ == "__main__":
try:
main()
except Exception, e:
logging.exception(e)
_show_startup_error(str(e), "".join(traceback.format_exc()))
except Exception, run_e:
logging.exception(run_e)
_show_startup_error(str(run_e), "".join(traceback.format_exc()))

View File

@ -61,6 +61,9 @@ class vmmAddHardware(gobject.GObject):
0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
_("Unexpected Error"),
_("An unexpected error occurred"))
self.install_error = ""
self.install_details = ""
self.topwin.hide()
self.window.signal_autoconnect({
"on_create_pages_switch_page" : self.page_changed,

View File

@ -55,13 +55,13 @@ class vmmAsyncJob(gobject.GObject):
self.is_pulsing = True
def run(self):
self.timer = gobject.timeout_add (100, self.exit_if_necessary)
timer = gobject.timeout_add (100, self.exit_if_necessary)
self.topwin.present()
self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
self.bg_thread.start()
gtk.main()
gobject.source_remove(self.timer)
self.timer = 0
gobject.source_remove(timer)
timer = 0
self.topwin.destroy()
def pulse_pbar(self, progress="", stage=None):

View File

@ -136,8 +136,8 @@ class vmmChooseCD(gobject.GObject):
def populate_opt_media(self):
try:
self.optical_helper = vmmOpticalDriveHelper(self.window.get_widget("cd-path"))
self.optical_helper.populate_opt_media()
optical_helper = vmmOpticalDriveHelper(self.window.get_widget("cd-path"))
optical_helper.populate_opt_media()
self.window.get_widget("physical-media").set_sensitive(True)
except Exception, e:
logging.error("Unable to create optical-helper widget: '%s'", e)

View File

@ -25,7 +25,6 @@ import os, sys
import glob
import traceback
from time import time
import logging
from socket import gethostbyaddr, gethostname
import dbus
import threading
@ -1055,8 +1054,10 @@ class vmmConnection(gobject.GObject):
f = open("/sys/class/net/bonding_masters")
while True:
rline = f.readline()
if not rline: break
if rline == "\x00": continue
if not rline:
break
if rline == "\x00":
continue
rline = rline.strip("\n\t")
masters = rline[:].split(' ')
return masters

View File

@ -79,6 +79,10 @@ class vmmCreate(gobject.GObject):
0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
_("Unexpected Error"),
_("An unexpected error occurred"))
self.install_error = ""
self.install_details = ""
self.non_sparse = True
self.topwin.hide()
self.window.signal_autoconnect({
"on_create_pages_switch_page" : self.page_changed,
@ -138,7 +142,7 @@ class vmmCreate(gobject.GObject):
cd_list.add_attribute(text, 'text', 1)
cd_list.add_attribute(text, 'sensitive', 2)
try:
self.optical_helper = vmmOpticalDriveHelper(self.window.get_widget("cd-path"))
vmmOpticalDriveHelper(self.window.get_widget("cd-path"))
self.window.get_widget("media-physical").set_sensitive(True)
except Exception, e:
logging.error("Unable to create optical-helper widget: '%s'", e)
@ -840,8 +844,8 @@ class vmmCreate(gobject.GObject):
if not self.connection.is_remote():
n = 1
while os.path.exists(_file) and n < 100:
file = os.path.join(_dir, self.get_config_name() + \
"-" + str(n) + ".img")
_file = os.path.join(_dir, self.get_config_name() + \
"-" + str(n) + ".img")
n = n + 1
if os.path.exists(_file):
_file = ""

View File

@ -27,7 +27,7 @@ class vmmCreateMeter(progress.BaseMeter):
progress.BaseMeter.__init__(self)
self.asyncjob = asyncjob
def _do_start(self, now):
def _do_start(self, now=None):
if self.text is not None:
text = self.text
else:

View File

@ -27,7 +27,6 @@ import logging
import traceback
import sys
import dbus
import traceback
import gtkvnc
import os
import socket
@ -116,6 +115,7 @@ class vmmDetails(gobject.GObject):
self.engine = engine
self.dynamic_tabs = []
self.ignorePause = False
# Don't allowing changing network/disks for Dom0
if self.vm.is_management_domain():
@ -247,7 +247,6 @@ class vmmDetails(gobject.GObject):
self.notifyInterface.connect_to_signal("NotificationClosed", self.notify_closed)
except Exception, e:
logging.error("Cannot initialize notification system" + str(e))
pass
self.window.get_widget("console-pages").set_show_tabs(False)
self.window.get_widget("details-menu-view-toolbar").set_active(self.config.get_details_show_toolbar())
@ -396,10 +395,9 @@ class vmmDetails(gobject.GObject):
["dismiss", _("Do not show this notification in the future")],
{"desktop-entry": "virt-manager",
"x": x+200, "y": y},
8 * 1000);
8 * 1000)
except Exception, e:
logging.error("Cannot popup notification " + str(e))
pass
def notify_ungrabbed(self, src):
topwin = self.window.get_widget("vmm-details")
@ -1711,7 +1709,7 @@ class vmmDetails(gobject.GObject):
devs = range(len(hw_list_model))
devs.reverse()
for i in devs:
iter = hw_list_model.iter_nth_child(None, i)
_iter = hw_list_model.iter_nth_child(None, i)
row = hw_list_model[i]
removeIt = False
@ -1744,7 +1742,7 @@ class vmmDetails(gobject.GObject):
hw_list.get_selection().select_iter(selModel.iter_nth_child(None, 0))
# Now actually remove it
hw_list_model.remove(iter)
hw_list_model.remove(_iter)
def repopulate_boot_list(self):
hw_list_model = self.window.get_widget("hw-list").get_model()

View File

@ -52,8 +52,11 @@ class vmmDomain(gobject.GObject):
self._update_status()
self.xml = None
self._network_traffic = None
self.config.on_vmlist_network_traffic_visible_changed(self.toggle_sample_network_traffic)
self.toggle_sample_network_traffic()
self._disk_io = None
self.config.on_vmlist_disk_io_visible_changed(self.toggle_sample_disk_io)
self.toggle_sample_disk_io()

View File

@ -152,7 +152,7 @@ class vmmEngine(gobject.GObject):
try:
self.connections[uri]["connection"].tick()
except KeyboardInterrupt:
raise KeyboardInterrupt
raise
except:
logging.error(("Could not refresh connection %s\n" % (uri)) + str(sys.exc_info()[0]) + \
" " + str(sys.exc_info()[1]) + "\n" + \
@ -403,24 +403,24 @@ class vmmEngine(gobject.GObject):
libvirt.VIR_DOMAIN_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"),
gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT),
None)
self.fcdialog.set_default_response(gtk.RESPONSE_ACCEPT)
self.fcdialog.set_current_folder(self.config.get_default_save_dir(con))
self.fcdialog.set_do_overwrite_confirmation(True)
response = self.fcdialog.run()
self.fcdialog.hide()
fcdialog = gtk.FileChooserDialog(_("Save Virtual Machine"),
src.window.get_widget("vmm-details"),
gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT),
None)
fcdialog.set_default_response(gtk.RESPONSE_ACCEPT)
fcdialog.set_current_folder(self.config.get_default_save_dir(con))
fcdialog.set_do_overwrite_confirmation(True)
response = fcdialog.run()
fcdialog.hide()
if(response == gtk.RESPONSE_ACCEPT):
file_to_save = self.fcdialog.get_filename()
file_to_save = fcdialog.get_filename()
progWin = vmmAsyncJob(self.config, self._save_callback,
[vm, file_to_save],
_("Saving Virtual Machine"))
progWin.run()
self.fcdialog.destroy()
fcdialog.destroy()
if self._save_callback_info != []:
self.err.show_err(_("Error saving domain: %s" % self._save_callback_info[0]), self._save_callback_info[1])
@ -618,7 +618,7 @@ class vmmEngine(gobject.GObject):
reason = _("Cannot migrate to same connection.")
# Explicitly don't include this in the list
continue;
continue
elif conn.get_state() == vmmConnection.STATE_ACTIVE:
# Assumably we can migrate to this connection
can_migrate = True

View File

@ -29,7 +29,6 @@ try:
haveKeyring = True
except:
logging.warning("No support for gnome-keyring")
pass
class vmmKeyring:

View File

@ -202,7 +202,7 @@ class vmmManager(gobject.GObject):
self.vmmenushutdown.add(self.vmmenushutdown_items["forcepoweroff"])
self.vmmenu_items["hsep1"] = gtk.SeparatorMenuItem()
self.vmmenu_items["hsep1"].show();
self.vmmenu_items["hsep1"].show()
self.vmmenu.add(self.vmmenu_items["hsep1"])
self.vmmenu_items["migrate"] = gtk.ImageMenuItem("_Migrate")
@ -213,7 +213,7 @@ class vmmManager(gobject.GObject):
self.vmmenu.add(self.vmmenu_items["migrate"])
self.vmmenu_items["hsep2"] = gtk.SeparatorMenuItem()
self.vmmenu_items["hsep2"].show();
self.vmmenu_items["hsep2"].show()
self.vmmenu.add(self.vmmenu_items["hsep2"])
self.vmmenu_items["open"] = gtk.ImageMenuItem(gtk.STOCK_OPEN)
@ -246,7 +246,7 @@ class vmmManager(gobject.GObject):
self.connmenu.add(self.connmenu_items["disconnect"])
self.connmenu_items["hsep"] = gtk.SeparatorMenuItem()
self.connmenu_items["hsep"].show();
self.connmenu_items["hsep"].show()
self.connmenu.add(self.connmenu_items["hsep"])
self.connmenu_items["details"] = gtk.ImageMenuItem("_Details")
@ -348,19 +348,19 @@ class vmmManager(gobject.GObject):
return
# get filename
self.fcdialog = gtk.FileChooserDialog(_("Restore Virtual Machine"),
fcdialog = gtk.FileChooserDialog(_("Restore Virtual Machine"),
self.window.get_widget("vmm-manager"),
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT),
None)
self.fcdialog.set_default_response(gtk.RESPONSE_ACCEPT)
self.fcdialog.set_current_folder(self.config.get_default_save_dir(self.current_connection()))
fcdialog.set_default_response(gtk.RESPONSE_ACCEPT)
fcdialog.set_current_folder(self.config.get_default_save_dir(self.current_connection()))
# pop up progress dialog
response = self.fcdialog.run()
self.fcdialog.hide()
response = fcdialog.run()
fcdialog.hide()
if(response == gtk.RESPONSE_ACCEPT):
file_to_load = self.fcdialog.get_filename()
file_to_load = fcdialog.get_filename()
if self.is_valid_saved_image(file_to_load):
progWin = vmmAsyncJob(self.config,
self.restore_saved_callback,
@ -371,7 +371,7 @@ class vmmManager(gobject.GObject):
self.err.val_err(_("The file '%s' does not appear to be a valid saved machine image") % file_to_load)
return
self.fcdialog.destroy()
fcdialog.destroy()
if(self.domain_restore_error != ""):
self.err.val_err(self.domain_restore_error)
self.domain_restore_error = ""

View File

@ -21,10 +21,12 @@
class vmmSecret:
def __init__(self, name, secret=None, attributes={}):
def __init__(self, name, secret=None, attributes=None):
self.name = name
self.secret = secret
if attributes == None:
attributes = {}
self.attributes = attributes
def set_secret(self, data):