diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-18 08:47:37 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-18 08:47:37 +0200 |
commit | b5ddc105852b63651916f322ce855baf61d129d0 (patch) | |
tree | d6e6ee6ca6f0ecfbba1311879e87e77a720a49c9 /subplot | |
parent | 24ffcb0083750bb77963a1ab8e3205290c2c7190 (diff) | |
download | obnam2-b5ddc105852b63651916f322ce855baf61d129d0.tar.gz |
feat! change client config to take a base URL instead of host, port
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/client.py | 6 | ||||
-rw-r--r-- | subplot/server.py | 12 |
2 files changed, 7 insertions, 11 deletions
diff --git a/subplot/client.py b/subplot/client.py index f159e74..7556986 100644 --- a/subplot/client.py +++ b/subplot/client.py @@ -14,13 +14,11 @@ def install_obnam(ctx): def configure_client(ctx, filename=None): get_file = globals()["get_file"] - assert ctx.get("server_name") is not None - assert ctx.get("server_port") is not None + assert ctx.get("server_url") is not None config = get_file(filename) config = yaml.safe_load(config) - config["server_name"] = ctx["server_name"] - config["server_port"] = ctx["server_port"] + config["server_url"] = ctx["server_url"] with open(filename, "w") as f: yaml.safe_dump(config, stream=f) diff --git a/subplot/server.py b/subplot/server.py index c159798..5952cb2 100644 --- a/subplot/server.py +++ b/subplot/server.py @@ -33,9 +33,7 @@ def start_chunk_server(ctx): logging.debug(f"Picked randomly port for obnam-server: {config['port']}") ctx["config"] = config - ctx["server_name"] = "localhost" - ctx["server_port"] = port - ctx["url"] = f"http://localhost:{port}" + ctx["server_url"] = f"http://localhost:{port}/chunks" start_daemon( ctx, @@ -55,7 +53,7 @@ def stop_chunk_server(ctx): def post_file(ctx, filename=None, path=None, header=None, json=None): - url = f"{ctx['url']}/chunks" + url = f"{ctx['server_url']}" headers = {header: json} data = open(filename, "rb").read() _request(ctx, requests.post, url, headers=headers, data=data) @@ -67,12 +65,12 @@ def get_chunk_via_var(ctx, var=None): def get_chunk_by_id(ctx, chunk_id=None): - url = f"{ctx['url']}/chunks/{chunk_id}" + url = f"{ctx['server_url']}/{chunk_id}" _request(ctx, requests.get, url) def find_chunks_with_sha(ctx, sha=None): - url = f"{ctx['url']}/chunks?sha256={sha}" + url = f"{ctx['server_url']}?sha256={sha}" _request(ctx, requests.get, url) @@ -82,7 +80,7 @@ def delete_chunk_via_var(ctx, var=None): def delete_chunk_by_id(ctx, chunk_id=None): - url = f"{ctx['url']}/chunks/{chunk_id}" + url = f"{ctx['server_url']}/{chunk_id}" _request(ctx, requests.delete, url) |