Skip to content

Commit

Permalink
Don't assume VIRTUAL_ENV is defined
Browse files Browse the repository at this point in the history
Fixes #6618
  • Loading branch information
boite authored and dwaynebailey committed Aug 21, 2017
1 parent af5d78d commit 467ed46
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pootle/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#: Default path for the settings file
SYSTEM_SETTINGS_PATH = os.path.join('/etc', 'pootle', 'pootle.conf')
HOME_SETTINGS_PATH = os.path.join('~', '.pootle', 'pootle.conf')
VENV_SETTINGS_PATH = os.path.join(os.environ["VIRTUAL_ENV"], "pootle.conf")
if "VIRTUAL_ENV" in os.environ:
VENV_SETTINGS_PATH = os.path.join(os.environ["VIRTUAL_ENV"], "pootle.conf")
else:
VENV_SETTINGS_PATH = ""
DEFAULT_SETTINGS_PATH = ":".join(
[SYSTEM_SETTINGS_PATH,
HOME_SETTINGS_PATH,
Expand Down Expand Up @@ -146,7 +149,7 @@ def init_command(parser, args):
u"Not used with sqlite."))

args, remainder_ = parser.parse_known_args(args)
config_path = args.config or VENV_SETTINGS_PATH
config_path = args.config or VENV_SETTINGS_PATH or HOME_SETTINGS_PATH

if os.path.exists(config_path):
resp = None
Expand Down Expand Up @@ -243,7 +246,7 @@ def configure_app(project, config_paths, django_settings_module, runner_name):
logger.error(
u"Configuration file does not exist at %(config_path)r. "
u"Use '%(runner_name)s init' to initialize the configuration file.",
dict(config_path=VENV_SETTINGS_PATH,
dict(config_path=VENV_SETTINGS_PATH or HOME_SETTINGS_PATH,
runner_name=runner_name))
sys.exit(1)
os.environ.setdefault(settings_envvar, ":".join(_config_paths))
Expand Down

0 comments on commit 467ed46

Please sign in to comment.