diff --git a/trains_agent/commands/config.py b/trains_agent/commands/config.py index 93a4212..725c1ab 100644 --- a/trains_agent/commands/config.py +++ b/trains_agent/commands/config.py @@ -78,20 +78,24 @@ def main(): web_host = '' files_host = '' if not parsed_host.port: - print('Host port not detected, do you wish to use the default 8008 port n/[y]? ', end='') + print('Host port not detected, do you wish to use the default 8080 port n/[y]? ', end='') replace_port = input().lower() if not replace_port or replace_port == 'y' or replace_port == 'yes': api_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8008' + parsed_host.path web_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8080' + parsed_host.path files_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8081' + parsed_host.path + elif not replace_port or replace_port.lower() == 'n' or replace_port.lower() == 'no': + web_host = input_host_port("Web", parsed_host) + api_host = input_host_port("API", parsed_host) + files_host = input_host_port("Files", parsed_host) if not api_host: api_host = parsed_host.scheme + "://" + parsed_host.netloc + parsed_host.path api_host = input_url('API Host', api_host) files_host = input_url('File Store Host', files_host) - print('\nTRAINS Hosts configuration:\nAPI: {}\nWeb App: {}\nFile Store: {}\n'.format( - api_host, web_host, files_host)) + print('\nTRAINS Hosts configuration:\nWeb App: {}\nAPI: {}\nFile Store: {}\n'.format( + web_host, api_host, files_host)) while True: print(description.format(web_host), end='') @@ -188,12 +192,20 @@ def input_url(host_type, host=None): parse_input = input() if host and (not parse_input or parse_input.lower() == 'yes' or parse_input.lower() == 'y'): break - if parse_input and verify_url(parse_input): - host = parse_input + parsed_host = verify_url(parse_input) if parse_input else None + if parse_input and parsed_host: + host = parsed_host.scheme + "://" + parsed_host.netloc + parsed_host.path break return host +def input_host_port(host_type, parsed_host): + print('Enter port for {} host '.format(host_type), end='') + replace_port = input().lower() + return parsed_host.scheme + "://" + parsed_host.netloc + (':{}'.format(replace_port) if replace_port else '') + \ + parsed_host.path + + def verify_url(parse_input): try: if not parse_input.startswith('http://') and not parse_input.startswith('https://'):