diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-09 17:47:58 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-09 17:47:58 +0300 |
commit | a742941804dd6f4b1ea3f39dfe3c7072b4b50e6b (patch) | |
tree | 286d2c03c2346b195c2989488d4da1e967a7c2e9 /subplot/client.py | |
parent | d0b0245edbb2f6ed8285358d83b98f3334bf1b12 (diff) | |
download | obnam2-a742941804dd6f4b1ea3f39dfe3c7072b4b50e6b.tar.gz |
refactor: make tests install a config in the default location
This way, every step doesn't need to specify a --config option to the
Obnam client.
Diffstat (limited to 'subplot/client.py')
-rw-r--r-- | subplot/client.py | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/subplot/client.py b/subplot/client.py index 90642f3..1ddc772 100644 --- a/subplot/client.py +++ b/subplot/client.py @@ -26,38 +26,27 @@ def configure_client(ctx, filename=None): config["server_url"] = ctx["server_url"] logging.debug(f"client config {filename}: {config}") + dirname = os.path.expanduser("~/.config/obnam") + if not os.path.exists(dirname): + os.makedirs(dirname) + filename = os.path.join(dirname, "obnam.yaml") + logging.debug(f"configure_client: filename={filename}") with open(filename, "w") as f: yaml.safe_dump(config, stream=f) -def run_obnam_restore(ctx, filename=None, genid=None, todir=None): - genid = ctx["vars"][genid] - run_obnam_restore_with_genref(ctx, filename=filename, genref=genid, todir=todir) +def run_obnam_restore(ctx, genid=None, todir=None): + runcmd_run = globals()["runcmd_run"] + genref = ctx["vars"][genid] + runcmd_run(ctx, ["env", "RUST_LOG=obnam", "obnam", "restore", genref, todir]) -def run_obnam_restore_with_genref(ctx, filename=None, genref=None, todir=None): - runcmd_run = globals()["runcmd_run"] - runcmd_run( - ctx, - [ - "env", - "RUST_LOG=obnam", - "obnam", - "--config", - filename, - "restore", - genref, - todir, - ], - ) - - -def run_obnam_get_chunk(ctx, filename=None, gen_id=None, todir=None): +def run_obnam_get_chunk(ctx, gen_id=None, todir=None): runcmd_run = globals()["runcmd_run"] gen_id = ctx["vars"][gen_id] logging.debug(f"run_obnam_get_chunk: gen_id={gen_id}") - runcmd_run(ctx, ["obnam", "--config", filename, "get-chunk", gen_id]) + runcmd_run(ctx, ["obnam", "get-chunk", gen_id]) def capture_generation_id(ctx, varname=None): |