gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-deployment] branch master updated: preferring pathlib


From: gnunet
Subject: [taler-deployment] branch master updated: preferring pathlib
Date: Tue, 18 May 2021 08:59:48 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository deployment.

The following commit(s) were added to refs/heads/master by this push:
     new 49cfd36  preferring pathlib
49cfd36 is described below

commit 49cfd3605e2c668f907335a39fce7f0780dace91
Author: MS <ms@taler.net>
AuthorDate: Tue May 18 08:59:45 2021 +0200

    preferring pathlib
---
 bin/taler-deployment            |  8 ++++----
 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
old mode 100644
new mode 100755
index bd638fd..03c0620
--- 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")

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]