environment-variables

Mocking os.environ with python unittests

Mocking os.environ with python unittests Question: I am trying to test a class that handles for me the working directory based on a given parameter. To do so, we are using a class variable to map them. When a specific value is passed, the path is retrieved from the environment variables (See baz in the …

Total answers: 2

How to use variables from an environment file Python?

How to use variables from an environment file Python? Question: I have a project that I’m working on in which I need to store sensitive information into an environment file as variables that can later be called in my code. I’m having issues with it working and so I’ve dumbed it down to the simplest …

Total answers: 1

Using ffmpeg on PythonAnywhere

Using ffmpeg on PythonAnywhere Question: My (first) web app uses pydub, which depends on ffmpeg. On my local windows environment, I installed ffmpeg and added the path to the ffmpeg executables to the windows "path" environment variables. It all works locally, but bow that I have deployed my app to PythonAnywhere, the following line in …

Total answers: 2

Can't Access configparser environment variables from env.ini file in faust (kafka streaming)

Can't Access configparser environment variables from env.ini file in faust (kafka streaming) Question: My Project is on FastAPI and the structure goes like this. – project – app – kafka_layer – faustworker.py – core – configs.py – env.ini My env.ini file goes like this [DEFAULT] DATABASE_URL=url_to_db I’ve tried adding this code in configs.py import configparser …

Total answers: 1

How to update a int value on a .env file using python

How to update a int value on a .env file using python Question: I have a problem doing this python file . The idea its that this python file could change a int value in a .env file . The problem its that i could change the value of the field in the env , …

Total answers: 1

Can I resolve environment variables with pathlib.Path without os.path.expandvars?

Can I resolve environment variables with pathlib.Path without os.path.expandvars? Question: Is there a clean way to resolve environment variables or %VARIABLES% in general purely with the Path class without having to use a fallback solution like os.path.expandvars or "my/path/%variable%".fortmat(**os.environ)? The question How to use win environment variable "pathlib" to save files? doesn’t provide an answer. …

Total answers: 1

How to check the availability of environment variables correctly?

How to check the availability of environment variables correctly? Question: I did a token check, if at least one token is missing, ‘True’ will not be. Now I need to deduce which variable is missing, how to do it? PRACTICUM_TOKEN = os.getenv(‘PRACTICUM_TOKEN’) TELEGRAM_TOKEN = os.getenv(‘TELEGRAM_TOKEN’) TELEGRAM_CHAT_ID = os.getenv(‘TELEGRAM_CHAT_ID’) def check_tokens(): """Checks the availability of environment …

Total answers: 2

How to access GitHub action secrets with python?

How to access GitHub action secrets with python? Question: I have environment secrets set up in a Python GitHub actions project: I can access the secrets from the actions file, because the following: jobs: log-the-inputs: runs-on: ubuntu-latest steps: – run: | echo "Log level: $LEVEL" echo "Tags: $TAGS" echo "Environment: $ENVIRONMENT" echo ${{ secrets.EMAIL_USER }} …

Total answers: 1

GitHub action couldn't find environment variable for Django

GitHub action couldn't find environment variable for Django Question: I was trying to use the environment variable in my Django application where I use the django-environ package with the .env file in my local machine. But I can’t use the .env file in my GitHub action. I’ve configured action secret variables manually from my project …

Total answers: 1

Why PyCharm does not recognize user environment variables configuration?

Why PyCharm does not recognize user environment variables configuration? Question: I tried to use the PyCharm user environment variable configuration, however, it throws KeyError. If I try to set the variables via commands it works, but via configuration it does not. I will appreciate any help. import os print(os.environ[‘BLA’]) (venv) (base) mikam@Mikas-MacBook-Pro Scripts % python …

Total answers: 3