summaryrefslogtreecommitdiff
path: root/bin/taler-deployment-auth-token
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-18 08:59:45 +0200
committerMS <ms@taler.net>2021-05-18 08:59:45 +0200
commit49cfd3605e2c668f907335a39fce7f0780dace91 (patch)
tree26f262e15cbd0bc3765169b7d4d9e70cc5b66328 /bin/taler-deployment-auth-token
parent7e7d831a6eaff1ce01285005eb2fc3d5d907675e (diff)
downloaddeployment-49cfd3605e2c668f907335a39fce7f0780dace91.tar.gz
deployment-49cfd3605e2c668f907335a39fce7f0780dace91.tar.bz2
deployment-49cfd3605e2c668f907335a39fce7f0780dace91.zip
preferring pathlib
Diffstat (limited to 'bin/taler-deployment-auth-token')
-rwxr-xr-x[-rw-r--r--]bin/taler-deployment-auth-token13
1 files changed, 9 insertions, 4 deletions
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")