Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
diapotb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Remote Modules
diapotb
Commits
c7fcce54
Commit
c7fcce54
authored
3 years ago
by
Gaëlle USSEGLIO
Browse files
Options
Downloads
Patches
Plain Diff
ENH : Display OTB and DiapOTB version in log file
parent
7a9a98e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!52
Merge for v1.1.0
,
!50
Finalize Python chains (v1.1.0)
,
!49
Add python tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_src/diapotb/lib/core/Utils.py
+35
-0
35 additions, 0 deletions
python_src/diapotb/lib/core/Utils.py
with
35 additions
and
0 deletions
python_src/diapotb/lib/core/Utils.py
+
35
−
0
View file @
c7fcce54
...
@@ -44,9 +44,11 @@ import time
...
@@ -44,9 +44,11 @@ import time
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
from
enum
import
Enum
from
enum
import
Enum
import
h5py
import
h5py
import
subprocess
from
diapotb.lib.core.DiapOTBExceptions
import
DiapOTBException
from
diapotb.lib.core.DiapOTBExceptions
import
DiapOTBException
from
diapotb.lib.core.DiapOTBEnums
import
Satellite
from
diapotb.lib.core.DiapOTBEnums
import
Satellite
from
diapotb.__meta__
import
__version__
import
otbApplication
as
otb
import
otbApplication
as
otb
...
@@ -96,6 +98,10 @@ class MetadataKeyInGeom(Enum):
...
@@ -96,6 +98,10 @@ class MetadataKeyInGeom(Enum):
return
self
.
value
return
self
.
value
# TODO : Gather and re-deifne some functions
# TODO : Find an uniform format for our logger
# Streamer to our log file
# Streamer to our log file
class
StreamToLogger
(
object
):
class
StreamToLogger
(
object
):
"""
"""
...
@@ -161,6 +167,9 @@ def init_filelog(output_dir):
...
@@ -161,6 +167,9 @@ def init_filelog(output_dir):
STDOUT_SAVE
.
write
=
stdout_save_write
# Restore stdout.write into STDOUT_SAVE
STDOUT_SAVE
.
write
=
stdout_save_write
# Restore stdout.write into STDOUT_SAVE
STDOUT_SAVE
.
flush
=
stdout_save_flush
# Restore stdout.write into STDOUT_SAVE
STDOUT_SAVE
.
flush
=
stdout_save_flush
# Restore stdout.write into STDOUT_SAVE
# Print current versions
log_otb_diapotb_versions
()
def
log
(
level
,
msg
):
def
log
(
level
,
msg
):
"""
"""
...
@@ -176,6 +185,32 @@ def print_on_std(msg):
...
@@ -176,6 +185,32 @@ def print_on_std(msg):
# Print on STDOUT_SAVE aka the original/true stdout
# Print on STDOUT_SAVE aka the original/true stdout
print
(
msg
,
file
=
STDOUT_SAVE
)
print
(
msg
,
file
=
STDOUT_SAVE
)
def
otb_version
():
"""
Get the current OTB version (through ReadImageInfo)
Call ReadImageInfo -version only once (result is cached)
"""
if
"
version
"
not
in
otb_version
.
__dict__
:
try
:
r
=
subprocess
.
run
([
'
otbcli_ReadImageInfo
'
,
'
-version
'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
version
=
r
.
stdout
.
decode
(
'
utf-8
'
).
strip
(
'
\n
'
)
version
=
re
.
search
(
r
'
\d+(\.\d+)+$
'
,
version
)[
0
]
otb_version
.
version
=
version
except
Exception
as
exp
:
raise
RuntimeError
(
"
Cannot retrieve current OTB version : {exp}
"
.
format
(
exp
=
exp
))
return
otb_version
.
version
def
log_otb_diapotb_versions
():
"""
Log OTB and DiapOTB versions
"""
msg
=
"
Current versions are : {diapotb_version} for DiapOTB (python scripts) and
"
\
"
{otb_version} for OTB
"
msg
=
msg
.
format
(
diapotb_version
=
__version__
,
otb_version
=
otb_version
())
logger
.
log
(
logging
.
INFO
,
msg
)
def
exception_tolerance
(
func
):
def
exception_tolerance
(
func
):
"""
Decorator to allow exceptions in some cases (ie : in SARMultiSlc*)
"""
Decorator to allow exceptions in some cases (ie : in SARMultiSlc*)
"""
"""
...
...
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