Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
Update fetch-machine-readable_salsa.py
· 2de439e7
Julien Cristau
authored
Aug 16, 2018
2de439e7
Merge branch 'patch-1' into 'master'
· 26071ecd
Andreas Tille
authored
Aug 16, 2018
Update fetch-machine-readable_salsa.py See merge request
!2
26071ecd
Show whitespace changes
Inline
Side-by-side
misc/machine_readable/fetch-machine-readable_salsa.py
View file @
26071ecd
...
...
@@ -84,7 +84,7 @@ def get_blends_groups():
groups
=
gl
.
groups
.
list
(
all
=
True
,
order_by
=
'
name
'
,
sort
=
'
asc
'
)
for
group
in
groups
:
# print(group.attributes['name'])
if
group
.
attributes
[
'
name
'
]
in
BLENDSGROUPS
:
if
group
.
name
in
BLENDSGROUPS
:
blends_groups
.
append
(
group
)
return
blends_groups
...
...
@@ -126,19 +126,13 @@ blends_groups = get_blends_groups()
for
group
in
blends_groups
:
unchanged
,
changed
,
new
,
ignored
=
(
0
,
0
,
0
,
0
)
gpath
=
group
.
attributes
[
'
path
'
]
blend
=
BLENDSGROUPS
[
group
.
attributes
[
'
name
'
]
]
blend
=
BLENDSGROUPS
[
group
.
name
]
projects
=
group
.
projects
.
list
(
all
=
True
,
order_by
=
'
name
'
,
sort
=
'
asc
'
)
# DEBUG : only few projects to be faster
# projects = group.projects.list(page=1, per_page=10, order_by='name', sort='asc')
print
(
"
%s has %i projects (Blend name %s)
"
%
(
group
.
attributes
[
'
name
'
],
len
(
projects
),
blend
))
# group.attributes['id'], group.attributes['path']) # , group.attributes['description'], group.attributes['full_name'])
for
pr
in
projects
:
try
:
project
=
gl
.
projects
.
get
(
pr
.
attributes
[
'
id
'
])
# without this extra get repository_tree() fails
except
gitlab
.
exceptions
.
GitlabGetError
:
wait_for_salsa
()
project
=
gl
.
projects
.
get
(
pr
.
attributes
[
'
id
'
])
# without this extra get repository_tree() fails
name
=
project
.
attributes
[
'
name
'
]
time
.
sleep
(
SLEEPTIMEPROJECTS
)
print
(
"
%s has %i projects (Blend name %s)
"
%
(
group
.
name
,
len
(
projects
),
blend
))
# group.attributes['id'], group.attributes['path']) # , group.attributes['description'], group.attributes['full_name'])
for
project
in
projects
:
name
=
project
.
name
if
name
in
BLACKLIST
or
name
.
endswith
(
'
.pages.debian.net
'
):
ignored
+=
1
if
debug
>
0
:
...
...
@@ -154,14 +148,14 @@ for group in blends_groups:
for
line
in
invcs
.
readlines
():
if
line
.
startswith
(
LAST_ACTIVITY
):
last_activity_at
=
line
[
LAST_ACTIVITY_LENGTH
:].
strip
()
if
last_activity_at
==
project
.
attributes
[
'
last_activity_at
'
]
:
if
last_activity_at
==
project
.
last_activity_at
:
dosomething
=
False
unchanged
+=
1
if
debug
>
1
:
print
(
"
Do nothing in %s since found last_activity_at %s == repository %s
"
%
(
name
,
last_activity_at
,
project
.
attributes
[
'
last_activity_at
'
]
))
print
(
"
Do nothing in %s since found last_activity_at %s == repository %s
"
%
(
name
,
last_activity_at
,
project
.
last_activity_at
))
else
:
if
debug
>
0
:
print
(
"
Continue with %s since found last_activity_at %s != repository %s
"
%
(
name
,
last_activity_at
,
project
.
attributes
[
'
last_activity_at
'
]
))
print
(
"
Continue with %s since found last_activity_at %s != repository %s
"
%
(
name
,
last_activity_at
,
project
.
last_activity_at
))
changed
+=
1
invcs
.
close
()
except
FileNotFoundError
:
...
...
@@ -175,7 +169,7 @@ for group in blends_groups:
out
.
write
(
"
Vcs-Browser: https://salsa.debian.org/%s/%s
\n
"
%
(
gpath
,
name
))
out
.
write
(
"
Vcs-Git: https://salsa.debian.org/%s/%s.git
\n
"
%
(
gpath
,
name
))
out
.
write
(
"
Blend: %s
\n
"
%
blend
)
out
.
write
(
"
%s%s
\n
"
%
(
LAST_ACTIVITY
,
project
.
attributes
[
'
last_activity_at
'
]
))
out
.
write
(
"
%s%s
\n
"
%
(
LAST_ACTIVITY
,
project
.
last_activity_at
))
out
.
close
()
# print(project)
# be friendly to Salsa and add some delay timr before real reading of data
...
...