Skip to content

Commit

Permalink
linted code
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Chen1 committed Feb 16, 2024
1 parent 37698b0 commit 20ed3db
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 19 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@
# Placeholder for scripts
# "bin/script.py",
],

)
1 change: 0 additions & 1 deletion swan/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# ./swan/api/__init__.py

19 changes: 12 additions & 7 deletions swan/api/swan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

from swan.api_client import APIClient
from swan.common.constant import (
GET,
POST,
CP_MACHINES,
PROVIDER_PAYMENTS,
TASKS,
GET,
POST,
CP_MACHINES,
PROVIDER_PAYMENTS,
TASKS,
DEPLOY_STATUS,
USER_PROVIDER_PAYMENTS
USER_PROVIDER_PAYMENTS,
)


class SwanAPI(APIClient):

def __init__(self, orchestrator_url, api_key, payment_key):
Expand Down Expand Up @@ -81,7 +82,11 @@ def make_payment(self):
)
payment_info["payment_key"] = self.payment_key
result = self._request_with_params(
POST, USER_PROVIDER_PAYMENTS, self.orchestrator_url, payment_info, self.token
POST,
USER_PROVIDER_PAYMENTS,
self.orchestrator_url,
payment_info,
self.token,
)
return result
except:
Expand Down
2 changes: 1 addition & 1 deletion swan/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# ./swan/common/__init__.py
# ./swan/common/__init__.py
2 changes: 1 addition & 1 deletion swan/common/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
FILTER_CP_BY_NAME = "/cp/filter/<string:serach_string>"
GET_CP_DETAILS = "/cp/details/<string:node_id>"
UPDATE_JOB_STATUS = "/job/status"
SPACE_CP_DETAIL = "/cp/<string:node_id>/<string:task_uuid>"
SPACE_CP_DETAIL = "/cp/<string:node_id>/<string:space_uuid>"
COLLATERAL_BALANCE = "/cp/collateral/<string:cp_address>"
EXTEND_JOBS = "/cp/extend_task"
CHECK_FROZEN_COLLATERAL = "/check_holding_collateral/<string:wallet_address>"
Expand Down
7 changes: 5 additions & 2 deletions swan/common/exception.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# ./swan/common/exception.py


class SwanAPIException(Exception):
pass


class SwanRequestException(Exception):
pass



class SwanParamsException(Exception):
pass
pass
2 changes: 1 addition & 1 deletion swan/common/params.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# ./swan/common/params.py
# ./swan/common/params.py
13 changes: 8 additions & 5 deletions swan/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# ./swan/common/utils.py
import requests


def parse_params_to_str(params):
url = '?'
url = "?"
for key, value in params.items():
url = url + str(key) + '=' + str(value) + '&'
url = url + str(key) + "=" + str(value) + "&"
return url[0:-1]


def list_repo_contents(user, repo):
"""
Lists the contents of a GitHub repository.
Expand All @@ -18,11 +20,12 @@ def list_repo_contents(user, repo):
Returns:
list: A list of dictionaries representing the files in the repository.
"""
url = f'https://api.github.com/repos/{user}/{repo}/contents'
url = f"https://api.github.com/repos/{user}/{repo}/contents"
response = requests.get(url)
response.raise_for_status()
response.raise_for_status()
return response.json()


def read_file_from_url(url):
"""
Reads a file from a URL.
Expand All @@ -34,5 +37,5 @@ def read_file_from_url(url):
str: The content of the file.
"""
response = requests.get(url)
response.raise_for_status()
response.raise_for_status()
return response.text

0 comments on commit 20ed3db

Please sign in to comment.