Skip to content

Commit d7058be

Browse files
committed
REQUEST_TIMEOUT variable now lives as env variable
1 parent ef333c2 commit d7058be

9 files changed

Lines changed: 27 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ dmypy.json
138138
.secrets/
139139
.bugout/
140140
test/
141+
dev.env

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# bugout-python
22
Python client library for Bugout API
33

4+
## Setup
5+
- Add variables from `sample.env` in you development environment
6+
```bash
7+
export BUGOUT_REQUESTS_TIMEOUT=5
8+
```
9+
410
```python
511
from bugout.app import Bugout
612

bugout/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import uuid
33

44
from . import data
5-
from .calls import ping, REQUESTS_TIMEOUT
5+
from .calls import ping
66
from .group import Group
77
from .journal import Journal
88
from .user import User
9+
from .settings import REQUESTS_TIMEOUT
910

1011

1112
class InvalidParameters(ValueError):

bugout/calls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from .data import Method
66

7-
REQUESTS_TIMEOUT = 5
8-
97

108
class InvalidUrlSpec(ValueError):
119
"""

bugout/group.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Dict, Optional, Union
22
import uuid
33

4-
from .calls import make_request, InvalidUrlSpec, REQUESTS_TIMEOUT
4+
from .calls import make_request, InvalidUrlSpec
55
from .data import (
66
Method,
77
Role,
@@ -10,6 +10,7 @@
1010
BugoutGroupMembers,
1111
BugoutUserGroups,
1212
)
13+
from .settings import REQUESTS_TIMEOUT
1314

1415

1516
class GroupInvalidParameters(ValueError):

bugout/journal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Dict, List, Optional, Union
22
import uuid
33

4-
from .calls import make_request, InvalidUrlSpec, REQUESTS_TIMEOUT
4+
from .calls import make_request, InvalidUrlSpec
55
from .data import (
66
BugoutJournal,
77
BugoutJournals,
@@ -16,6 +16,7 @@
1616
HolderType,
1717
Method,
1818
)
19+
from .settings import REQUESTS_TIMEOUT
1920

2021

2122
class Journal:

bugout/settings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
REQUESTS_TIMEOUT = 5
4+
REQUESTS_TIMEOUT_RAW = os.environ.get("BUGOUT_REQUESTS_TIMEOUT")
5+
try:
6+
if REQUESTS_TIMEOUT_RAW is not None:
7+
REQUESTS_TIMEOUT = int(REQUESTS_TIMEOUT_RAW)
8+
except:
9+
raise Exception(
10+
f"Could not parse BUGOUT_REQUESTS_TIMEOUT environment variable as int: {REQUESTS_TIMEOUT_RAW}"
11+
)

bugout/user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Any, Dict, List, Optional, Union
22
import uuid
33

4-
from .calls import make_request, InvalidUrlSpec, REQUESTS_TIMEOUT
4+
from .calls import make_request, InvalidUrlSpec
55
from .data import Method, TokenType, BugoutUser, BugoutToken, BugoutUserTokens
6+
from .settings import REQUESTS_TIMEOUT
67

78

89
class TokenInvalidParameters(ValueError):

sample.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export BUGOUT_REQUESTS_TIMEOUT=5

0 commit comments

Comments
 (0)