Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary upload destination #189

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sjefferson99
Copy link
Contributor

Add a secondary upload destination in the config file that defaults to None.

Modified the __init__.py upload readings function to have a stab at the secondary upload once the full set of primary attempts are complete.

The secondary will not retry data if the primary is successful and equally the secondary will receive duplicates if the primary experiences issues on the previous pass.

This is designed to allow me to get extra diagnostic data to my influxdb while not interrupting the Wunderground data upload.

The above could be improved with better error handling logic if there is demand.

This makes improvements in the direction requested in #38 for more concurrent destinations.

@gbravery
Copy link

I had a play with this code (i.e. I wanted to use it in the future, so I thought I'd import it now, ready for when I really wanted it).
However, I found if the secondary_destination was left as None, then the code began to error.
Seemed to be around the import code:
exec(f"import enviro.destinations.{secondary_destination}")
secondary_destination_module = sys.modules[f"enviro.destinations.{secondary_destination}"]
secondary_destination_module.log_destination()

I wonder if there is a safer way of doing this?

@sjefferson99
Copy link
Contributor Author

Yes, this was a bit rushed to get the data I needed in and not enough testing of each scenario.

Scanning the code it looks like the try for the whole block will fail on there being no module called "None" to import. A simple fix would be to put the module import in an "if secondary_destination:" block, although I suspect further work on try blocks would be better. There may be more fallout from expecting that module to exist etc. I vaguely recall having a lot of fun with all those tries and they are not my forte.

I'll set up None in config.py and develop something more robust, might take a few days, especially as my board has currently mysteriously fallen out with my DHCP server.

@sjefferson99
Copy link
Contributor Author

@gbravery I have put the if statements in for the secondary destination code. I've tested it works as expected with influxdb or None set.
I might come back to this and make it look a little less hacky.

@Gadgetoid Gadgetoid added the enhancement New feature or request label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants