Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csppfetch
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
cspp_geo
csppfetch
Commits
3b9fcc48
Commit
3b9fcc48
authored
2 years ago
by
Alan De Smet
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug; add lockfile to cleaning
it's help=, not description=
parent
f447aa77
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
example/aitf-clean-temporal
+12
-7
12 additions, 7 deletions
example/aitf-clean-temporal
with
12 additions
and
7 deletions
example/aitf-clean-temporal
+
12
−
7
View file @
3b9fcc48
...
...
@@ -25,6 +25,7 @@ import logging
import
aitf.ancil
import
aitf.conlog
import
csppfetch
from
csppfetch.exclusivelockfile
import
PIDLockFile
def
parse_args
():
...
...
@@ -58,7 +59,7 @@ def parse_args():
TEMPORAL_CACHE_ENV
=
'
CSPP_GEO_AITF_TEMPORAL_CACHE
'
TEMPORAL_DEFAULT
=
os
.
environ
.
get
(
TEMPORAL_CACHE_ENV
,
TEMPORAL_INVALID
)
ap
.
add_argument
(
"
temporal-dir
"
,
metavar
=
"
DIR
"
,
nargs
=
'
?
'
,
description
=
f
'
temporal directory to clean (default: environment variable
{
TEMPORAL_CACHE_ENV
}
'
,
help
=
f
'
temporal directory to clean (default: environment variable
{
TEMPORAL_CACHE_ENV
}
'
,
default
=
TEMPORAL_DEFAULT
)
subgroup
=
ap
.
add_mutually_exclusive_group
()
...
...
@@ -106,12 +107,16 @@ def main():
if
not
args
.
keep_old
:
from
datetime
import
datetime
stats
=
csppfetch
.
CleaningStats
()
csppfetch
.
delete_old_files
(
args
.
temporal_dir
+
"
/L1b
"
,
args
.
oldest
,
stats
)
csppfetch
.
delete_old_files
(
args
.
temporal_dir
+
"
/L2
"
,
args
.
oldest
,
stats
)
if
args
.
want_summary
:
sys
.
stdout
.
write
(
'
Expiring Old Data Summary
\n
'
)
sys
.
stdout
.
write
(
f
'
Removed
{
stats
.
num_deleted
}
files totaling
{
stats
.
size_deleted
}
bytes
\n
'
)
sys
.
stdout
.
write
(
f
'
Kept
{
stats
.
num_kept
}
files totaling
{
stats
.
size_kept
}
bytes
\n
'
)
with
PIDLockFile
(
args
.
temporal_dir
+
"
cleaning-process.pid
"
)
as
has_lock
:
if
has_lock
:
csppfetch
.
delete_old_files
(
args
.
temporal_dir
+
"
/L1b
"
,
args
.
oldest
,
stats
)
csppfetch
.
delete_old_files
(
args
.
temporal_dir
+
"
/L2
"
,
args
.
oldest
,
stats
)
if
args
.
want_summary
:
sys
.
stdout
.
write
(
'
Expiring Old Data Summary
\n
'
)
sys
.
stdout
.
write
(
f
'
Removed
{
stats
.
num_deleted
}
files totaling
{
stats
.
size_deleted
}
bytes
\n
'
)
sys
.
stdout
.
write
(
f
'
Kept
{
stats
.
num_kept
}
files totaling
{
stats
.
size_kept
}
bytes
\n
'
)
else
:
# No lock
sys
.
stdout
.
write
(
"
Cleaning skipped; another process is already doing so.
"
)
return
0
...
...
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