summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2013-03-17 18:18:22 -0400
committerCole Robinson <crobinso@redhat.com>2013-04-03 18:22:05 -0400
commitd6c8ad02973c30ace415b89b430885c939045cc2 (patch)
treed587b2e488d87dcb99f5451f6145018c7c015b05
parent88603e4fada1b360021b45ed2eaed263fde3f776 (diff)
downloadvirt-manager-d6c8ad02973c30ace415b89b430885c939045cc2.tar.gz
Wire up python unit tests, unify gettext setup
-rw-r--r--setup.py129
-rw-r--r--tests/__init__.py3
-rwxr-xr-xvirt-clone8
-rwxr-xr-xvirt-convert1
-rwxr-xr-xvirt-image1
-rwxr-xr-xvirt-install1
-rw-r--r--virtconv/__init__.py14
-rw-r--r--virtconv/diskcfg.py1
-rw-r--r--virtconv/formats.py3
-rw-r--r--virtconv/parsers/ovf.py1
-rw-r--r--virtconv/parsers/virtimage.py1
-rw-r--r--virtconv/parsers/vmx.py1
-rw-r--r--virtconv/vmcfg.py1
-rw-r--r--virtinst/CapabilitiesParser.py1
-rw-r--r--virtinst/CloneManager.py1
-rw-r--r--virtinst/DistroInstaller.py1
-rw-r--r--virtinst/DomainNumatune.py1
-rw-r--r--virtinst/Guest.py1
-rw-r--r--virtinst/ImageFetcher.py2
-rw-r--r--virtinst/ImageInstaller.py2
-rw-r--r--virtinst/ImageParser.py1
-rw-r--r--virtinst/Installer.py1
-rw-r--r--virtinst/Interface.py2
-rw-r--r--virtinst/LiveCDInstaller.py2
-rw-r--r--virtinst/NodeDeviceParser.py1
-rw-r--r--virtinst/OSDistro.py1
-rw-r--r--virtinst/Storage.py1
-rw-r--r--virtinst/VirtualAudio.py1
-rw-r--r--virtinst/VirtualCharDevice.py1
-rw-r--r--virtinst/VirtualController.py1
-rw-r--r--virtinst/VirtualDevice.py1
-rw-r--r--virtinst/VirtualDisk.py1
-rw-r--r--virtinst/VirtualFilesystem.py1
-rw-r--r--virtinst/VirtualGraphics.py1
-rw-r--r--virtinst/VirtualHostDevice.py1
-rw-r--r--virtinst/VirtualInputDevice.py1
-rw-r--r--virtinst/VirtualMemballoon.py1
-rw-r--r--virtinst/VirtualNetworkInterface.py1
-rw-r--r--virtinst/VirtualRedirDevice.py1
-rw-r--r--virtinst/VirtualSmartCardDevice.py1
-rw-r--r--virtinst/VirtualWatchdog.py1
-rw-r--r--virtinst/XMLBuilderDomain.py1
-rw-r--r--virtinst/__init__.py17
-rw-r--r--virtinst/_util.py1
-rw-r--r--virtinst/cli.py17
-rw-r--r--virtinst/osdict.py1
-rw-r--r--virtinst/support.py1
-rw-r--r--virtinst/util.py1
48 files changed, 146 insertions, 90 deletions
diff --git a/setup.py b/setup.py
index e4205242..d634bab0 100644
--- a/setup.py
+++ b/setup.py
@@ -2,6 +2,8 @@
import glob
import os
+import sys
+import unittest
from distutils.core import Command, setup
from distutils.command.install_egg_info import install_egg_info
@@ -170,6 +172,130 @@ if not cliconfig.with_tui:
tui_files = []
+class TestBaseCommand(Command):
+ user_options = [('debug', 'd', 'Show debug output')]
+ boolean_options = ['debug']
+
+ def initialize_options(self):
+ self.debug = 0
+ self._testfiles = []
+ self._dir = os.getcwd()
+
+ def finalize_options(self):
+ if self.debug and "DEBUG_TESTS" not in os.environ:
+ os.environ["DEBUG_TESTS"] = "1"
+
+ def run(self):
+ try:
+ # Use system 'coverage' if available
+ import coverage
+ use_coverage = True
+ except:
+ use_coverage = False
+
+ tests = unittest.TestLoader().loadTestsFromNames(self._testfiles)
+ t = unittest.TextTestRunner(verbosity=1)
+
+ if use_coverage:
+ coverage.erase()
+ coverage.start()
+
+ if hasattr(unittest, "installHandler"):
+ try:
+ unittest.installHandler()
+ except:
+ print "installHandler hack failed"
+
+ try:
+ result = t.run(tests)
+ except KeyboardInterrupt:
+ sys.exit(1)
+
+ if use_coverage:
+ coverage.stop()
+
+ sys.exit(int(bool(len(result.failures) > 0 or
+ len(result.errors) > 0)))
+
+
+class TestCommand(TestBaseCommand):
+ description = "Runs a quick unit test suite"
+ user_options = TestBaseCommand.user_options + \
+ [("testfile=", None, "Specific test file to run (e.g "
+ "validation, storage, ...)"),
+ ("skipcli", None, "Skip CLI tests")]
+
+ def initialize_options(self):
+ TestBaseCommand.initialize_options(self)
+ self.testfile = None
+ self.skipcli = None
+
+ def finalize_options(self):
+ TestBaseCommand.finalize_options(self)
+
+ def run(self):
+ '''
+ Finds all the tests modules in tests/, and runs them.
+ '''
+ testfiles = []
+ for t in glob.glob(os.path.join(self._dir, 'tests', '*.py')):
+ if (t.endswith("__init__.py") or
+ t.endswith("urltest.py")):
+ continue
+
+ base = os.path.basename(t)
+ if self.testfile:
+ check = os.path.basename(self.testfile)
+ if base != check and base != (check + ".py"):
+ continue
+ if self.skipcli and base.count("clitest"):
+ continue
+
+ testfiles.append('.'.join(['tests', os.path.splitext(base)[0]]))
+
+ if not testfiles:
+ raise RuntimeError("--testfile didn't catch anything")
+
+ self._testfiles = testfiles
+ TestBaseCommand.run(self)
+
+
+class TestURLFetch(TestBaseCommand):
+ description = "Test fetching kernels and isos from various distro trees"
+
+ user_options = TestBaseCommand.user_options + \
+ [("match=", None, "Regular expression of dist names to "
+ "match [default: '.*']"),
+ ("path=", None, "Paths to local iso or directory or check"
+ " for installable distro. Comma separated")]
+
+ def initialize_options(self):
+ TestBaseCommand.initialize_options(self)
+ self.match = None
+ self.path = ""
+
+ def finalize_options(self):
+ TestBaseCommand.finalize_options(self)
+ if self.match is None:
+ self.match = ".*"
+
+ origpath = str(self.path)
+ if not origpath:
+ self.path = []
+ else:
+ self.path = origpath.split(",")
+
+ def run(self):
+ import tests
+ self._testfiles = ["tests.urltest"]
+ tests.urltest.MATCH_FILTER = self.match
+ if self.path:
+ for p in self.path:
+ tests.urltest.LOCAL_MEDIA.append(p)
+ TestBaseCommand.run(self)
+
+
+
setup(
name = "virt-manager",
version = cliconfig.__version__,
@@ -195,11 +321,12 @@ setup(
'build_i18n': my_build_i18n,
'build_icons': my_build_icons,
'sdist': sdist_auto,
-
'install_egg_info': my_egg_info,
'configure': configure,
'rpm': my_rpm,
+ 'test': TestCommand,
+ 'test_urls' : TestURLFetch,
}
)
diff --git a/tests/__init__.py b/tests/__init__.py
index d358935c..fc86b9db 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -16,9 +16,10 @@
import logging
import os
+
import virtinst
+from tests import utils
-import utils
# Force certain helpers to return consistent values
virtinst._util.is_blktap_capable = lambda: False
diff --git a/virt-clone b/virt-clone
index c9868f38..3f7eb669 100755
--- a/virt-clone
+++ b/virt-clone
@@ -20,18 +20,18 @@
# MA 02110-1301 USA.
+import optparse
+from optparse import OptionGroup
import sys
import logging
-import virtinst.CloneManager as clmgr
+
import urlgrabber.progress as progress
-import optparse
-from optparse import OptionGroup
+import virtinst.CloneManager as clmgr
import virtinst.cli as cli
from virtinst.cli import fail, print_stdout, print_stderr
from virtinst.User import User
-cli.setupGettext()
### General input gathering functions
def get_clone_name(new_name, auto_clone, design):
diff --git a/virt-convert b/virt-convert
index a19c3354..0e26a71e 100755
--- a/virt-convert
+++ b/virt-convert
@@ -34,7 +34,6 @@ import virtconv.formats as formats
import virtconv.vmcfg as vmcfg
import virtconv.diskcfg as diskcfg
-cli.setupGettext()
def parse_args():
"""Parse and verify command line."""
diff --git a/virt-image b/virt-image
index 78b32b1d..e0531850 100755
--- a/virt-image
+++ b/virt-image
@@ -32,7 +32,6 @@ from virtinst.cli import fail, print_stdout, print_stderr
import optparse
from optparse import OptionGroup
-cli.setupGettext()
### General input gathering functions
diff --git a/virt-install b/virt-install
index ac3875b3..de063299 100755
--- a/virt-install
+++ b/virt-install
@@ -38,7 +38,6 @@ import virtinst._util as _util
from virtinst.VirtualDevice import VirtualDevice
from virtinst.cli import fail, print_stdout, print_stderr
-cli.setupGettext()
##############################
diff --git a/virtconv/__init__.py b/virtconv/__init__.py
index 1af5780f..9fdf2c85 100644
--- a/virtconv/__init__.py
+++ b/virtconv/__init__.py
@@ -21,20 +21,6 @@
import pkgutil
import imp
import os
-import sys
-import gettext
-
-gettext.bindtextdomain("virtinst")
-_gettext = lambda m: gettext.dgettext("virtinst", m)
-
-try:
- import _config
-except ImportError:
- print "virtconv: Please run 'python setup.py build' in the source"
- print " directory before using the code."
- sys.exit(1)
-__version__ = _config.__version__
-__version_info__ = _config.__version_info__
parsers_path = [os.path.join(__path__[0], "parsers/")]
diff --git a/virtconv/diskcfg.py b/virtconv/diskcfg.py
index 3fbed4f4..e52e3234 100644
--- a/virtconv/diskcfg.py
+++ b/virtconv/diskcfg.py
@@ -27,7 +27,6 @@ import os
import re
import logging
-from virtconv import _gettext as _
DISK_FORMAT_NONE = 0
DISK_FORMAT_RAW = 1
diff --git a/virtconv/formats.py b/virtconv/formats.py
index ca9ab677..059696c6 100644
--- a/virtconv/formats.py
+++ b/virtconv/formats.py
@@ -20,10 +20,9 @@
import os
-from virtconv import _gettext as _
-
_parsers = [ ]
+
class parser(object):
"""
Base class for particular config file format definitions of
diff --git a/virtconv/parsers/ovf.py b/virtconv/parsers/ovf.py
index 65780f29..86ea9ca1 100644
--- a/virtconv/parsers/ovf.py
+++ b/virtconv/parsers/ovf.py
@@ -20,7 +20,6 @@
import libxml2
-from virtconv import _gettext as _
import virtconv.formats as formats
import virtconv.vmcfg as vmcfg
import virtconv.diskcfg as diskcfg
diff --git a/virtconv/parsers/virtimage.py b/virtconv/parsers/virtimage.py
index 15a9cd68..e594e886 100644
--- a/virtconv/parsers/virtimage.py
+++ b/virtconv/parsers/virtimage.py
@@ -19,7 +19,6 @@
# MA 02110-1301 USA.
#
-from virtconv import _gettext as _
import virtconv.formats as formats
import virtconv.vmcfg as vmcfg
import virtconv.diskcfg as diskcfg
diff --git a/virtconv/parsers/vmx.py b/virtconv/parsers/vmx.py
index 89b0a0c1..a3f93bc3 100644
--- a/virtconv/parsers/vmx.py
+++ b/virtconv/parsers/vmx.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
#
-from virtconv import _gettext as _
import virtconv.formats as formats
import virtconv.vmcfg as vmcfg
import virtconv.diskcfg as diskcfg
diff --git a/virtconv/vmcfg.py b/virtconv/vmcfg.py
index 5e967294..db58d3ac 100644
--- a/virtconv/vmcfg.py
+++ b/virtconv/vmcfg.py
@@ -19,7 +19,6 @@
#
import platform
-from virtconv import _gettext as _
from virtconv import diskcfg
from virtinst import CapabilitiesParser
diff --git a/virtinst/CapabilitiesParser.py b/virtinst/CapabilitiesParser.py
index 6585a154..2f0a287b 100644
--- a/virtinst/CapabilitiesParser.py
+++ b/virtinst/CapabilitiesParser.py
@@ -21,7 +21,6 @@
import re
-from virtinst import _gettext as _
import _util
class CapabilitiesParserException(Exception):
diff --git a/virtinst/CloneManager.py b/virtinst/CloneManager.py
index 04692b64..d3028de0 100644
--- a/virtinst/CloneManager.py
+++ b/virtinst/CloneManager.py
@@ -44,7 +44,6 @@ import Guest
from VirtualNetworkInterface import VirtualNetworkInterface
from VirtualDisk import VirtualDisk
from virtinst import Storage
-from virtinst import _gettext as _
import _util
def _listify(val):
diff --git a/virtinst/DistroInstaller.py b/virtinst/DistroInstaller.py
index a1658279..b8baea53 100644
--- a/virtinst/DistroInstaller.py
+++ b/virtinst/DistroInstaller.py
@@ -33,7 +33,6 @@ from VirtualDisk import VirtualDisk
from User import User
import OSDistro
-from virtinst import _gettext as _
def _is_url(url, is_local):
"""
diff --git a/virtinst/DomainNumatune.py b/virtinst/DomainNumatune.py
index e838dfe0..cbb85a9d 100644
--- a/virtinst/DomainNumatune.py
+++ b/virtinst/DomainNumatune.py
@@ -22,7 +22,6 @@ import re
import _util
import XMLBuilderDomain
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
class DomainNumatune(XMLBuilderDomain.XMLBuilderDomain):
"""
diff --git a/virtinst/Guest.py b/virtinst/Guest.py
index 54a21ea0..f0886f2d 100644
--- a/virtinst/Guest.py
+++ b/virtinst/Guest.py
@@ -48,7 +48,6 @@ from DomainNumatune import DomainNumatune
from DomainFeatures import DomainFeatures
import osdict
-from virtinst import _gettext as _
class Guest(XMLBuilderDomain.XMLBuilderDomain):
diff --git a/virtinst/ImageFetcher.py b/virtinst/ImageFetcher.py
index d4d3e483..d4756f57 100644
--- a/virtinst/ImageFetcher.py
+++ b/virtinst/ImageFetcher.py
@@ -28,7 +28,7 @@ import urllib2
import urlparse
import ftplib
import tempfile
-from virtinst import _gettext as _
+
# This is a generic base class for fetching/extracting files from
# a media source, such as CD ISO, NFS server, or HTTP/FTP server
diff --git a/virtinst/ImageInstaller.py b/virtinst/ImageInstaller.py
index d8f2494c..6793e55e 100644
--- a/virtinst/ImageInstaller.py
+++ b/virtinst/ImageInstaller.py
@@ -24,7 +24,7 @@ import Installer
import ImageParser
import CapabilitiesParser as Cap
from VirtualDisk import VirtualDisk
-from virtinst import _gettext as _
+
class ImageInstallerException(Exception):
def __init__(self, msg):
diff --git a/virtinst/ImageParser.py b/virtinst/ImageParser.py
index ea074cf5..c9659d6d 100644
--- a/virtinst/ImageParser.py
+++ b/virtinst/ImageParser.py
@@ -26,7 +26,6 @@ import libxml2
import urlgrabber
import CapabilitiesParser
-from virtinst import _gettext as _
import _util
diff --git a/virtinst/Installer.py b/virtinst/Installer.py
index 796cc860..5ad0d371 100644
--- a/virtinst/Installer.py
+++ b/virtinst/Installer.py
@@ -31,7 +31,6 @@ import virtinst
import XMLBuilderDomain
from XMLBuilderDomain import _xml_property
from virtinst import CapabilitiesParser
-from virtinst import _gettext as _
from VirtualDisk import VirtualDisk
from Boot import Boot
diff --git a/virtinst/Interface.py b/virtinst/Interface.py
index 9ab18a47..54a828fb 100644
--- a/virtinst/Interface.py
+++ b/virtinst/Interface.py
@@ -26,7 +26,7 @@ import logging
import _util
import support
-from virtinst import _gettext as _
+
class Interface(object):
"""
diff --git a/virtinst/LiveCDInstaller.py b/virtinst/LiveCDInstaller.py
index b26ff52e..11d8486a 100644
--- a/virtinst/LiveCDInstaller.py
+++ b/virtinst/LiveCDInstaller.py
@@ -21,7 +21,7 @@
import Installer
from VirtualDisk import VirtualDisk
-from virtinst import _gettext as _
+
class LiveCDInstallerException(Exception):
def __init__(self, msg):
diff --git a/virtinst/NodeDeviceParser.py b/virtinst/NodeDeviceParser.py
index 1b6ffa4e..191f0a8b 100644
--- a/virtinst/NodeDeviceParser.py
+++ b/virtinst/NodeDeviceParser.py
@@ -17,7 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
-from virtinst import _gettext as _
import support
import _util
import libvirt
diff --git a/virtinst/OSDistro.py b/virtinst/OSDistro.py
index f900f661..89ef33f4 100644
--- a/virtinst/OSDistro.py
+++ b/virtinst/OSDistro.py
@@ -30,7 +30,6 @@ import ConfigParser
import virtinst
import osdict
from virtinst import _util
-from virtinst import _gettext as _
from ImageFetcher import MountedImageFetcher
from ImageFetcher import FTPImageFetcher
diff --git a/virtinst/Storage.py b/virtinst/Storage.py
index fd40009c..4d31266d 100644
--- a/virtinst/Storage.py
+++ b/virtinst/Storage.py
@@ -56,7 +56,6 @@ import urlgrabber
from _util import xml_escape as escape
import _util
import support
-from virtinst import _gettext as _
DEFAULT_DEV_TARGET = "/dev"
diff --git a/virtinst/VirtualAudio.py b/virtinst/VirtualAudio.py
index 66f7a492..899a06e0 100644
--- a/virtinst/VirtualAudio.py
+++ b/virtinst/VirtualAudio.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualAudio(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualCharDevice.py b/virtinst/VirtualCharDevice.py
index a17ffc64..b1c658ec 100644
--- a/virtinst/VirtualCharDevice.py
+++ b/virtinst/VirtualCharDevice.py
@@ -21,7 +21,6 @@ import VirtualDevice
from _util import xml_escape
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
class VirtualCharDevice(VirtualDevice.VirtualDevice):
"""
diff --git a/virtinst/VirtualController.py b/virtinst/VirtualController.py
index d9297ae8..e3385ea1 100644
--- a/virtinst/VirtualController.py
+++ b/virtinst/VirtualController.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
import VirtualDevice
-#from virtinst import _gettext as _
from XMLBuilderDomain import XMLBuilderDomain, _xml_property
import logging
diff --git a/virtinst/VirtualDevice.py b/virtinst/VirtualDevice.py
index ce987fe3..1697968d 100644
--- a/virtinst/VirtualDevice.py
+++ b/virtinst/VirtualDevice.py
@@ -20,7 +20,6 @@
# MA 02110-1301 USA.
from XMLBuilderDomain import XMLBuilderDomain, _xml_property
-from virtinst import _gettext as _
import logging
class VirtualDevice(XMLBuilderDomain):
diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
index 3f9bcba1..68cb04ce 100644
--- a/virtinst/VirtualDisk.py
+++ b/virtinst/VirtualDisk.py
@@ -35,7 +35,6 @@ import _util
import Storage
from VirtualDevice import VirtualDevice
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
def _vdisk_create(path, size, kind, sparse=True):
force_fixed = "raw"
diff --git a/virtinst/VirtualFilesystem.py b/virtinst/VirtualFilesystem.py
index 8499c36e..f689589c 100644
--- a/virtinst/VirtualFilesystem.py
+++ b/virtinst/VirtualFilesystem.py
@@ -20,7 +20,6 @@
import os
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualFilesystem(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualGraphics.py b/virtinst/VirtualGraphics.py
index c722e2ba..72ae6a0b 100644
--- a/virtinst/VirtualGraphics.py
+++ b/virtinst/VirtualGraphics.py
@@ -24,7 +24,6 @@ import _util
import VirtualDevice
import support
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
def _get_mode_prop(channel_type):
xpath = "./channel[@name='%s']/@mode" % channel_type
diff --git a/virtinst/VirtualHostDevice.py b/virtinst/VirtualHostDevice.py
index 752e92f9..78e74334 100644
--- a/virtinst/VirtualHostDevice.py
+++ b/virtinst/VirtualHostDevice.py
@@ -21,7 +21,6 @@ import VirtualDevice
import NodeDeviceParser
import logging
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualHostDevice(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualInputDevice.py b/virtinst/VirtualInputDevice.py
index 6e4083a9..77657cfa 100644
--- a/virtinst/VirtualInputDevice.py
+++ b/virtinst/VirtualInputDevice.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualInputDevice(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualMemballoon.py b/virtinst/VirtualMemballoon.py
index 2acf997f..8320d9b1 100644
--- a/virtinst/VirtualMemballoon.py
+++ b/virtinst/VirtualMemballoon.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualMemballoon(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualNetworkInterface.py b/virtinst/VirtualNetworkInterface.py
index 2415176d..598ba99e 100644
--- a/virtinst/VirtualNetworkInterface.py
+++ b/virtinst/VirtualNetworkInterface.py
@@ -24,7 +24,6 @@ import _util
import VirtualDevice
import XMLBuilderDomain
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
def _countMACaddr(vms, searchmac):
if not searchmac:
diff --git a/virtinst/VirtualRedirDevice.py b/virtinst/VirtualRedirDevice.py
index 43b58699..f01032b7 100644
--- a/virtinst/VirtualRedirDevice.py
+++ b/virtinst/VirtualRedirDevice.py
@@ -21,7 +21,6 @@
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualRedirDevice(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualSmartCardDevice.py b/virtinst/VirtualSmartCardDevice.py
index 89b43e4a..63754bee 100644
--- a/virtinst/VirtualSmartCardDevice.py
+++ b/virtinst/VirtualSmartCardDevice.py
@@ -21,7 +21,6 @@
import VirtualDevice
from XMLBuilderDomain import _xml_property
-from virtinst import _gettext as _
class VirtualSmartCardDevice(VirtualDevice.VirtualDevice):
diff --git a/virtinst/VirtualWatchdog.py b/virtinst/VirtualWatchdog.py
index f55c8b58..cb364197 100644
--- a/virtinst/VirtualWatchdog.py
+++ b/virtinst/VirtualWatchdog.py
@@ -18,7 +18,6 @@
# MA 02110-1301 USA.
import VirtualDevice
-from virtinst import _gettext as _
from XMLBuilderDomain import _xml_property
class VirtualWatchdog(VirtualDevice.VirtualDevice):
diff --git a/virtinst/XMLBuilderDomain.py b/virtinst/XMLBuilderDomain.py
index e2a2c94b..d7fc7f24 100644
--- a/virtinst/XMLBuilderDomain.py
+++ b/virtinst/XMLBuilderDomain.py
@@ -27,7 +27,6 @@ import libxml2
import CapabilitiesParser
import _util
-from virtinst import _gettext as _
_xml_refs_lock = threading.Lock()
_xml_refs = {}
diff --git a/virtinst/__init__.py b/virtinst/__init__.py
index a392b9af..5f742638 100644
--- a/virtinst/__init__.py
+++ b/virtinst/__init__.py
@@ -14,21 +14,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
-import gettext
-import sys
+from virtcli import cliconfig, cliutils
+enable_rhel6_defaults = not cliconfig.rhel_enable_unsupported_opts
+cliutils.setup_i18n()
-gettext.bindtextdomain("virtinst")
-_gettext = lambda m: gettext.dgettext("virtinst", m)
-
-try:
- import _config
-except ImportError:
- print "virtinst: Please run 'python setup.py build' in the source"
- print " directory before using the code."
- sys.exit(1)
-__version__ = _config.__version__
-__version_info__ = _config.__version_info__
-enable_rhel6_defaults = _config.rhel6defaults
# Public imports
diff --git a/virtinst/_util.py b/virtinst/_util.py
index c9f6eb97..688edacc 100644
--- a/virtinst/_util.py
+++ b/virtinst/_util.py
@@ -35,7 +35,6 @@ import libxml2
import libvirt
import virtinst.util as util
-from virtinst import _gettext as _
try:
import selinux
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 79d59d92..51ef0156 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -34,10 +34,11 @@ import itertools
import libvirt
+from virtcli import cliconfig
+
import virtinst
from virtinst import _util
from _util import listify
-from virtinst import _gettext as _
from virtinst import Guest
from virtinst import VirtualNetworkInterface
@@ -48,6 +49,7 @@ from virtinst import VirtualCharDevice
from virtinst import VirtualDevice
from virtinst import User
+
DEFAULT_POOL_PATH = "/var/lib/libvirt/images"
DEFAULT_POOL_NAME = "default"
@@ -141,20 +143,9 @@ def setupParser(usage=None):
parser = parse_class(usage=usage,
formatter=VirtHelpFormatter(),
- version=virtinst.__version__)
+ version=cliconfig.__version__)
return parser
-def setupGettext():
- try:
- locale.setlocale(locale.LC_ALL, '')
- except locale.Error, e:
- print >> sys.stderr, "warning: failed to set locale, defaulting to C"
- os.environ['LC_ALL'] = 'C'
- locale.setlocale(locale.LC_ALL, 'C')
-
- gettext.bindtextdomain("virtinst")
- gettext.install("virtinst")
-
def earlyLogging():
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 728afeb6..0c5b2f1f 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -21,7 +21,6 @@
import support
from VirtualDevice import VirtualDevice
-from virtinst import _gettext as _
HV_ALL = "all"
diff --git a/virtinst/support.py b/virtinst/support.py
index 5ec25485..5059e409 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -22,7 +22,6 @@
import libvirt
import _util
-from virtinst import _gettext as _
# Flags for check_conn_support
SUPPORT_CONN_STORAGE = 0
diff --git a/virtinst/util.py b/virtinst/util.py
index 38a04c88..b1db00fa 100644
--- a/virtinst/util.py
+++ b/virtinst/util.py
@@ -36,7 +36,6 @@ import logging
import subprocess
import libvirt
-from virtinst import _gettext as _
import virtinst
import CapabilitiesParser
import User