Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Add possibility to use environment variables #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

junpet
Copy link

@junpet junpet commented Nov 1, 2020

You can use environment variables instead of storing passwords in
config.py as plaintext. Note that settings.py is still needed, because
this file reads the environment variables.

Changes in settings.py:

Some minimal adjustments in push_msg.py:

  • Remove unused json import
  • Use single quote globally
  • Remove unnecessary whitespace character
  • Break some long lines

You can use environment variables instead of storing passwords in
config.py as plaintext. Note that settings.py is still needed, because
this file reads the  environment variables.

Changes in settings.py:
- Only the domain has to be specified for the URLs. Previously you used
'https://example.com/ocs/v2.php/apps/notifications/api/v2/notifications'
now you only specify 'https://example.com'. This is valid for both
Nextcloud and Gotify URL as well.

Some minimal adjustments in push_msg.py:
- Remove unused json import
- Use single quote globally
- Remove unnecessary whitespace character
- Break some long lines
@mrchainman mrchainman self-assigned this Nov 13, 2020
@mrchainman
Copy link
Owner

mrchainman commented Nov 13, 2020

Hi @junpet
thanks for your work.
Can you confirm, that using environment variables works also with special characters in passwords, i.e. quotes etc.?

EDIT:
I just tried running it, but the environment variables are not being read. Which shell did you use?

@junpet
Copy link
Author

junpet commented Nov 19, 2020

Hi @mrchainman!

Sorry for late answer. I used VSCode on Windows with Python 3 dev container. It looks like this container uses bash. I've created environment variables with the following command:

export NEXTCLOUD_URL="https://cloud.mydomain.com"

I think you can use special characters in the password. IIRC you need to escape $ character, and you can't use = and NUL, but I haven't tested. See more.

BTW, I've created a docker branch as well and I run this script in a container for some time, working like a charm.

@mrchainman
Copy link
Owner

@junpet alright, i will retest it and report back.

@mrchainman
Copy link
Owner

@junpet Sorry, still didn't geht around testing, have a lot going on right now... Would you be interested in maintaining this project?

@junpet
Copy link
Author

junpet commented Jan 24, 2021

@mrchainman Unfortunately I have not much time either, so it wouldn't be much difference if I would maintain this project. Just keep it. Don't worry about merging this. You'll do it if you have time. :) Have a nice day. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants