Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-getlists
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gn4-3-wp9-t2
gitlab-getlists
Merge requests
!2
Master
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Master
master
into
main
Overview
0
Commits
6
Pipelines
0
Changes
1
Closed
Tomasz Kaźmierczak
requested to merge
master
into
main
2 years ago
Overview
0
Commits
6
Pipelines
0
Changes
1
Expand
Production Ready
0
0
Merge request reports
Viewing commit
80c532fd
Prev
Next
Show latest version
1 file
+
40
−
32
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
80c532fd
poprawka w przypadku, gdy brak repozytorium w projekcie
· 80c532fd
kazix
authored
2 years ago
main.py
+
40
−
32
Options
@@ -7,47 +7,55 @@ from json2html import *
# pobieranie listy projektów
# testowe
headers
=
{
'
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_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'
# headers = {'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_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
)
# 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_branch
=
'
repository/branches
'
projects
=
gl
.
projects
.
list
(
all
=
True
)
j_project
=
{}
j_project
[
'
projects
'
]
=
{}
for
project
in
projects
:
#
print('Project ID: ', project.attributes['id'])
#
print('Project Name: ', project.attributes['name_with_namespace'])
print
(
'
Project ID:
'
,
project
.
attributes
[
'
id
'
])
print
(
'
Project Name:
'
,
project
.
attributes
[
'
name_with_namespace
'
])
# print('branch', project.attributes['default_branch'])
# print('status', project.attributes['visibility'])
# print('aktywny', project.attributes['last_activity_at'])
# print('grupa', project.attributes['namespace']['name'])
branch
=
project
.
attributes
[
'
default_branch
'
]
print
(
'
status
'
,
project
.
attributes
[
'
visibility
'
])
print
(
'
aktywny
'
,
project
.
attributes
[
'
last_activity_at
'
])
print
(
'
grupa
'
,
project
.
attributes
[
'
namespace
'
][
'
name
'
])
x
=
project
.
attributes
[
'
id
'
]
c_link
=
gl_proj
+
'
/
'
+
str
(
x
)
+
'
/
'
+
gl_license
+
branch
c_response
=
requests
.
get
(
c_link
,
headers
=
headers
)
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
'
]
check_b
=
gl_proj
+
'
/
'
+
str
(
x
)
check_b_response
=
requests
.
get
(
check_b
,
headers
=
headers
)
check_b_data
=
check_b_response
.
text
check_b_answer
=
json
.
loads
(
check_b_data
)
if
"
default_branch
"
in
check_b_answer
:
branch
=
project
.
attributes
[
'
default_branch
'
]
# x = project.attributes['id']
c_link
=
gl_proj
+
'
/
'
+
str
(
x
)
+
'
/
'
+
gl_license
+
branch
c_response
=
requests
.
get
(
c_link
,
headers
=
headers
)
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
'
full_act
=
project
.
attributes
[
'
last_activity_at
'
]
last_act
=
full_act
.
split
(
sep
,
1
)[
0
]
Loading