Skip to content

Commit afc5a98

Browse files
author
Josef-MrBeam
committed
prepare for github release patcher plugin
1 parent d855231 commit afc5a98

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

octoprint_mrbeam/software_update_information.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from octoprint_mrbeam.mrb_logger import mrb_logger
1919
from octoprint_mrbeam.util import dict_merge, logExceptions
20-
from octoprint_mrbeam.util.github_api import get_file_of_repo_for_tag
20+
from octoprint_mrbeam.util.github_api import get_file_of_repo_for_tag, REPO_URL
2121
from util.pip_util import get_version_of_pip_module
2222

2323

@@ -96,7 +96,8 @@ def get_tag_of_github_repo(repo):
9696
import json
9797

9898
try:
99-
url = "https://api.github.com/repos/mrbeam/{repo}/tags".format(repo=repo)
99+
url = "{repo_url}/tags".format(repo_url=REPO_URL.format(repo=repo))
100+
100101
headers = {
101102
"Accept": "application/json",
102103
}

octoprint_mrbeam/util/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import threading
1111

1212
from .log import logExceptions, logtime, logme
13+
from . import github_api
1314

1415
if sys.version_info >= (3,):
1516
_basestring = str

octoprint_mrbeam/util/github_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import json
1313

1414
_logger = mrb_logger("octoprint.plugins.mrbeam.util.github_api")
15-
15+
REPO_URL = "https://api.github.com/repos/mrbeam/{repo}"
1616

1717
def get_file_of_repo_for_tag(file, repo, tag):
1818
"""
@@ -27,8 +27,8 @@ def get_file_of_repo_for_tag(file, repo, tag):
2727
content of file
2828
"""
2929
try:
30-
url = "https://api.github.com/repos/mrbeam/{repo}/contents/{file}?ref={tag}".format(
31-
repo=repo, file=file, tag=tag
30+
url = "{repo_url}/contents/{file}?ref={tag}".format(
31+
repo_url=REPO_URL.format(repo=repo), file=file, tag=tag
3232
)
3333

3434
headers = {
@@ -46,7 +46,7 @@ def get_file_of_repo_for_tag(file, repo, tag):
4646
_logger.warning("timeout while trying to get the file")
4747
return None
4848
except ConnectionError:
49-
_logger.warning("connection error while trying to get the file")
49+
_logger.warning("connection error while trying to get the file {}".format(url))
5050
return None
5151

5252
if response:

0 commit comments

Comments
 (0)