add load_json_to_environ
This commit is contained in:
parent
fed7d27136
commit
2f6d0c47e5
2 changed files with 13 additions and 7 deletions
10
main.py
10
main.py
|
|
@ -1,16 +1,12 @@
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from pytest_abra.utils import load_json_to_environ
|
||||||
|
|
||||||
# --------------------- load credentials to env variables -------------------- #
|
# --------------------- load credentials to env variables -------------------- #
|
||||||
|
|
||||||
cred_file = Path("credentials.json")
|
cred_file = Path("credentials.json")
|
||||||
with open(cred_file, "r") as f:
|
load_json_to_environ(cred_file)
|
||||||
CREDENTIALS = json.load(f)
|
|
||||||
|
|
||||||
for key, value in CREDENTIALS.items():
|
|
||||||
os.environ[key] = value
|
|
||||||
|
|
||||||
# --------------------------------- env files -------------------------------- #
|
# --------------------------------- env files -------------------------------- #
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
@ -46,3 +48,11 @@ def generate_random_string(length: int, punctuation=False) -> str:
|
||||||
characters += string.punctuation
|
characters += string.punctuation
|
||||||
random_string = "".join(random.choice(characters) for _ in range(length))
|
random_string = "".join(random.choice(characters) for _ in range(length))
|
||||||
return random_string
|
return random_string
|
||||||
|
|
||||||
|
|
||||||
|
def load_json_to_environ(cred_file: Path):
|
||||||
|
with open(cred_file, "r") as f:
|
||||||
|
CREDENTIALS = json.load(f)
|
||||||
|
|
||||||
|
for key, value in CREDENTIALS.items():
|
||||||
|
os.environ[key] = value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue