Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
beat
beat.web
Commits
65771bbb
Commit
65771bbb
authored
4 years ago
by
Samuel GAIST
Committed by
Flavio TARSETTI
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[backend][management][commands] Pre-commit cleanup
parent
2e21994e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!347
Cleanup backend
,
!342
Django 3 migration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/backend/management/commands/cleanup_cache.py
+46
-32
46 additions, 32 deletions
beat/web/backend/management/commands/cleanup_cache.py
beat/web/backend/management/commands/qsetup.py
+5
-5
5 additions, 5 deletions
beat/web/backend/management/commands/qsetup.py
with
51 additions
and
37 deletions
beat/web/backend/management/commands/cleanup_cache.py
+
46
−
32
View file @
65771bbb
...
...
@@ -25,54 +25,68 @@
# #
###############################################################################
import
os
import
logging
logger
=
logging
.
getLogger
(
'
beat.web
'
)
import
os
from
django.core.management.base
import
BaseCommand
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
...utils
import
cleanup_cache
from
....
import
__version__
logger
=
logging
.
getLogger
(
"
beat.web
"
)
class
Command
(
BaseCommand
):
help
=
'
Cleans-up the cache, removing old files
'
class
Command
(
BaseCommand
):
help
=
"
Cleans-up the cache, removing old files
"
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
--olderthan
'
,
type
=
int
,
metavar
=
'
MINUTES
'
,
default
=
0
,
help
=
'
All files which are older than this value
'
\
'
in *minutes* and are not locked or being used by active
'
\
'
experiments (running or scheduled) will be deleted
'
\
'
[default: %(default)s]
'
)
parser
.
add_argument
(
'
--delete
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
By default we only list cache files that will
'
\
'
be erased. If you pass this flag, then we really erase them
'
)
parser
.
add_argument
(
'
--path
'
,
default
=
settings
.
CACHE_ROOT
,
help
=
'
By default, we erase the CACHE path on your settings. Set
'
\
'
this flag if you want to operate on a different path
'
\
'
[default: %(default)s]
'
)
parser
.
add_argument
(
"
--olderthan
"
,
type
=
int
,
metavar
=
"
MINUTES
"
,
default
=
0
,
help
=
"
All files which are older than this value
"
"
in *minutes* and are not locked or being used by active
"
"
experiments (running or scheduled) will be deleted
"
"
[default: %(default)s]
"
,
)
parser
.
add_argument
(
"
--delete
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
By default we only list cache files that will
"
"
be erased. If you pass this flag, then we really erase them
"
,
)
parser
.
add_argument
(
"
--path
"
,
default
=
settings
.
CACHE_ROOT
,
help
=
"
By default, we erase the CACHE path on your settings. Set
"
"
this flag if you want to operate on a different path
"
"
[default: %(default)s]
"
,
)
def
handle
(
self
,
*
ignored
,
**
arguments
):
# Setup this command's logging level
global
logger
arguments
[
'
verbosity
'
]
=
int
(
arguments
[
'
verbosity
'
])
if
arguments
[
'
verbosity
'
]
>=
1
:
if
arguments
[
'
verbosity
'
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
elif
arguments
[
'
verbosity
'
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
deleted
=
cleanup_cache
(
arguments
[
'
path
'
],
age_in_minutes
=
arguments
[
'
olderthan
'
],
delete
=
arguments
[
'
delete
'
])
if
not
arguments
[
'
delete
'
]:
arguments
[
"
verbosity
"
]
=
int
(
arguments
[
"
verbosity
"
])
if
arguments
[
"
verbosity
"
]
>=
1
:
if
arguments
[
"
verbosity
"
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
elif
arguments
[
"
verbosity
"
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
deleted
=
cleanup_cache
(
arguments
[
"
path
"
],
age_in_minutes
=
arguments
[
"
olderthan
"
],
delete
=
arguments
[
"
delete
"
],
)
if
not
arguments
[
"
delete
"
]:
print
(
"
%d cache files can be deleted
"
%
len
(
deleted
))
for
k
in
deleted
:
print
(
os
.
path
.
join
(
arguments
[
'
path
'
],
k
))
print
(
os
.
path
.
join
(
arguments
[
"
path
"
],
k
))
This diff is collapsed.
Click to expand it.
beat/web/backend/management/commands/qsetup.py
+
5
−
5
View file @
65771bbb
...
...
@@ -25,17 +25,17 @@
# #
###############################################################################
import
sys
import
logging
import
simplejson
import
socket
import
sys
# Default configuration to start the state with
import
psutil
import
socket
import
simplejson
from
django.core.management.base
import
BaseCommand
from
...utils
import
setup_backend
,
dump_backend
from
...utils
import
dump_backend
from
...utils
import
setup_backend
logger
=
logging
.
getLogger
(
"
beat.web
"
)
...
...
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