Skip to content

Commit

Permalink
black applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ypriverol committed Sep 25, 2024
1 parent bf5d73e commit b2753ed
Show file tree
Hide file tree
Showing 12 changed files with 610 additions and 242 deletions.
18 changes: 14 additions & 4 deletions authentication/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ def get_token(self, username, password):

# get token to access the api
url = self.base_url + "getAAPToken"
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
credentials = "{\"Credentials\":{\"username\":\"" + username + "\", \"password\":\"" + password + "\"}}"
headers = {"Content-type": "application/json", "Accept": "text/plain"}
credentials = (
'{"Credentials":{"username":"'
+ username
+ '", "password":"'
+ password
+ '"}}'
)

response = requests.post(url, data=credentials, headers=headers)

Expand All @@ -44,8 +50,12 @@ def validate_token(self, token):
:return: Return True if the token is valid and not expired: Otherwise returns False
"""
url = self.base_url + "token-validation"
headers = {'Authorization': 'Bearer ' + token}
headers = {"Authorization": "Bearer " + token}

response = requests.post(url, headers=headers)

return response.ok and response.status_code == 200 and response.text == 'Token Valid'
return (
response.ok
and response.status_code == 200
and response.text == "Token Valid"
)
212 changes: 140 additions & 72 deletions files/files.py

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions msrun/msrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ def update_msrun_metadata(self, filename, token):
"""

# get project file accession from the prefix of the file name (e.g: PXF00000145820)
accession = filename.split('-', 1)[0]
accession = filename.split("-", 1)[0]

url = self.base_url + "msruns/" + accession + "/updateMetadata"
headers = {'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer ' + token}
headers = {
"Content-type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer " + token,
}

with open(filename) as json_file:
data = json.load(json_file)
Expand Down
Loading

0 comments on commit b2753ed

Please sign in to comment.