Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 24, 2024
1 parent b5d0db5 commit 6a9215a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions jenkinsapi/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_plugins_url(self, depth):
# This only ever needs to work on the base object
return f"{self.baseurl}/pluginManager/api/python?depth={depth}"

def get_update_center_url(self, depth = 1):
def get_update_center_url(self, depth=1):
return f"{self.baseurl}/manage/updateCenter/api/json?depth={depth}"

def install_plugin(
Expand Down Expand Up @@ -651,7 +651,10 @@ def get_plugins(self, depth: int = 1) -> Plugins:
url = self.get_plugins_url(depth=depth)
# If the plugins object is not already created or the baseurl has changed
# the we recreate a new one
if not hasattr(self, '_get_plugins') or self._get_plugins.baseurl != url:
if (
not hasattr(self, "_get_plugins")
or self._get_plugins.baseurl != url
):
self._get_plugins = Plugins(url, self)
return self._get_plugins

Expand Down
3 changes: 2 additions & 1 deletion jenkinsapi/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def upload_config(self, config_xml: str) -> None:
raise JenkinsAPIException("Built-In node does not have config.xml")

self.jenkins.requester.post_xml_and_confirm_status(
"%(baseurl)s/config.xml" % self.__dict__, data=config_xml)
"%(baseurl)s/config.xml" % self.__dict__, data=config_xml
)

def get_labels(self) -> str | None:
"""
Expand Down
12 changes: 8 additions & 4 deletions jenkinsapi/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ def check_updates_server(self) -> None:

@property
def update_center_dict(self):
if not hasattr(self, '_update_center_dict'):
update_center = "https://updates.jenkins.io/update-center.actual.json"
if not hasattr(self, "_update_center_dict"):
update_center = (
"https://updates.jenkins.io/update-center.actual.json"
)
jsonp = requests.get(update_center).content.decode("utf-8")
self._update_center_dict = json.loads(jsonp)
return self._update_center_dict

@property
def update_center_dict_server(self):
if not hasattr(self, '_update_center_dict_server'):
jsonp = self.jenkins_obj.requester.get_url(self.jenkins_obj.get_update_center_url(2)).content.decode("utf-8")
if not hasattr(self, "_update_center_dict_server"):
jsonp = self.jenkins_obj.requester.get_url(
self.jenkins_obj.get_update_center_url(2)
).content.decode("utf-8")
self._update_center_dict_server = json.loads(jsonp)
return self._update_center_dict_server

Expand Down

0 comments on commit 6a9215a

Please sign in to comment.