Skip to content

Commit

Permalink
Merge pull request #3 from tobyp/master
Browse files Browse the repository at this point in the history
Expose timeout setting in Session.
  • Loading branch information
not-na committed Feb 25, 2020
2 parents a36d63e + 4a507c0 commit 0d6dc1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fritzctl/session.py
Expand Up @@ -152,6 +152,7 @@ class Session(object):
:param str pwd: Optional Password for authentification
:param int port: Port to use when connecting, defaults to ``49000``
:param bool authcheck: If the credentials should be checked, simply requests the ``general_deviceinfo`` API.
:param float timeout: Timeout for requests
Instance Variables:
Expand All @@ -161,14 +162,15 @@ class Session(object):
:ivar device: :py:class:`simpletr64.DeviceTR64()` Instance used for managing authentification
:ivar urns: List of URNs found on the server, can be used for debugging
"""
def __init__(self,server=None,user=None,pwd=None,port=49000,authcheck=True):
def __init__(self, server=None, user=None, pwd=None, port=49000, authcheck=True, timeout=2.0):
if server is None:
raise NotImplementedError("Server search is currently not implemented")
else:
self.server = server

self.user = user if user is not None else ""
self.pwd = pwd if pwd is not None else ""
self.timeout = timeout
self.device = simpletr64.DeviceTR64(server,port=port)
self.device.username = self.user
self.device.password = self.pwd
Expand Down Expand Up @@ -227,4 +229,6 @@ def execute(self,*args,**kwargs):
This method simply passes through all parameters to the internal :py:class:`simpletr64.DeviceTR64()` instance.
"""
if 'timeout' not in kwargs:
kwargs['timeout'] = self.timeout
return self.device.execute(*args,**kwargs)

0 comments on commit 0d6dc1d

Please sign in to comment.