Skip to content

Commit b980105

Browse files
author
Othman Moumni Abdou
committed
add global request timeout
1 parent 49f9662 commit b980105

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127
# MacOS
128128
.DS_Store
129129

130+
# PyCharm
131+
.idea
132+

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## History
22

3+
### 0.2.1
4+
5+
- Add global request timeout
6+
37
### 0.2.0
48

59
- Add support for m2web api

pydatamailbox/client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313

1414
class EwonClient(object):
15-
def __init__(self, account, username, password):
15+
def __init__(self, account, username, password, timeout=None):
1616
self.account = account
1717
self.username = username
1818
self.password = password
19+
self.timeout = timeout
1920
self.data = {
2021
"t2maccount": account,
2122
"t2musername": username,
@@ -34,7 +35,7 @@ def _build_url(self, url):
3435

3536
def _request(self, url, data, check_success=True):
3637
try:
37-
response = self.session.post(url=url, data=data)
38+
response = self.session.post(url=url, data=data, timeout=self.timeout)
3839
except requests.exceptions.ConnectionError as e: # pragma: nocover
3940
raise DataMailboxConnectionError(str(e)) # pragma: nocover
4041
if response.status_code != 200:
@@ -62,8 +63,8 @@ class DataMailbox(EwonClient):
6263
This client only supports: getstatus, getewons, getewon, syncdata
6364
"""
6465

65-
def __init__(self, account, username, password, devid):
66-
super().__init__(account, username, password)
66+
def __init__(self, account, username, password, devid, timeout=None):
67+
super().__init__(account, username, password, timeout)
6768
self.data["t2mdevid"] = devid
6869
self.base_url = "https://data.talk2m.com/"
6970

@@ -151,8 +152,8 @@ class M2Web(EwonClient):
151152
This client only supports: getaccountinfo, getewons, getewon
152153
"""
153154

154-
def __init__(self, account, username, password, devid):
155-
super().__init__(account, username, password)
155+
def __init__(self, account, username, password, devid, timeout=None):
156+
super().__init__(account, username, password, timeout)
156157
self.data["t2mdeveloperid"] = devid
157158
self.base_url = "https://m2web.talk2m.com/t2mapi/"
158159

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"Programming Language :: Python :: 3.6",
3030
"Programming Language :: Python :: 3.7",
3131
],
32-
description="Unoffical client for the Ewon's datamailbox web APIs",
32+
description="Unofficial client for the Ewon's datamailbox web APIs",
3333
install_requires=requirements,
3434
license="MIT license",
3535
long_description=readme + "\n\n" + history,
@@ -42,6 +42,6 @@
4242
test_suite="tests",
4343
tests_require=test_requirements,
4444
url="https://github.com/optimdata/pydatamailbox",
45-
version="0.2.0",
45+
version="0.2.1",
4646
zip_safe=False,
4747
)

0 commit comments

Comments
 (0)