Skip to content

Commit f905fa6

Browse files
author
Son NK
committed
add GNUPGHOME config
1 parent b5637d6 commit f905fa6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

app/config.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import os
2+
import random
3+
import string
24
import subprocess
5+
import tempfile
36
from uuid import uuid4
47

58
from dotenv import load_dotenv
@@ -154,6 +157,17 @@ def get_abs_path(file_path: str):
154157
os.environ.get("WORDS_FILE_PATH", "local_data/words_alpha.txt")
155158
)
156159

160+
# Used to generate random email
161+
if os.environ.get("GNUPGHOME"):
162+
GNUPGHOME = get_abs_path(os.environ.get("GNUPGHOME"))
163+
else:
164+
letters = string.ascii_lowercase
165+
random_dir_name = "".join(random.choice(letters) for _ in range(20))
166+
GNUPGHOME = f"/tmp/{random_dir_name}"
167+
if not os.path.exists(GNUPGHOME):
168+
os.mkdir(GNUPGHOME, mode=0o700)
169+
170+
print("WARNING: Use a temp directory for GNUPGHOME", GNUPGHOME)
157171

158172
# Github, Google, Facebook client id and secrets
159173
GITHUB_CLIENT_ID = os.environ.get("GITHUB_CLIENT_ID")

example.env

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,7 @@ FACEBOOK_CLIENT_SECRET=to_fill
108108

109109
# Flask profiler
110110
# FLASK_PROFILER_PATH=/tmp/flask-profiler.sql
111-
# FLASK_PROFILER_PASSWORD=password
111+
# FLASK_PROFILER_PASSWORD=password
112+
113+
# Where to store GPG Keyring
114+
# GNUPGHOME=/tmp/gnupg

0 commit comments

Comments
 (0)