api: If there is no $HOME, assume .zuliprc doesn't exist.

This commit is contained in:
Eeshan Garg 2017-05-29 22:49:59 -02:30 committed by Tim Abbott
parent 55f4f16d7a
commit 7f81f6b7e5

View file

@ -168,7 +168,10 @@ def init_from_options(options, client=None):
client_cert_key=options.client_cert_key) client_cert_key=options.client_cert_key)
def get_default_config_filename(): 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") config_file = os.path.join(os.environ["HOME"], ".zuliprc")
if (not os.path.exists(config_file) and if (not os.path.exists(config_file) and
os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))): os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))):
@ -205,7 +208,7 @@ class Client(object):
if config_file is None: if config_file is None:
config_file = get_default_config_filename() 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() config = SafeConfigParser()
with open(config_file, 'r') as f: with open(config_file, 'r') as f:
config.readfp(f, config_file) config.readfp(f, config_file)