taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

commit 49cfd3605e2c668f907335a39fce7f0780dace91
parent 7e7d831a6eaff1ce01285005eb2fc3d5d907675e
Author: MS <ms@taler.net>
Date:   Tue, 18 May 2021 08:59:45 +0200

preferring pathlib

Diffstat:
Mbin/taler-deployment | 8++++----
Mbin/taler-deployment-auth-token | 13+++++++++----
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/bin/taler-deployment b/bin/taler-deployment @@ -57,8 +57,6 @@ export TALER_COVERAGE={coverage} export TALER_ENV_FRONTENDS_APITOKEN="$(cat ~/merchant_auth_token)" """ -TOKEN_FILE = "~/merchant_auth_token" - @dataclass class Repo: name: str @@ -689,9 +687,11 @@ def bootstrap() -> None: if deployment_path not in path_list: path_list.insert(0, deployment_path) - if not os.path.isfile(TOKEN_FILE): - with open(TOKEN_FILE, "w") as f: + token_file = Path.home() / "merchant_auth_token" + if not token_file.is_file(): + with token_file.open("w") as f: f.write(generate_apitoken()) + print(f"Token file '{token_file}' created.") with (home / "activate").open("w") as f: f.write( diff --git a/bin/taler-deployment-auth-token b/bin/taler-deployment-auth-token @@ -17,15 +17,20 @@ import random import os +import sys +from pathlib import Path +from string import ascii_letters, ascii_uppercase -TOKEN_FILE = "~/merchant_auth_token" +TOKEN_FILE = Path.home() / "merchant_auth_token" def generate_apitoken(): return "secret-token:" + ''.join(random.choices(ascii_letters + ascii_uppercase, k=10)) -if os.path.isfile(TOKEN_FILE): +if TOKEN_FILE.is_file(): print("~/merchant_auth_token exists already. Not overwriting it!") - return 0 + sys.exit(0) -with open(TOKEN_FILE) as f: +with TOKEN_FILE.open("w") as f: f.write(generate_apitoken()) + +print(f"Token file '{TOKEN_FILE}' created")