Skip to content

Commit

Permalink
Merge e9ca237 into 1c9786b
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard33 committed Apr 23, 2020
2 parents 1c9786b + e9ca237 commit b60e941
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions bimmer_connected/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import datetime
import logging
import pathlib
import urllib
import os
import json
from threading import Lock
from typing import Callable, List
Expand Down Expand Up @@ -42,7 +42,7 @@ class ConnectedDriveAccount: # pylint: disable=too-many-instance-attributes
"""

# pylint: disable=too-many-arguments
def __init__(self, username: str, password: str, region: Regions, log_responses: str = None,
def __init__(self, username: str, password: str, region: Regions, log_responses: pathlib.Path = None,
retries_on_500_error: int = 5) -> None:
self._region = region
self._server_url = None
Expand Down Expand Up @@ -183,8 +183,8 @@ def _log_response_to_file(self, response: requests.Response, logfilename: str =
output_path = None
count = 0

while output_path is None or os.path.exists(output_path):
output_path = os.path.join(self._log_responses, '{}_{}.txt'.format(logfilename, count))
while output_path is None or output_path.exists():
output_path = self._log_responses / '{}_{}.txt'.format(logfilename, count)
count += 1

with open(output_path, 'w') as logfile:
Expand Down
11 changes: 4 additions & 7 deletions bimmer_connected/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
import argparse
import logging
import json
import os
import time
import sys

from pathlib import Path

import requests

from bimmer_connected.account import ConnectedDriveAccount
from bimmer_connected.country_selector import get_region_from_name, valid_regions
from bimmer_connected.vehicle import VehicleViewDirection

FINGERPRINT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'vehicle_fingerprint')

TEXT_VIN = 'Vehicle Identification Number'


Expand Down Expand Up @@ -106,9 +104,8 @@ def get_status(args) -> None:

def fingerprint(args) -> None:
"""Save the vehicle fingerprint."""
time_str = time.strftime("%Y-%m-%d_%H-%M-%S")
time_dir = os.path.join(FINGERPRINT_DIR, time_str)
os.makedirs(time_dir)
time_dir = Path.home() / 'vehicle_fingerprint' / time.strftime("%Y-%m-%d_%H-%M-%S")
time_dir.mkdir(parents=True)

account = ConnectedDriveAccount(args.username, args.password, get_region_from_name(args.region),
log_responses=time_dir)
Expand Down

0 comments on commit b60e941

Please sign in to comment.