diff --git a/virtcli/cliconfig.py b/virtcli/cliconfig.py index 7f1a7cb91..60d4f55b4 100644 --- a/virtcli/cliconfig.py +++ b/virtcli/cliconfig.py @@ -25,13 +25,16 @@ import ConfigParser import os -cfg = ConfigParser.ConfigParser() +_cfg = ConfigParser.ConfigParser() _filepath = os.path.abspath(__file__) _srcdir = os.path.abspath(os.path.join(os.path.dirname(_filepath), "..")) -cfgpath = os.path.join(os.path.dirname(_filepath), "cli.cfg") +_cfgpath = os.path.join(os.path.dirname(_filepath), "cli.cfg") +if os.path.exists(_cfgpath): + _cfg.read(_cfgpath) + _istest = "VIRTINST_TEST_SUITE" in os.environ -if os.path.exists(cfgpath): - cfg.read(cfgpath) +_running_from_srcdir = os.path.exists( + os.path.join(_srcdir, "tests", "clitest.py")) def _split_list(commastr): @@ -42,7 +45,7 @@ def _get_param(name, default): if _istest: return default try: - return cfg.get("config", name) + return _cfg.get("config", name) except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default @@ -66,19 +69,21 @@ def _setup_gsettings_path(schemadir): raise RuntimeError("Failed to compile local gsettings schemas") -__version__ = "1.1.0" +############## +# Public API # +############## +__version__ = "1.1.0" __snapshot__ = 0 _usr_version = _get_param("pkgversion", "") if _usr_version is not None and _usr_version != "": __version__ = _usr_version -# We should map this into the config somehow but I question if anyone cares prefix = _get_param("prefix", "/usr") gettext_dir = os.path.join(prefix, "share", "locale") install_asset_dir = os.path.join(prefix, "share", "virt-manager") -if os.getcwd() == _srcdir: +if _running_from_srcdir: asset_dir = _srcdir icon_dir = os.path.join(_srcdir, "data") _setup_gsettings_path(icon_dir)