Skip to content

Commit

Permalink
Merge pull request #29 from chizmw/remote-json-fetch-fixes
Browse files Browse the repository at this point in the history
Remote json fetch fixes
  • Loading branch information
chizmw authored Apr 17, 2023
2 parents 4cc455a + a68949c commit 604c178
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/Fixed-20230418-003009.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Fixed
body: add timeout to requests.get()
time: 2023-04-18T00:30:09.690116+01:00
custom:
GithubIssue: ""
5 changes: 5 additions & 0 deletions .changes/unreleased/Fixed-20230418-003058.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Fixed
body: exit(…) -> sys.exit(…)
time: 2023-04-18T00:30:58.196572+01:00
custom:
GithubIssue: ""
2 changes: 1 addition & 1 deletion botcpdf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():
# if we don't have any args, exit with an error
if len(sys.argv) == 1:
print("Usage: botcpdf <scriptname>|<scriptjsonurl>")
exit(1)
sys.exit(1)

# if our first arg starts with http, assume it's a URL
if sys.argv[1].startswith("http"):
Expand Down
5 changes: 3 additions & 2 deletions botcpdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import shutil
import sys
import os
import requests # type: ignore
import requests # type: ignore
from pdf2image import convert_from_path


def fetch_remote_data(url: str):
"""Fetch data from a remote URL."""

response = requests.get(url)
response = requests.get(url, timeout=10, allow_redirects=True)
response.raise_for_status()
return response.json()

Expand Down

0 comments on commit 604c178

Please sign in to comment.