mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
cliconfig: Fix running from git dir if git isn't CWD (bz 1138962)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user