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
Commits
a692ba29
Commit
a692ba29
authored
2 years ago
by
kazix
Browse files
Options
Downloads
Patches
Plain Diff
clean main.py before last commit
parent
702b86fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+10
-31
10 additions, 31 deletions
main.py
with
10 additions
and
31 deletions
main.py
+
10
−
31
View file @
a692ba29
...
@@ -18,7 +18,7 @@ load_dotenv()
...
@@ -18,7 +18,7 @@ load_dotenv()
try
:
try
:
if
args
.
production
:
if
args
.
production
:
token
=
os
.
getenv
(
'
PRODUCTION_TOKEN
'
)
token
=
os
.
getenv
(
'
PRODUCTION_TOKEN
'
)
print
(
'
p
rodu
kcyjny
'
)
print
(
'
P
rodu
ction Mode, connect to server
'
)
headers
=
{
'
PRIVATE-TOKEN
'
:
token
}
headers
=
{
'
PRIVATE-TOKEN
'
:
token
}
gl
=
gitlab
.
Gitlab
(
url
=
'
https://gitlab.geant.org
'
,
private_token
=
token
)
gl
=
gitlab
.
Gitlab
(
url
=
'
https://gitlab.geant.org
'
,
private_token
=
token
)
gl_user
=
'
https://gitlab.geant.org/api/v4/users
'
gl_user
=
'
https://gitlab.geant.org/api/v4/users
'
...
@@ -28,7 +28,7 @@ try:
...
@@ -28,7 +28,7 @@ try:
projects
=
gl
.
projects
.
list
(
all
=
True
)
projects
=
gl
.
projects
.
list
(
all
=
True
)
elif
args
.
developer
:
elif
args
.
developer
:
token
=
os
.
getenv
(
'
DEVELOPER_TOKEN
'
)
token
=
os
.
getenv
(
'
DEVELOPER_TOKEN
'
)
print
(
'
testowy
'
)
print
(
'
Production Mode, connect to server
'
)
headers
=
{
'
PRIVATE-TOKEN
'
:
token
}
headers
=
{
'
PRIVATE-TOKEN
'
:
token
}
gl
=
gitlab
.
Gitlab
(
url
=
'
https://k8s-gitlab.software.geant.org
'
,
private_token
=
token
)
gl
=
gitlab
.
Gitlab
(
url
=
'
https://k8s-gitlab.software.geant.org
'
,
private_token
=
token
)
gl_user
=
'
https://k8s-gitlab.software.geant.org/api/v4/users
'
gl_user
=
'
https://k8s-gitlab.software.geant.org/api/v4/users
'
...
@@ -37,38 +37,16 @@ try:
...
@@ -37,38 +37,16 @@ try:
gl_branch
=
'
repository/branches
'
gl_branch
=
'
repository/branches
'
projects
=
gl
.
projects
.
list
(
all
=
True
)
projects
=
gl
.
projects
.
list
(
all
=
True
)
else
:
else
:
print
(
"
No variable,
exit
"
)
print
(
"
--production or --developer, please, now
exit
"
)
exit
()
exit
()
# 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'
# 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('
s
tatus', project.attributes['visibility'])
print
(
'
S
tatus
:
'
,
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'])
x
=
project
.
attributes
[
'
id
'
]
x
=
project
.
attributes
[
'
id
'
]
...
@@ -84,10 +62,10 @@ try:
...
@@ -84,10 +62,10 @@ try:
c_data
=
c_response
.
text
c_data
=
c_response
.
text
c_answer
=
json
.
loads
(
c_data
)
c_answer
=
json
.
loads
(
c_data
)
if
"
message
"
in
c_answer
:
if
"
message
"
in
c_answer
:
#
print("License file: ", c_answer['message'])
print
(
"
License file:
"
,
c_answer
[
'
message
'
])
lic
=
c_answer
[
'
message
'
]
lic
=
c_answer
[
'
message
'
]
if
"
file_name
"
in
c_answer
:
if
"
file_name
"
in
c_answer
:
#
print("License file: ", c_answer['file_name'])
print
(
"
License file:
"
,
c_answer
[
'
file_name
'
])
lic
=
c_answer
[
'
file_name
'
]
lic
=
c_answer
[
'
file_name
'
]
# print('branch', project.attributes['default_branch'])
# print('branch', project.attributes['default_branch'])
else
:
else
:
...
@@ -95,7 +73,6 @@ try:
...
@@ -95,7 +73,6 @@ try:
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
]
# print("ostatnia aktywnosc: ", last_act)
tmp
=
{
tmp
=
{
'
project_id
'
:
project
.
attributes
[
'
id
'
],
'
project_id
'
:
project
.
attributes
[
'
id
'
],
'
project_name
'
:
project
.
attributes
[
'
name_with_namespace
'
],
'
project_name
'
:
project
.
attributes
[
'
name_with_namespace
'
],
...
@@ -134,7 +111,7 @@ try:
...
@@ -134,7 +111,7 @@ try:
'
owner_mail_commit
'
:
user
.
commit_email
'
owner_mail_commit
'
:
user
.
commit_email
}
}
j_project
[
'
projects
'
][
x
][
'
owners
'
][
y
]
=
user_tmp
j_project
[
'
projects
'
][
x
][
'
owners
'
][
y
]
=
user_tmp
#
print(8*"-")
print
(
8
*
"
-
"
)
except
:
except
:
print
(
'
Cant connect to GitLab server, check credential
'
)
print
(
'
Cant connect to GitLab server, check credential
'
)
exit
()
exit
()
...
@@ -150,3 +127,5 @@ new_jproject_html = json2html.convert(json=new_jproject)
...
@@ -150,3 +127,5 @@ new_jproject_html = json2html.convert(json=new_jproject)
with
open
(
"
gitlab-projects.html
"
,
"
w
"
,
encoding
=
'
utf8
'
)
as
outfile
:
with
open
(
"
gitlab-projects.html
"
,
"
w
"
,
encoding
=
'
utf8
'
)
as
outfile
:
outfile
.
write
(
new_jproject_html
)
outfile
.
write
(
new_jproject_html
)
print
(
"
This is the end...
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment