Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SIPS
EdosL0Util
Commits
c96bb289
Commit
c96bb289
authored
4 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
rdrmerge: support using cwd rather than just tmpdir
parent
0d3e40d1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
edosl0util/cli/rdrmerge.py
+16
-4
16 additions, 4 deletions
edosl0util/cli/rdrmerge.py
with
16 additions
and
4 deletions
edosl0util/cli/rdrmerge.py
+
16
−
4
View file @
c96bb289
...
...
@@ -20,6 +20,12 @@ from .util import configure_logging
LOG
=
logging
.
getLogger
(
"
edosl0util.cli.rdrmerge
"
)
@contextmanager
def
working_directory
(
workdir
,
**
kwds
):
os
.
chdir
(
workdir
)
yield
workdir
# py2 compat
@contextmanager
def
TemporaryDirectory
(
**
kwds
):
...
...
@@ -94,15 +100,20 @@ start_of_mission = {
}
def
merge_rdrs
(
inputs
,
not_before
=
None
,
not_after
=
None
):
def
merge_rdrs
(
inputs
,
not_before
=
None
,
not_after
=
None
,
workdir
=
None
):
to_process
=
rdrs_to_process
(
inputs
)
if
workdir
is
not
None
:
workdir
=
working_directory
(
workdir
)
else
:
workdir
=
TemporaryDirectory
(
os
.
getcwd
())
# do each set of files separately to handle case where different products
# are provided
outputs
=
[]
for
(
sat
,
product
),
rdrs
in
to_process
.
items
():
LOG
.
info
(
"
handling %d files for %s %s
"
,
len
(
rdrs
),
sat
,
product
)
with
TemporaryDirectory
(
dir
=
os
.
getcwd
())
as
tmpdir
:
with
workdir
as
tmpdir
:
# extract RDRs separately, name them after RDR
pds
=
[]
for
fpath
in
rdrs
:
...
...
@@ -139,7 +150,7 @@ def main():
"
%Y-%m-%dT%H:%M:%SZ
"
,
"
%Y-%m-%dT%H:%M:%S
"
,
"
%Y-%m-%d %H:%M:%S
"
,
"
%Y-%m-%d
"
"
%Y-%m-%d
"
,
]:
try
:
return
datetime
.
strptime
(
v
,
fmt
)
...
...
@@ -148,6 +159,7 @@ def main():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
--workdir
"
,
help
=
"
Working directory. Not cleaned up.
"
)
parser
.
add_argument
(
"
--not-before
"
,
type
=
timestamp
,
...
...
@@ -164,7 +176,7 @@ def main():
if
not
args
.
rdr
:
parser
.
exit
(
1
,
"
no RDR
'
s provided
"
)
for
o
in
merge_rdrs
(
args
.
rdr
,
not_before
=
args
.
not_before
):
for
o
in
merge_rdrs
(
args
.
rdr
,
not_before
=
args
.
not_before
,
workdir
=
args
.
workdir
):
LOG
.
info
(
"
created %s
"
,
o
)
...
...
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