andrewfraley / arris_cable_modem_stats

Retrieves stats from Arris cable modems and sends to InfluxDB
50 stars 33 forks source link

Return to main to re-auth on error #13

Closed mbentley closed 3 years ago

mbentley commented 3 years ago

Signed-off-by: Matt Bentley mbentley@mbentley.net

mbentley commented 3 years ago

I found that if I logged in to the cable modem myself, it would break the auth or if my session expired or something of that nature. Instead of continuing, I just return back to main which causes it to re-auth. This probably isn't the cleanest way to do this but I am not great at Python.

Feel free to close this is you think it is a bit too heavy handed but it is easier than having to make sure to restart the process/container in the case of the session being ended and re-authentication needing to occur.

andrewfraley commented 3 years ago

@mbentley Thank you for this. I made some other changes that should give you the same result. There are now multiple config options to handle exiting and retries. The one you're looking for in particular I think is clear_auth_token_on_html_error = True, which should cause the script to obtain a new session from the modem if it encounters an error pulling the stats from the modem.

Note the config file is a little different now so you'll have to start over with the new format, or you can use ENV variables to set the same options as well.

mbentley commented 3 years ago

Awesome, thanks!