I write my own cmd tool and I have created a click cmd where I trigger my upload function. Inside this upload function, I do a artifactory deploy call. If I test this whith pytest the function works, If I test it over the cmd line, it cant find my enviromental variables.
I have added these into my .bashrc and also in pycharm as env var.
Do have any idea why it does not work over the command line. It says that my env vars are None
MY MAIN:
def configure_click(entrypoint: click.Group = cli):
entrypoint.add_command(deploy_log)
return entrypoint
def main():
entrypoint = configure_click(entrypoint=cli)
entrypoint()
@click.command(context_settings=CLICK_CONTEXT_SETTINGS)
@click.option(
'-u', '--storage-url',
required=True,
help='url of the artifactory repository',
@click.option(
'-i', '--input_directory',
required=True,
help='Directory of the updated log',
)
def deploy_log(storage_url,input_directory):
test_log = Log()
test_log.upload_log(storage_url, input_directory)
Log Class:
def upload_log(self, artifactory_path, input_dir):
TARGET_PATH = ('{}/test/log.zip'.format(artifactory_path))
PATH_TO_FILE = 'log.zip'
ARTIFACTORY_USER = os.getenv('ARTIFACTORY_USER')
ARTIFACTORY_TOKEN= os.getenv('ARTIFACTORY_TOKEN')
deploy_cmd = "curl --fail -u"+ARTIFACTORY_USER+":"+ARTIFACTORY_TOKEN+ " -T "+PATH_TO_FILE+" "+ TARGET_PATH
os.system(deploy_cmd)
EXCEPTION:
TypeError: must be str, not NoneType