Skip to content
Snippets Groups Projects
Commit 80c532fd authored by kazix's avatar kazix
Browse files

poprawka w przypadku, gdy brak repozytorium w projekcie

parent 8b5ced6b
No related branches found
No related tags found
3 merge requests!3Master to Main,!2Master,!1Master
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -7,47 +7,55 @@ from json2html import * ...@@ -7,47 +7,55 @@ from json2html import *
# pobieranie listy projektów # pobieranie listy projektów
# testowe # testowe
headers = {'PRIVATE-TOKEN': 'glpat-hQFB1vBzz9rQzq8wuhcG'} # headers = {'PRIVATE-TOKEN': 'glpat-hQFB1vBzz9rQzq8wuhcG'}
gl = gitlab.Gitlab(url='https://k8s-gitlab.software.geant.org', private_token='glpat-hQFB1vBzz9rQzq8wuhcG') # gl = gitlab.Gitlab(url='https://k8s-gitlab.software.geant.org', private_token='glpat-hQFB1vBzz9rQzq8wuhcG')
gl_user = 'https://k8s-gitlab.software.geant.org/api/v4/users' # gl_user = 'https://k8s-gitlab.software.geant.org/api/v4/users'
gl_proj = 'https://k8s-gitlab.software.geant.org/api/v4/projects' # gl_proj = 'https://k8s-gitlab.software.geant.org/api/v4/projects'
gl_license = 'repository/files/LICENSE?ref='
gl_branch = 'repository/branches'
projects = gl.projects.list()
# (all=True)
# # produkcyjne
# headers = {'PRIVATE-TOKEN': 'glpat-P6orz6-t2f3n1BoVDrnr'}
# gl = gitlab.Gitlab(url='https://gitlab.geant.org', private_token='glpat-P6orz6-t2f3n1BoVDrnr')
# gl_user = 'https://gitlab.geant.org/api/v4/users'
# gl_proj = 'https://gitlab.geant.org/api/v4/projects'
# gl_license = 'repository/files/LICENSE?ref=' # gl_license = 'repository/files/LICENSE?ref='
# gl_branch = 'repository/branches' # gl_branch = 'repository/branches'
# projects = gl.projects.list(all=True) # projects = gl.projects.list()
# (all=True) # (all=True)
# produkcyjne
headers = {'PRIVATE-TOKEN': 'glpat-P6orz6-t2f3n1BoVDrnr'}
gl = gitlab.Gitlab(url='https://gitlab.geant.org', private_token='glpat-P6orz6-t2f3n1BoVDrnr')
gl_user = 'https://gitlab.geant.org/api/v4/users'
gl_proj = 'https://gitlab.geant.org/api/v4/projects'
gl_license = 'repository/files/LICENSE?ref='
gl_branch = 'repository/branches'
projects = gl.projects.list(all=True)
j_project = {} j_project = {}
j_project['projects'] = {} j_project['projects'] = {}
for project in projects: for project in projects:
# print('Project ID: ', project.attributes['id']) print('Project ID: ', project.attributes['id'])
# print('Project Name: ', project.attributes['name_with_namespace']) print('Project Name: ', project.attributes['name_with_namespace'])
# print('branch', project.attributes['default_branch']) # print('branch', project.attributes['default_branch'])
# print('status', project.attributes['visibility']) print('status', project.attributes['visibility'])
# print('aktywny', project.attributes['last_activity_at']) print('aktywny', project.attributes['last_activity_at'])
# print('grupa', project.attributes['namespace']['name']) print('grupa', project.attributes['namespace']['name'])
branch = project.attributes['default_branch']
x = project.attributes['id'] x = project.attributes['id']
c_link = gl_proj + '/' + str(x) + '/' + gl_license + branch check_b = gl_proj + '/' + str(x)
c_response = requests.get(c_link, headers=headers) check_b_response = requests.get(check_b, headers=headers)
c_data = c_response.text check_b_data = check_b_response.text
c_answer = json.loads(c_data) check_b_answer = json.loads(check_b_data)
if "message" in c_answer: if "default_branch" in check_b_answer:
print("License file: ", c_answer['message']) branch = project.attributes['default_branch']
lic = c_answer['message'] # x = project.attributes['id']
if "file_name" in c_answer: c_link = gl_proj + '/' + str(x) + '/' + gl_license + branch
print("License file: ", c_answer['file_name']) c_response = requests.get(c_link, headers=headers)
lic = c_answer['file_name'] c_data = c_response.text
c_answer = json.loads(c_data)
if "message" in c_answer:
print("License file: ", c_answer['message'])
lic = c_answer['message']
if "file_name" in c_answer:
print("License file: ", c_answer['file_name'])
lic = c_answer['file_name']
print('branch', project.attributes['default_branch'])
else:
lic = 'No created repository'
sep = 'T' sep = 'T'
full_act = project.attributes['last_activity_at'] full_act = project.attributes['last_activity_at']
last_act = full_act.split(sep, 1)[0] last_act = full_act.split(sep, 1)[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment