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

allowed caller to select servicetype #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions examples/allVehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

from weconnect import weconnect


def main():
""" Simple example showing how to retrieve all vehciles from the account """
parser = argparse.ArgumentParser(
prog='allVehciles',
description='Example retrieving all vehciles in the account')
parser.add_argument('-u', '--username', help='Username of Volkswagen id', required=True)
parser.add_argument('-p', '--password', help='Password of Volkswagen id', required=True)
parser.add_argument('-s', '--servicetype', help='The type of service to be used.', required=False)

args = parser.parse_args()

print('# Initialize WeConnect')
weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False)
if args.servicetype is not None:
# switching to user defined servicetype (e.g. "MyCupra")
print("Selected servicetype is: " + str(args.servicetype))
stype=weconnect.Service(args.servicetype)
weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False, servicetype=stype)
else:
# using default servicetype ("WeConnect")
weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False)

print('# Login')
weConnect.login()
print('# update')
Expand Down
3 changes: 2 additions & 1 deletion weconnect/weconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__( # noqa: C901 # pylint: disable=too-many-arguments
updateCapabilities: bool = True,
updatePictures: bool = True,
numRetries: int = 3,
servicetype=Service.WE_CONNECT, # make service-type controllable by caller. Defaulting to VW WeConnect
timeout: bool = None,
selective: Optional[list[Domain]] = None,
forceReloginAfter: Optional[int] = None
Expand Down Expand Up @@ -104,7 +105,7 @@ def __init__( # noqa: C901 # pylint: disable=too-many-arguments
self.tokenfile = tokenfile

self.__manager = SessionManager(tokenstorefile=tokenfile)
self.__session = self.__manager.getSession(Service.WE_CONNECT, SessionUser(username=username, password=password))
self.__session = self.__manager.getSession(servicetype, SessionUser(username=username, password=password))
self.__session.proxies.update(self.proxystring)
self.__session.timeout = timeout
self.__session.retries = numRetries
Expand Down