Skip to content

Commit

Permalink
BUGFIX: templates are now given to swate as binary again
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerskk committed Feb 2, 2024
1 parent d9048ad commit 2ecda83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions app/github/github_api.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import requests
import os


class GithubAPI:
def __init__(self, repository_name):
self.repository_name = repository_name
# self.branch = branch

# GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN", "")
#
# if GITHUB_TOKEN is not "":
# self.auth_token = GITHUB_TOKEN
# else:
# self.auth_token = ""
#
# self.headers = {'Authorization': 'token ' + self.auth_token,
# 'Accept': 'application/vnd.github.v3.raw'
# }
self.auth_token = os.environ.get("GITHUB_TOKEN", "")
# GITHUB_TOKEN = ""

self.headers = {'Authorization': 'token ' + self.auth_token,
'Accept': 'application/vnd.github.v3.raw'
}

def get_master_tree(self, branch):
# headers = {'Authorization': 'token ' + self.auth_token,
Expand All @@ -30,7 +27,8 @@ def get_master_tree(self, branch):
# }

try:
response = requests.get(url)
print(self.headers)
response = requests.get(url, self.headers)
response.raise_for_status()
except requests.exceptions.HTTPError as err:
print("status code: ", response.status_code)
Expand All @@ -56,12 +54,14 @@ def convert_to_raw_url(self, file_name, branch):

if __name__ == "__main__":

github_api = GithubAPI("nfdi4plants/nfdi4plants_ontology")
# github_api = GithubAPI("nfdi4plants/nfdi4plants_ontology")
github_api = GithubAPI("nfdi4plants/Swate-templates")

tree = github_api.get_master_tree("main").get("tree")

print("tree", tree)


for file in tree:
print("file: ",file)
print("file: ", file)
print(github_api.convert_to_raw_url(file.get("path"), "main"))
6 changes: 3 additions & 3 deletions app/tasks/template_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ def template_build_from_scratch():

for file in files:
result = requests.get(file)
data = json.loads(result.content)
decoded_content = base64.b64decode(data["content"])
# data = json.loads(result.content)
# decoded_content = base64.b64decode(data["content"])

swate_api = SwateAPI()
converted_json = swate_api.convert_xslx(decoded_content)
converted_json = swate_api.convert_xslx(result.content)

print("conv_json", converted_json)
# data_list.append(converted_json)
Expand Down

0 comments on commit 2ecda83

Please sign in to comment.