From 31037597ad8a48ca8f3a871a70b58995caf8513c Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Sun, 23 Mar 2025 18:28:52 +0000 Subject: [PATCH] issue #36 - env variables: now a default value is set at .env.sample if the user wants to add custom config they can create a .env file --- .env.sample | 3 +++ SimpleX/main.py | 5 ++++- scripts/lantern.py | 7 +++++-- scripts/uptimechecker.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..02f7692 --- /dev/null +++ b/.env.sample @@ -0,0 +1,3 @@ +TOR_HOST=socks5h://127.0.0.1 +TOR_PORT=9050 +WEBSOCKET_PORT=3030 \ No newline at end of file diff --git a/SimpleX/main.py b/SimpleX/main.py index 23e6708..6bd3d0e 100644 --- a/SimpleX/main.py +++ b/SimpleX/main.py @@ -5,7 +5,10 @@ import json import random import os -load_dotenv() +if os.path.exists('.env'): + load_dotenv(".env") +else: + load_dotenv(".env.sample") websocket_port = os.environ.get("WEBSOCKET_PORT") diff --git a/scripts/lantern.py b/scripts/lantern.py index 15bc385..3a43ea7 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -9,7 +9,10 @@ import time import urllib import sys -load_dotenv() +if os.path.exists('.env'): + load_dotenv(".env") +else: + load_dotenv(".env.sample") tor_host = os.environ.get("TOR_HOST") tor_port = os.environ.get("TOR_PORT") @@ -1196,4 +1199,4 @@ Maintenance: if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/scripts/uptimechecker.py b/scripts/uptimechecker.py index 00d1a41..103ade6 100644 --- a/scripts/uptimechecker.py +++ b/scripts/uptimechecker.py @@ -7,7 +7,10 @@ import json import pandas as pd import glob -load_dotenv() +if os.path.exists('.env'): + load_dotenv(".env") +else: + load_dotenv(".env.sample") tor_host = os.environ.get("TOR_HOST") tor_port = os.environ.get("TOR_PORT")