Skip to content
Snippets Groups Projects
Commit 97f3b761 authored by George Marchment's avatar George Marchment
Browse files

updated github api request with authentication

parent fde3727c
No related branches found
No related tags found
No related merge requests found
Pipeline #13874 passed with stage
in 1 minute and 4 seconds
......@@ -45,7 +45,8 @@ class Workflow:
license = None, creativeWorkStatus = None, authors = None,
version = None, keywords = None, producer = None,
publisher = None, processes_2_remove = None,
processes_annotation = None):
processes_annotation = None,
personnal_acces_token = None):
if(not os.path.isfile(file)):
nextflow_files = glob.glob(f'{file}/*.nf')
......@@ -54,7 +55,7 @@ class Workflow:
try:
file = '/'.join(nextflow_files[0].split('/')[:-1])+"/main.nf"
with open(file, 'r') as f:
txt= f.read()
txt= f.read()
except:
file =nextflow_files[0]
......@@ -80,6 +81,7 @@ class Workflow:
self.keywords = keywords
self.producer = producer
self.publisher = publisher
self.personnal_acces_token = personnal_acces_token
if(processes_2_remove==""):
processes_2_remove = None
self.processes_2_remove = processes_2_remove
......@@ -172,7 +174,11 @@ class Workflow:
current_directory = os.getcwd()
os.chdir(self.get_repo_adress())
try:
_ = os.system(f"wget -qO - https://api.github.com/repos/{self.address} > temp_dico_{id(self)}.json")
if(self.personnal_acces_token!=None):
command = f'curl --silent --request GET --url "https://api.github.com/repos/{self.address}" --header "Authorization: Bearer {self.personnal_acces_token}" --header "X-GitHub-Api-Version: 2022-11-28" > temp_dico_{id(self)}.json'
else:
command = f'curl --silent --request GET --url "https://api.github.com/repos/{self.address}" > temp_dico_{id(self)}.json'
_ = os.system(command)
with open(f'temp_dico_{id(self)}.json') as json_file:
self.dico = json.load(json_file)
os.system(f"rm temp_dico_{id(self)}.json")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment