|
|
|
|
@ -20,7 +20,7 @@ def get_env(): |
|
|
|
|
load_dotenv(".env") |
|
|
|
|
pwd = os.environ['ARANGO_PWD_ENV_MANAGER'] |
|
|
|
|
except (FileNotFoundError, KeyError): |
|
|
|
|
import getpass |
|
|
|
|
from getpass import getpass |
|
|
|
|
import warnings |
|
|
|
|
warnings.warn("No .env file found or 'ARANGO_PWD_ENV_MANAGER' not set.", UserWarning) |
|
|
|
|
pwd = getpass("Enter the ArangoDB password for the user 'env_manager': ") |
|
|
|
|
@ -37,10 +37,26 @@ def get_env(): |
|
|
|
|
db = ArangoClient(hosts=host).db(db, username=username, password=pwd) |
|
|
|
|
env_doc = db.collection('enviroment').all().next() |
|
|
|
|
|
|
|
|
|
return env_doc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_env(): |
|
|
|
|
# Set the environment variables |
|
|
|
|
for key, value in env_doc.items(): |
|
|
|
|
for key, value in get_env().items(): |
|
|
|
|
if isinstance(value, dict): |
|
|
|
|
continue |
|
|
|
|
os.environ[key] = str(value) |
|
|
|
|
|
|
|
|
|
return env_doc |
|
|
|
|
def print_env(): |
|
|
|
|
for key, value in get_env().items(): |
|
|
|
|
if isinstance(value, dict): |
|
|
|
|
continue |
|
|
|
|
print(f"{key}: {value}") |
|
|
|
|
|
|
|
|
|
def print_info(): |
|
|
|
|
env_info = get_env()['INFO'] |
|
|
|
|
for i, (k, v) in enumerate(env_info.items()): |
|
|
|
|
if i % 2 == 0: |
|
|
|
|
print(f"\033[90m{k}: {v}\033[0m") # Grey color for even indices |
|
|
|
|
else: |
|
|
|
|
print(f"{k}: {v}") # Default color for odd indices |
|
|
|
|
|