-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix subscription invoice date * add incremental backoff * bump version 0.6.1
- Loading branch information
1 parent
c3e9d88
commit 5010661
Showing
1 changed file
with
5 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Author: Dominik Steiner ([email protected]), Andreas Sauerwein-Schlosser ([email protected]) | ||
Description: This script downloads all Tesla charging invoices for a given month. | ||
Usage: python3 dsteiner_tesla_invoices_download.py | ||
Version: 0.6.0 | ||
Version: 0.6.1 | ||
Date Created: 2024-02-05 | ||
Changed: Changed Owner-API Endpoint to /products instead of /vehicles. | ||
Python Version: 3.11.7 | ||
|
@@ -95,7 +95,7 @@ def base_req(url: str, method="get", json={}, *args, **kwargs): | |
break | ||
except requests.exceptions.ChunkedEncodingError: | ||
logger.warning(f"incomplete read occured, attempt {attempt} of 3") | ||
sleep(1) | ||
sleep(attempt * 3 + 1) # sleep for 1, 4, 7 seconds | ||
else: | ||
logger.error("giving up after 3 tries") | ||
exit(1) | ||
|
@@ -242,7 +242,7 @@ def interactive(): | |
prev_month = cur_month - timedelta(days=1) | ||
|
||
user_choice_month = input( | ||
"Bitte gewünschten Monat im Format 'YYYY-MM' bzw. 'cur' oder 'prev' oder 'all' für aktuellen oder vorherigen Monat oder alles eingeben [prev]: " # noqa | ||
"Bitte gewünschten Monat im Format 'YYYY-MM' bzw. 'cur' oder 'prev' oder 'all' für aktuellen oder vorherigen Monat oder alles eingeben [prev]: " # noqa | ||
) | ||
user_choice_month = user_choice_month.strip().lower() | ||
|
||
|
@@ -375,7 +375,7 @@ def save_subscription_invoice(subscription_invoices, desired_invoice_date, vin): | |
INVOICE_PATH.mkdir(parents=True, exist_ok=True) | ||
|
||
for invoice in subscription_invoices: | ||
invoice_datetime = datetime.fromisoformat(subscription_invoices[0]["InvoiceDate"]) | ||
invoice_datetime = datetime.fromisoformat(invoice["InvoiceDate"]) | ||
|
||
# check for desired invoice date | ||
if desired_invoice_date.year == 1999: | ||
|
@@ -393,7 +393,7 @@ def save_subscription_invoice(subscription_invoices, desired_invoice_date, vin): | |
) | ||
if local_file_path.exists(): | ||
# file already downloaded, skip | ||
logger.info(f"Invoice {invoice['InvoiceFileName']} already saved") | ||
logger.info(f"Invoice - {invoice['InvoiceFileName']} already saved to {local_file_path}") | ||
continue | ||
|
||
logger.info(f"Downloading {invoice['InvoiceFileName']}") | ||
|