description = "\n" \ "Please create new trains credentials through the profile page in " \ "your trains web app (e.g. http://localhost:8080/profile)\n" \ "In the profile page, press \"Create new credentials\", then press \"Copy to clipboard\".\n" \ "\n" \ "Paste copied configuration here:\n" host_description = """ Editing configuration file: {CONFIG_FILE} Enter the url of the trains-server's Web service, for example: {HOST} """ # noinspection PyBroadException try: def_host = ENV_HOST.get(default=config_obj.get("api.web_server")) or 'http://localhost:8080' except Exception: def_host = 'http://localhost:8080' def validate_file(string): if not string: raise argparse.ArgumentTypeError("expected a valid file path") return string def main(): default_config_file = os.getenv(LOCAL_CONFIG_FILE_OVERRIDE_VAR) or LOCAL_CONFIG_FILES[0] p = argparse.ArgumentParser(description=__doc__) p.add_argument(
from pathlib2 import Path from six.moves.urllib.parse import urlparse from trains.backend_api.session.defs import ENV_HOST from trains.backend_config.defs import LOCAL_CONFIG_FILES from trains.config import config_obj description = """ Please create new credentials using the web app: {}/admin In the Admin page, press "Create new credentials", then press "Copy to clipboard" Paste credentials here: """ try: def_host = ENV_HOST.get(default=config_obj.get("api.host")) except Exception: def_host = 'http://localhost:8080' host_description = """ Editing configuration file: {CONFIG_FILE} Enter the url of the trains-server's api service, example: http://localhost:8008 or default demo server [{HOST}]: """.format( CONFIG_FILE=LOCAL_CONFIG_FILES[0], HOST=def_host, ) def main(): print('TRAINS SDK setup process') conf_file = Path(LOCAL_CONFIG_FILES[0]).absolute() if conf_file.exists() and conf_file.is_file() and conf_file.stat().st_size > 0: