Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
basic error handling if there is no debian/ dir
· da324913
Andreas Tille
authored
Mar 13, 2018
da324913
More sensible handling of errors in empty repositories
· 6b504dfc
Andreas Tille
authored
Mar 13, 2018
6b504dfc
Show whitespace changes
Inline
Side-by-side
misc/machine_readable/fetch-machine-readable_salsa.py
View file @
6b504dfc
...
...
@@ -2,6 +2,7 @@
import
gitlab
import
os
import
sys
import
shutil
import
base64
...
...
@@ -53,7 +54,15 @@ def get_blends_groups():
return
blends_groups
def
output_metadata
(
subdir
,
metadata
):
try
:
items
=
project
.
repository_tree
(
path
=
subdir
)
except
gitlab
.
exceptions
.
GitlabGetError
as
err
:
print
(
"
%s/%s does not seem to have dir %s
"
%
(
gpath
,
name
,
subdir
),
file
=
sys
.
stderr
)
return
None
except
:
print
(
"
%s/%s does not seem to have dir %s
"
%
(
gpath
,
name
,
subdir
),
file
=
sys
.
stderr
)
print
(
"
Unexpected error:
"
,
sys
.
exc_info
())
return
None
for
item
in
items
:
if
item
[
'
name
'
]
in
metadata
:
file_info
=
project
.
repository_blob
(
item
[
'
id
'
])
...
...
@@ -70,10 +79,9 @@ blends_groups = get_blends_groups()
for
group
in
blends_groups
:
print
(
group
.
attributes
[
'
name
'
],
group
.
attributes
[
'
id
'
],
group
.
attributes
[
'
path
'
])
# , group.attributes['description'], group.attributes['full_name'])
gpath
=
group
.
attributes
[
'
path
'
]
#projects = group.projects.list(all=True, order_by='name', sort='asc')
#projects = group.projects.all(order_by='name', sort='asc')
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
'
)
#
projects = group.projects.list(page=1, per_page=10, order_by='name', sort='asc')
for
pr
in
projects
:
project
=
gl
.
projects
.
get
(
pr
.
attributes
[
'
id
'
])
# without this extra get repository_tree() fails
name
=
project
.
attributes
[
'
name
'
]
...
...
@@ -85,5 +93,5 @@ for group in blends_groups:
out
.
write
(
"
Vcs-Git: git@salsa.debian.org:%s/%s.git
\n
"
%
(
gpath
,
name
))
out
.
close
()
# print(project)
output_metadata
(
'
debian
'
,
debianmetadata
)
if
output_metadata
(
'
debian
'
,
debianmetadata
)
:
output_metadata
(
'
debian/upstream
'
,
upstreammetadata
)