api: Ensure automatic tilde expansion.
This commit is contained in:
parent
6db062ef75
commit
9d683e4669
|
@ -254,6 +254,9 @@ class Client(object):
|
||||||
if client is None:
|
if client is None:
|
||||||
client = _default_client()
|
client = _default_client()
|
||||||
|
|
||||||
|
# Normalize user-specified path
|
||||||
|
if config_file is not None:
|
||||||
|
config_file = os.path.abspath(os.path.expanduser(config_file))
|
||||||
# Fill values from Environment Variables if not available in Constructor
|
# Fill values from Environment Variables if not available in Constructor
|
||||||
if config_file is None:
|
if config_file is None:
|
||||||
config_file = os.environ.get("ZULIP_CONFIG")
|
config_file = os.environ.get("ZULIP_CONFIG")
|
||||||
|
@ -301,7 +304,7 @@ class Client(object):
|
||||||
raise RuntimeError("insecure is set to '%s', it must be 'true' or 'false' if it is used in %s"
|
raise RuntimeError("insecure is set to '%s', it must be 'true' or 'false' if it is used in %s"
|
||||||
% (insecure_setting, config_file))
|
% (insecure_setting, config_file))
|
||||||
elif None in (api_key, email):
|
elif None in (api_key, email):
|
||||||
raise RuntimeError("api_key or email not specified and %s does not exist"
|
raise RuntimeError("api_key or email not specified and file %s does not exist"
|
||||||
% (config_file,))
|
% (config_file,))
|
||||||
|
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
|
|
|
@ -20,6 +20,9 @@ bots_lib_module = {} # type: Dict[str, Any]
|
||||||
|
|
||||||
def read_config_file(config_file_path):
|
def read_config_file(config_file_path):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
|
config_file_path = os.path.abspath(os.path.expanduser(config_file_path))
|
||||||
|
if not os.path.isfile(config_file_path):
|
||||||
|
raise IOError("Could not read config file {}: File not found.".format(config_file_path))
|
||||||
parser = SafeConfigParser()
|
parser = SafeConfigParser()
|
||||||
parser.read(config_file_path)
|
parser.read(config_file_path)
|
||||||
|
|
||||||
|
@ -55,7 +58,8 @@ def handle_bot(bot):
|
||||||
lib_module = get_bot_lib_module(bot)
|
lib_module = get_bot_lib_module(bot)
|
||||||
if lib_module is None:
|
if lib_module is None:
|
||||||
return BadRequest("Can't find the configuration or Bot Handler code for bot {}. "
|
return BadRequest("Can't find the configuration or Bot Handler code for bot {}. "
|
||||||
"Make sure that the `zulip_bots` package is installed!".format(bot))
|
"Make sure that the `zulip_bots` package is installed, and "
|
||||||
|
"that your flaskbotrc is set up correctly".format(bot))
|
||||||
|
|
||||||
client = Client(email=bots_config[bot]["email"],
|
client = Client(email=bots_config[bot]["email"],
|
||||||
api_key=bots_config[bot]["key"],
|
api_key=bots_config[bot]["key"],
|
||||||
|
|
Loading…
Reference in a new issue