Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
824aee99
Commit
824aee99
authored
Aug 06, 2020
by
Guilhem Saurel
Browse files
flake8
parent
9102fb02
Pipeline
#10587
passed with stage
in 1 minute and 15 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dashboard/middleware.py
View file @
824aee99
...
...
@@ -3,8 +3,11 @@ from ipaddress import ip_address, ip_network
from
django.conf
import
settings
from
django.http
import
HttpRequest
,
HttpResponse
,
HttpResponseRedirect
from
django.shortcuts
import
reverse
from
rest_framework
import
permissions
ALLOWED_URLS
=
(
'admin'
,
'accounts'
,
'gh'
)
def
ip_laas
(
request
:
HttpRequest
)
->
bool
:
"""check if request comes from settings.LAAS_NETWORKS."""
...
...
@@ -21,7 +24,6 @@ class LAASPermsMiddleware:
or if the user is authenticated,
or if the request comes from a trusted IP.
"""
ALLOWED_URLS
=
(
'admin'
,
'accounts'
,
'gh'
)
allowed
=
(
any
(
request
.
path
.
startswith
(
f
'/
{
url
}
/'
)
for
url
in
ALLOWED_URLS
)
or
request
.
user
and
request
.
user
.
is_authenticated
or
request
.
method
in
permissions
.
SAFE_METHODS
and
ip_laas
(
request
))
...
...
rainboard/management/commands/checks.py
View file @
824aee99
...
...
@@ -43,7 +43,7 @@ class Command(BaseCommand):
rattr
=
getattr
(
repo
,
attr_name
)
logger
.
warning
(
f
"project
{
project
}
's repo
{
repo
.
git_remote
()
}
{
attr_name
}
:
{
attr
}
Vs.
{
rattr
}
"
)
print
(
f
'
\n
Checking robotpkgs
\n
'
)
print
(
'
\n
Checking robotpkgs
\n
'
)
for
robotpkg
in
Robotpkg
.
objects
.
all
():
repo
,
project_repo
=
robotpkg
.
master_repository
,
robotpkg
.
project
.
main_repo
().
url
...
...
rainboard/management/commands/delete_perso.py
View file @
824aee99
...
...
@@ -11,5 +11,5 @@ class Command(BaseCommand):
help
=
'Delete personnal projects'
def
handle
(
self
,
*
args
,
**
options
):
logger
.
info
(
f
'removing unwanted projects:'
)
logger
.
info
(
'removing unwanted projects:'
)
logger
.
info
(
str
(
Project
.
objects
.
filter
(
main_namespace__group
=
False
).
delete
()))
rainboard/management/commands/fetch.py
View file @
824aee99
...
...
@@ -10,7 +10,7 @@ class Command(BaseCommand):
help
=
'Fetch all remotes'
def
handle
(
self
,
*
args
,
**
options
):
logger
.
info
(
f
'Fetching all repos'
)
logger
.
info
(
'Fetching all repos'
)
for
project
in
Project
.
objects
.
all
():
logger
.
info
(
f
' updating branches for
{
project
}
'
)
project
.
update_branches
(
main
=
False
,
pull
=
True
)
rainboard/management/commands/populate.py
View file @
824aee99
...
...
@@ -14,7 +14,7 @@ class Command(BaseCommand):
help
=
'populates licenses, projets, namespaces and repos from forges'
def
handle
(
self
,
*
args
,
**
options
):
logger
.
info
(
f
'updating licenses'
)
logger
.
info
(
'updating licenses'
)
for
data
in
requests
.
get
(
LICENSES
).
json
()[
'licenses'
]:
License
.
objects
.
get_or_create
(
spdx_id
=
data
[
'licenseId'
],
defaults
=
{
...
...
@@ -22,12 +22,12 @@ class Command(BaseCommand):
'url'
:
data
[
'detailsUrl'
]
})
logger
.
info
(
f
'updating forges'
)
logger
.
info
(
'updating forges'
)
for
forge
in
Forge
.
objects
.
order_by
(
'source'
):
logger
.
info
(
f
' updating
{
forge
}
'
)
forge
.
get_projects
()
logger
.
info
(
f
'updating repos'
)
logger
.
info
(
'updating repos'
)
for
repo
in
Repo
.
objects
.
all
():
logger
.
info
(
f
' updating
{
repo
}
'
)
repo
.
api_update
()
...
...
rainboard/management/commands/update.py
View file @
824aee99
...
...
@@ -58,46 +58,46 @@ class Command(BaseCommand):
def
log
(
message
):
self
.
stdout
.
write
(
message
)
log
(
f
'updating forges'
)
log
(
'updating forges'
)
for
forge
in
Forge
.
objects
.
order_by
(
'source'
):
log
(
f
' updating
{
forge
}
'
)
forge
.
get_projects
()
log
(
f
'
\n
Updating all repos
\n
'
)
log
(
'
\n
Updating all repos
\n
'
)
for
repo
in
Repo
.
objects
.
filter
(
project__archived
=
False
,
project__main_namespace__from_gepetto
=
True
):
log
(
f
'
{
repo
}
'
)
repo
.
update
()
log
(
f
'
\n
Updating all branches
\n
'
)
log
(
'
\n
Updating all branches
\n
'
)
for
branch
in
Branch
.
objects
.
filter
(
project__archived
=
False
,
project__main_namespace__from_gepetto
=
True
):
log
(
f
'
{
branch
.
project
}
-
{
branch
}
'
)
branch
.
update
(
pull
=
False
)
log
(
f
'
\n
Pulling Robotpkg
\n
'
)
log
(
'
\n
Pulling Robotpkg
\n
'
)
update_robotpkg
(
settings
.
RAINBOARD_RPKG
)
log
(
f
'
\n
Updating gepetto projects
\n
'
)
log
(
'
\n
Updating gepetto projects
\n
'
)
for
project
in
Project
.
objects
.
filter
(
archived
=
False
,
main_namespace__from_gepetto
=
True
):
log
(
f
'
{
project
}
'
)
project
.
update
(
only_main_branches
=
False
)
log
(
f
'
\n
Updating Robotpkg
\n
'
)
log
(
'
\n
Updating Robotpkg
\n
'
)
for
robotpkg
in
Robotpkg
.
objects
.
filter
(
project__archived
=
False
,
project__main_namespace__from_gepetto
=
True
):
log
(
f
'
{
robotpkg
}
'
)
robotpkg
.
update
(
pull
=
False
)
log
(
f
'
\n
Updating keep doc
\n
'
)
log
(
'
\n
Updating keep doc
\n
'
)
Branch
.
objects
.
filter
(
Q
(
name__endswith
=
'master'
)
|
Q
(
name__endswith
=
'devel'
),
repo__namespace
=
F
(
'project__main_namespace'
),
repo__forge__source
=
SOURCES
.
gitlab
).
update
(
keep_doc
=
True
)
log
(
f
'
\n
Delete perso
\n
'
)
log
(
'
\n
Delete perso
\n
'
)
call_command
(
'delete_perso'
)
log
(
f
'
\n
clean obsolete Images
\n
'
)
log
(
'
\n
clean obsolete Images
\n
'
)
Image
.
objects
.
filter
(
robotpkg__project__archived
=
True
).
delete
()
log
(
f
'
\n
Look for missing images
\n
'
)
log
(
'
\n
Look for missing images
\n
'
)
for
img
in
Image
.
objects
.
filter
(
created__lt
=
timezone
.
now
()
-
timedelta
(
days
=
7
),
target__active
=
True
):
log
(
f
'
{
img
}
'
)
...
...
rainboard/models.py
View file @
824aee99
import
json
import
logging
import
re
from
functools
import
cmp_to_key
from
subprocess
import
check_output
from
django.conf
import
settings
...
...
@@ -844,12 +843,12 @@ class Robotpkg(NamedModel):
last_commit
=
next
(
repo
.
iter_commits
(
paths
=
repo_path
,
max_count
=
1
))
self
.
updated
=
last_commit
.
authored_datetime
license
=
check_output
([
'make'
,
'show-var'
,
f
'VARNAME=LICENSE'
],
cwd
=
cwd
).
decode
().
strip
()
license
=
check_output
([
'make'
,
'show-var'
,
'VARNAME=LICENSE'
],
cwd
=
cwd
).
decode
().
strip
()
if
license
in
RPKG_LICENSES
:
self
.
license
=
License
.
objects
.
get
(
spdx_id
=
RPKG_LICENSES
[
license
])
else
:
logger
.
warning
(
f
'Unknown robotpkg license:
{
license
}
'
)
self
.
public
=
not
bool
(
check_output
([
'make'
,
'show-var'
,
f
'VARNAME=RESTRICTED'
],
cwd
=
cwd
).
decode
().
strip
())
self
.
public
=
not
bool
(
check_output
([
'make'
,
'show-var'
,
'VARNAME=RESTRICTED'
],
cwd
=
cwd
).
decode
().
strip
())
with
(
cwd
/
'DESCR'
).
open
()
as
f
:
self
.
description
=
f
.
read
().
strip
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment