Fix the last of the pylint messages

If using an older pylint, there are still some complaints about hashlib
and Popen, but those aren't our problems.
This commit is contained in:
Cole Robinson 2013-04-12 09:51:26 -04:00
parent b8f1bbd3de
commit 3f79fa3919
13 changed files with 76 additions and 39 deletions

View File

@ -33,7 +33,7 @@ class TestImageParser(unittest.TestCase):
basedir = "tests/image-xml/" basedir = "tests/image-xml/"
conn = libvirt.open("test:///default") conn = libvirt.open("test:///default")
qemuconn = virtinst.cli._open_test_uri(qemuuri) qemuconn = virtinst.cli.open_test_uri(qemuuri)
caps = virtinst.CapabilitiesParser.parse(conn.getCapabilities()) caps = virtinst.CapabilitiesParser.parse(conn.getCapabilities())
qemucaps = virtinst.CapabilitiesParser.parse(qemuconn.getCapabilities()) qemucaps = virtinst.CapabilitiesParser.parse(qemuconn.getCapabilities())

View File

@ -4,7 +4,6 @@
virtinst merge bits: virtinst merge bits:
make sure translations actually work when installed make sure translations actually work when installed
merge pylint scripts, make sure there are no warnings
break out osdistro bits so we don't need to carry virt-install.pod break out osdistro bits so we don't need to carry virt-install.pod
merge README, reference that we merged virtinst and see that repo for merge README, reference that we merged virtinst and see that repo for
old NEWS, etc. old NEWS, etc.
@ -61,7 +60,6 @@ start a spice guest, shrink the window to smaller than guest resolution, scrollb
==================== ====================
enable all pep8 bits enable all pep8 bits
pylint: drop shell script, stick it in setup.py
drop old stuff from both spec files drop old stuff from both spec files
update README update README
virtinst initrd test: drop the big files? just stub em out virtinst initrd test: drop the big files? just stub em out

View File

@ -32,6 +32,7 @@ import traceback
import libvirt import libvirt
import virtinst import virtinst
import virtinst.cli
from virtinst import uriutil from virtinst import uriutil
from virtManager import util from virtManager import util
@ -45,13 +46,6 @@ from virtManager.network import vmmNetwork
from virtManager.nodedev import vmmNodeDevice from virtManager.nodedev import vmmNodeDevice
from virtManager.storagepool import vmmStoragePool from virtManager.storagepool import vmmStoragePool
def _is_virtinst_test_uri(uri):
try:
from virtinst import cli
return bool(cli._is_virtinst_test_uri(uri))
except:
return False
class vmmConnection(vmmGObject): class vmmConnection(vmmGObject):
__gsignals__ = { __gsignals__ = {
@ -99,7 +93,8 @@ class vmmConnection(vmmGObject):
self._caps = None self._caps = None
self._caps_xml = None self._caps_xml = None
self._is_virtinst_test_uri = _is_virtinst_test_uri(self._uri) self._is_virtinst_test_uri = virtinst.cli.is_virtinst_test_uri(
self._uri)
self.network_capable = None self.network_capable = None
self._storage_capable = None self._storage_capable = None
@ -967,13 +962,7 @@ class vmmConnection(vmmGObject):
""" """
if not self._is_virtinst_test_uri: if not self._is_virtinst_test_uri:
return return
return virtinst.cli.open_test_uri(uri)
try:
from virtinst import cli
return cli._open_test_uri(uri)
except:
logging.exception("Trouble opening test URI")
return
def open(self, sync=False): def open(self, sync=False):
if self.state != self.STATE_DISCONNECTED: if self.state != self.STATE_DISCONNECTED:

View File

@ -23,8 +23,8 @@ import virtconv.formats as formats
import virtconv.vmcfg as vmcfg import virtconv.vmcfg as vmcfg
import virtconv.diskcfg as diskcfg import virtconv.diskcfg as diskcfg
import virtconv.netdevcfg as netdevcfg import virtconv.netdevcfg as netdevcfg
import virtinst.Guest as Guest from virtinst import Guest
import virtinst.ImageParser as ImageParser from virtinst import ImageParser
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
import re import re
@ -86,7 +86,7 @@ def export_os_params(vm):
# TODO: Shouldn't be directly using _OS_TYPES here. virt-image libs ( # TODO: Shouldn't be directly using _OS_TYPES here. virt-image libs (
# ImageParser?) should handle this info # ImageParser?) should handle this info
ostype = Guest._OS_TYPES.get(vm.os_type) ostype = Guest._OS_TYPES.get(vm.os_type) # pylint: disable=W0212
if ostype: if ostype:
osvariant = ostype.get('variants').get(vm.os_variant) osvariant = ostype.get('variants').get(vm.os_variant)

View File

@ -157,6 +157,9 @@ class DistroInstaller(Installer.Installer):
def __init__(self, type="xen", location=None, def __init__(self, type="xen", location=None,
extraargs=None, os_type=None, extraargs=None, os_type=None,
conn=None, caps=None): conn=None, caps=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
Installer.Installer.__init__(self, type, location, extraargs, Installer.Installer.__init__(self, type, location, extraargs,
os_type, conn=conn, caps=caps) os_type, conn=conn, caps=caps)
@ -367,8 +370,13 @@ class DistroInstaller(Installer.Installer):
not os.path.isdir(self.location)): not os.path.isdir(self.location)):
device = VirtualDisk.DEVICE_CDROM device = VirtualDisk.DEVICE_CDROM
if (self.is_xenpv() and
not guest._lookup_osdict_key('pv_cdrom_install')): # pylint: disable=W0212
# Access to protected member lookup_osdict_key
can_cdrom = guest._lookup_osdict_key('pv_cdrom_install')
# pylint: enable=W0212
if self.is_xenpv() and can_cdrom:
device = VirtualDisk.DEVICE_DISK device = VirtualDisk.DEVICE_DISK
disk = VirtualDisk(conn=guest.conn, disk = VirtualDisk(conn=guest.conn,

View File

@ -69,6 +69,9 @@ class DomainFeatures(XMLBuilderDomain.XMLBuilderDomain):
def _get_xml_config(self, defaults=None): def _get_xml_config(self, defaults=None):
# pylint: disable=W0221
# Argument number differs from overridden method
if not defaults: if not defaults:
defaults = {} defaults = {}
ret = "" ret = ""

View File

@ -172,6 +172,8 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
def __init__(self, type=None, connection=None, hypervisorURI=None, def __init__(self, type=None, connection=None, hypervisorURI=None,
installer=None, parsexml=None, caps=None, conn=None): installer=None, parsexml=None, caps=None, conn=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
# Set up the connection, since it is fundamental for other init # Set up the connection, since it is fundamental for other init
conn = conn or connection conn = conn or connection
@ -219,7 +221,11 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
self._default_input_device = None self._default_input_device = None
self._default_console_device = None self._default_console_device = None
# pylint: disable=W0212
# Access to protected member _get_caps
caps = caps or (self._installer and self._installer._get_caps()) caps = caps or (self._installer and self._installer._get_caps())
# pylint: enable=W0212
XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml, XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
caps=caps) caps=caps)
if self._is_parse(): if self._is_parse():
@ -581,13 +587,13 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
# If user adds a device conflicting with a default assigned device # If user adds a device conflicting with a default assigned device
# remove the default # remove the default
if (dev.virtual_device_type == VirtualDevice.VIRTUAL_DEV_INPUT and if (devtype == VirtualDevice.VIRTUAL_DEV_INPUT and
self._default_input_device): self._default_input_device):
if self._default_input_device in self.get_all_devices(): if self._default_input_device in self.get_all_devices():
self.remove_device(self._default_input_device) self.remove_device(self._default_input_device)
self._default_input_device = None self._default_input_device = None
if (dev.virtual_device_type in [VirtualDevice.VIRTUAL_DEV_CONSOLE, if (devtype in [VirtualDevice.VIRTUAL_DEV_CONSOLE,
VirtualDevice.VIRTUAL_DEV_SERIAL] and VirtualDevice.VIRTUAL_DEV_SERIAL] and
self._default_console_device): self._default_console_device):
if self._default_console_device in self.get_all_devices(): if self._default_console_device in self.get_all_devices():
@ -899,6 +905,9 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
this.) this.)
@type disk_boot: C{bool} @type disk_boot: C{bool}
""" """
# pylint: disable=W0221
# Argument number differs from overridden method
# We do a shallow copy of the device list here, and set the defaults. # We do a shallow copy of the device list here, and set the defaults.
# This way, default changes aren't persistent, and we don't need # This way, default changes aren't persistent, and we don't need
# to worry about when to call set_defaults # to worry about when to call set_defaults

View File

@ -83,6 +83,9 @@ class Installer(XMLBuilderDomain.XMLBuilderDomain):
def __init__(self, type="xen", location=None, def __init__(self, type="xen", location=None,
extraargs=None, os_type=None, conn=None, extraargs=None, os_type=None, conn=None,
parsexml=None, parsexmlnode=None, caps=None): parsexml=None, parsexmlnode=None, caps=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml, XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
parsexmlnode, caps=caps) parsexmlnode, caps=caps)
@ -356,6 +359,9 @@ class Installer(XMLBuilderDomain.XMLBuilderDomain):
'post-install' phase. 'post-install' phase.
@type isinstall: C{bool} @type isinstall: C{bool}
""" """
# pylint: disable=W0221
# Argument number differs from overridden method
if isinstall: if isinstall:
bootconfig = self._install_bootconfig bootconfig = self._install_bootconfig
else: else:
@ -485,6 +491,7 @@ class Installer(XMLBuilderDomain.XMLBuilderDomain):
return gobj return gobj
class ContainerInstaller(Installer): class ContainerInstaller(Installer):
def prepare(self, guest, meter): def prepare(self, guest, meter):
ignore = guest ignore = guest
@ -497,6 +504,3 @@ class ContainerInstaller(Installer):
def has_install_phase(self): def has_install_phase(self):
return False return False
# Back compat
Installer.get_install_xml = Installer.get_xml_config

View File

@ -349,7 +349,10 @@ class StoragePool(StorageObject):
pool_list_from_sources = staticmethod(pool_list_from_sources) pool_list_from_sources = staticmethod(pool_list_from_sources)
def __init__(self, conn, name, type, target_path=None, uuid=None): def __init__(self, conn, name, type, target_path=None, uuid=None):
StorageObject.__init__(self, object_type=StorageObject.TYPE_POOL, \ # pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
StorageObject.__init__(self, object_type=StorageObject.TYPE_POOL,
name=name, conn=conn) name=name, conn=conn)
if type not in self.get_pool_types(): if type not in self.get_pool_types():
@ -545,6 +548,9 @@ class FilesystemPool(StoragePool):
def __init__(self, conn, name, source_path=None, target_path=None, def __init__(self, conn, name, source_path=None, target_path=None,
format="auto", uuid=None, perms=None): format="auto", uuid=None, perms=None):
# pylint: disable=W0622
# Redefining built-in 'format', but it matches the XML so keep it
StoragePool.__init__(self, name=name, type=StoragePool.TYPE_FS, StoragePool.__init__(self, name=name, type=StoragePool.TYPE_FS,
target_path=target_path, uuid=uuid, conn=conn) target_path=target_path, uuid=uuid, conn=conn)
@ -603,6 +609,9 @@ class NetworkFilesystemPool(StoragePool):
def __init__(self, conn, name, source_path=None, host=None, def __init__(self, conn, name, source_path=None, host=None,
target_path=None, format="auto", uuid=None): target_path=None, format="auto", uuid=None):
# pylint: disable=W0622
# Redefining built-in 'format', but it matches the XML so keep it
StoragePool.__init__(self, name=name, type=StoragePool.TYPE_NETFS, StoragePool.__init__(self, name=name, type=StoragePool.TYPE_NETFS,
uuid=uuid, target_path=target_path, conn=conn) uuid=uuid, target_path=target_path, conn=conn)
@ -762,6 +771,9 @@ class DiskPool(StoragePool):
def __init__(self, conn, name, source_path=None, target_path=None, def __init__(self, conn, name, source_path=None, target_path=None,
format="auto", uuid=None): format="auto", uuid=None):
# pylint: disable=W0622
# Redefining built-in 'format', but it matches the XML so keep it
StoragePool.__init__(self, name=name, type=StoragePool.TYPE_DISK, StoragePool.__init__(self, name=name, type=StoragePool.TYPE_DISK,
uuid=uuid, target_path=target_path, conn=conn) uuid=uuid, target_path=target_path, conn=conn)
self.format = format self.format = format
@ -979,11 +991,11 @@ class StorageVolume(StorageObject):
pool = StorageVolume.lookup_pool_by_name(pool_name=pool_name, pool = StorageVolume.lookup_pool_by_name(pool_name=pool_name,
conn=conn) conn=conn)
self._pool = None self._pool = None
self.pool = pool self.pool = pool
poolconn = self.pool._conn # pylint: disable=W0212
StorageObject.__init__(self, object_type=StorageObject.TYPE_VOLUME, StorageObject.__init__(self, object_type=StorageObject.TYPE_VOLUME,
name=name, conn=self.pool._conn) name=name, conn=poolconn)
self._allocation = None self._allocation = None
self._capacity = None self._capacity = None
self._format = None self._format = None
@ -1130,7 +1142,9 @@ class StorageVolume(StorageObject):
if not isinstance(vol, libvirt.virStorageVol): if not isinstance(vol, libvirt.virStorageVol):
raise ValueError(_("input_vol must be a virStorageVol")) raise ValueError(_("input_vol must be a virStorageVol"))
if not is_create_vol_from_supported(self.pool._conn):
poolconn = self.pool._conn # pylint: disable=W0212
if not is_create_vol_from_supported(poolconn):
raise ValueError(_("Creating storage from an existing volume is" raise ValueError(_("Creating storage from an existing volume is"
" not supported by this libvirt version.")) " not supported by this libvirt version."))
self._input_vol = vol self._input_vol = vol
@ -1302,6 +1316,9 @@ class FileVolume(StorageVolume):
def __init__(self, name, capacity, pool=None, pool_name=None, conn=None, def __init__(self, name, capacity, pool=None, pool_name=None, conn=None,
format="raw", allocation=None, perms=None): format="raw", allocation=None, perms=None):
# pylint: disable=W0622
# Redefining built-in 'format', but it matches the XML so keep it
StorageVolume.__init__(self, name=name, pool=pool, pool_name=pool_name, StorageVolume.__init__(self, name=name, pool=pool, pool_name=pool_name,
allocation=allocation, capacity=capacity, allocation=allocation, capacity=capacity,
conn=conn) conn=conn)

