Adds API HOST and PORT as configurable parameters.

Uses API_BIND/API_PORT for the server and API_CONNECT/API_PORT for the user, for consistency.
This commit is contained in:
Sergi Delgado Segura
2020-04-07 12:10:49 +02:00
parent 2be433d589
commit bed21e9625
13 changed files with 50 additions and 31 deletions

View File

@@ -406,7 +406,7 @@ def main(command, args, command_line_conf):
setup_logging(config.get("LOG_FILE"), LOG_PREFIX)
# Set the teos url
teos_url = "{}:{}".format(config.get("TEOS_SERVER"), config.get("TEOS_PORT"))
teos_url = "{}:{}".format(config.get("API_CONNECT"), config.get("API_PORT"))
# If an http or https prefix if found, leaves the server as is. Otherwise defaults to http.
if not teos_url.startswith("http"):
teos_url = "http://" + teos_url
@@ -479,17 +479,17 @@ if __name__ == "__main__":
commands = ["register", "add_appointment", "get_appointment", "get_all_appointments", "help"]
try:
opts, args = getopt(argv[1:], "s:p:h", ["server", "port", "help"])
opts, args = getopt(argv[1:], "h", ["apiconnect=", "apiport=", "help"])
for opt, arg in opts:
if opt in ["-s", "--server"]:
if opt in ["--apiconnect"]:
if arg:
command_line_conf["TEOS_SERVER"] = arg
command_line_conf["API_CONNECT"] = arg
if opt in ["-p", "--port"]:
if opt in ["--apiport"]:
if arg:
try:
command_line_conf["TEOS_PORT"] = int(arg)
command_line_conf["API_PORT"] = int(arg)
except ValueError:
sys.exit("port must be an integer")