diff options
author | MS <ms@taler.net> | 2021-05-18 08:59:45 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2021-05-18 08:59:45 +0200 |
commit | 49cfd3605e2c668f907335a39fce7f0780dace91 (patch) | |
tree | 26f262e15cbd0bc3765169b7d4d9e70cc5b66328 | |
parent | 7e7d831a6eaff1ce01285005eb2fc3d5d907675e (diff) | |
download | deployment-49cfd3605e2c668f907335a39fce7f0780dace91.tar.gz deployment-49cfd3605e2c668f907335a39fce7f0780dace91.tar.bz2 deployment-49cfd3605e2c668f907335a39fce7f0780dace91.zip |
preferring pathlib
-rwxr-xr-x | bin/taler-deployment | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | bin/taler-deployment-auth-token | 13 |
2 files changed, 13 insertions, 8 deletions
diff --git a/bin/taler-deployment b/bin/taler-deployment index 54b30bb..adcdd41 100755 --- 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 index bd638fd..03c0620 100644..100755 --- 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") |