View File

@ -282,6 +282,8 @@ class VirtualDisk(VirtualDevice):
__init__ and setting all properties performs lots of validation, __init__ and setting all properties performs lots of validation,
and will throw ValueError's if problems are found. and will throw ValueError's if problems are found.
""" """
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
_virtual_device_type = VirtualDevice.VIRTUAL_DEV_DISK _virtual_device_type = VirtualDevice.VIRTUAL_DEV_DISK
@ -1471,6 +1473,9 @@ class VirtualDisk(VirtualDevice):
takes precedence. takes precedence.
@type disknode: C{str} @type disknode: C{str}
""" """
# pylint: disable=W0221
# Argument number differs from overridden method
typeattr = self.type typeattr = self.type
if self.type == VirtualDisk.TYPE_BLOCK: if self.type == VirtualDisk.TYPE_BLOCK:
typeattr = 'dev' typeattr = 'dev'

View File

@ -94,9 +94,10 @@ class VirtualGraphics(VirtualDevice):
keymap=KEYMAP_DEFAULT, conn=None, parsexml=None, keymap=KEYMAP_DEFAULT, conn=None, parsexml=None,
parsexmlnode=None, tlsPort=-1, channels=None, parsexmlnode=None, tlsPort=-1, channels=None,
caps=None, passwdValidTo=None): caps=None, passwdValidTo=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
VirtualDevice.__init__(self, conn, VirtualDevice.__init__(self, conn, parsexml, parsexmlnode, caps)
parsexml, parsexmlnode, caps)
self._type = None self._type = None
self._port = None self._port = None

View File

@ -145,6 +145,9 @@ class VirtualNetworkInterface(VirtualDevice):
def __init__(self, macaddr=None, type=TYPE_BRIDGE, bridge=None, def __init__(self, macaddr=None, type=TYPE_BRIDGE, bridge=None,
network=None, model=None, conn=None, network=None, model=None, conn=None,
parsexml=None, parsexmlnode=None, caps=None): parsexml=None, parsexmlnode=None, caps=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
VirtualDevice.__init__(self, conn, parsexml, parsexmlnode, caps) VirtualDevice.__init__(self, conn, parsexml, parsexmlnode, caps)
self._network = None self._network = None

View File

@ -223,10 +223,10 @@ def setupLogging(appname, debug=False, do_quiet=False):
_virtinst_uri_magic = "__virtinst_test__" _virtinst_uri_magic = "__virtinst_test__"
def _is_virtinst_test_uri(uri): def is_virtinst_test_uri(uri):
return uri and uri.startswith(_virtinst_uri_magic) return uri and uri.startswith(_virtinst_uri_magic)
def _open_test_uri(uri): def open_test_uri(uri):
""" """
This hack allows us to fake various drivers via passing a magic This hack allows us to fake various drivers via passing a magic
URI string to virt-*. Helps with testing URI string to virt-*. Helps with testing
@ -318,8 +318,8 @@ def getConnection(uri):
fail(_("Must be root to create Xen guests")) fail(_("Must be root to create Xen guests"))
# Hack to facilitate virtinst unit testing # Hack to facilitate virtinst unit testing
if _is_virtinst_test_uri(uri): if is_virtinst_test_uri(uri):
return _open_test_uri(uri) return open_test_uri(uri)
logging.debug("Requesting libvirt URI %s", (uri or "default")) logging.debug("Requesting libvirt URI %s", (uri or "default"))
conn = open_connection(uri) conn = open_connection(uri)