def _get_access_token(force_server=False): config = whetlab.load_config() if "access_token" not in config.keys() or force_server: access_token = _get_access_token_from_server() return access_token else: return config['access_token']
def make_url(path): global _api_suffix global _host_url config = whetlab.load_config() if "api_url" not in config.keys(): _host_url = _default_host_url else: _host_url = config['api_url'] return urlparse.urljoin(urlparse.urljoin(_host_url, _api_suffix), path)
def _get_auth(): username, password, access_token = None, None, None config = whetlab.load_config() if "access_token" not in config.keys() or config["access_token"] == "": click.echo("Please log in to download your access token:") username, password = _get_login() access_token = None else: access_token = config['access_token'] auth, headers = _format_auth(username, password, access_token) return auth, headers
def _get_auth(): username,password,access_token = None,None,None config = whetlab.load_config() if "access_token" not in config.keys() or config["access_token"] == "": click.echo("Please log in to download your access token:") username, password = _get_login() access_token = None else: access_token = config['access_token'] auth, headers = _format_auth(username, password, access_token) return auth, headers
def setup(): """Log in and set up this machine to work with Whetlab """ config = whetlab.load_config() if len(config.keys()) > 0: # if config setup yes = click.confirm("You've already set up Whetlab. Rerun setup?") if not yes: return global _host_url _host_url = None config_filepath = whetlab.find_config_file() if config_filepath: os.remove(config_filepath) access_token = _get_access_token(force_server=True) click.echo("Setting up Whetlab config file...") _write_config(access_token) click.echo("All setup! Run whetlab get-token to see your access token.")