From 7f81f6b7e59ae8a23b6bade7d73131ddf7bec32b Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Mon, 29 May 2017 22:49:59 -0230 Subject: [PATCH] api: If there is no $HOME, assume .zuliprc doesn't exist. --- zulip/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index a63b2e1..da1bdb2 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -168,7 +168,10 @@ def init_from_options(options, client=None): client_cert_key=options.client_cert_key) def get_default_config_filename(): - # type: () -> str + # type: () -> Optional[str] + if os.environ.get("HOME") is None: + return None + config_file = os.path.join(os.environ["HOME"], ".zuliprc") if (not os.path.exists(config_file) and os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))): @@ -205,7 +208,7 @@ class Client(object): if config_file is None: config_file = get_default_config_filename() - if os.path.exists(config_file): + if config_file is not None and os.path.exists(config_file): config = SafeConfigParser() with open(config_file, 'r') as f: config.readfp(f, config_file)