diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8171634..1836eff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,3 +58,9 @@ of making a fork and pull request yourself: Please use clear commit messages so we can understand what each commit does. We'll review every PR and might offer feedback or request changes before merging. + +## Local build and test + +- pip install build # Install the build library +- python -m build # Build this library with your changes +- pip install . # Install built library locally \ No newline at end of file diff --git a/min_requirements.txt b/min_requirements.txt index 299ac60..ce17677 100644 --- a/min_requirements.txt +++ b/min_requirements.txt @@ -2,4 +2,5 @@ certifi==2022.6.15 charset-normalizer==2.1.1 idna==3.3 requests==2.28.1 -urllib3==1.26.12 \ No newline at end of file +urllib3==1.26.12 +json5==0.12.0 diff --git a/requirements.txt b/requirements.txt index 299ac60..ce17677 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ certifi==2022.6.15 charset-normalizer==2.1.1 idna==3.3 requests==2.28.1 -urllib3==1.26.12 \ No newline at end of file +urllib3==1.26.12 +json5==0.12.0 diff --git a/src/pcpi/session_loader.py b/src/pcpi/session_loader.py index 8b5e794..da71a7c 100644 --- a/src/pcpi/session_loader.py +++ b/src/pcpi/session_loader.py @@ -2,7 +2,7 @@ import os import re import logging -import json +import json5 #Installed import requests @@ -344,7 +344,11 @@ def load_config(file_path='', num_tenants=-1, min_tenants=-1, logger=py_logger): exit() if file_path == '': - config_dir = os.path.join(os.environ['HOME'], '.prismacloud') + env_vars = os.environ.keys() + if "HOME" in env_vars: + config_dir = os.path.join(os.environ['HOME'], '.prismacloud') + elif "USERPROFILE" in env_vars: + config_dir = os.path.join(os.environ['USERPROFILE'], '.prismacloud') config_path = os.path.join(config_dir, 'credentials.json') if not os.path.exists(config_dir): os.mkdir(config_dir) @@ -356,12 +360,12 @@ def load_config(file_path='', num_tenants=-1, min_tenants=-1, logger=py_logger): if not os.path.exists(config_path): config = __get_config_from_user(num_tenants, min_tenants) with open(config_path, 'w') as outfile: - json.dump(config, outfile) + json5.dump(config, outfile) config_data = {} with open(config_path, 'r') as infile: try: - config_data = json.load(infile) + config_data = json5.load(infile) except Exception as e: logger.error('Failed to load credentials file. Exiting...') logger.log(e)