Skip to content

Commit

Permalink
v0.6.1 (#3)
Browse files Browse the repository at this point in the history
* fix subscription invoice date

* add incremental backoff

* bump version 0.6.1
  • Loading branch information
aSauerwein authored Jun 23, 2024
1 parent c3e9d88 commit 5010661
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions download_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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']}")
Expand Down

0 comments on commit 5010661

Please sign in to comment.