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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Luc Hermitte
diapotb
Commits
e8e37102
Commit
e8e37102
authored
4 years ago
by
Gaëlle USSEGLIO
Browse files
Options
Downloads
Patches
Plain Diff
ENH : Improve generateConfigFile with color
parent
fc70b8f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_src/utils/generateConfigFile.py
+94
-57
94 additions, 57 deletions
python_src/utils/generateConfigFile.py
with
94 additions
and
57 deletions
python_src/utils/generateConfigFile.py
+
94
−
57
View file @
e8e37102
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
"""
"""
import
os
import
os
import
sys
import
re
import
re
import
json
import
json
import
readline
,
glob
import
readline
,
glob
...
@@ -20,79 +21,109 @@ import func_utils
...
@@ -20,79 +21,109 @@ import func_utils
def
complete
(
text
,
state
):
def
complete
(
text
,
state
):
return
(
glob
.
glob
(
text
+
'
*
'
)
+
[
None
])[
state
]
return
(
glob
.
glob
(
text
+
'
*
'
)
+
[
None
])[
state
]
# Print with colors
def
prRed
(
skk
):
print
(
"
\033
[91m {}
\033
[00m
"
.
format
(
skk
))
def
prGreen
(
skk
):
print
(
"
\033
[92m {}
\033
[00m
"
.
format
(
skk
))
def
prYellow
(
skk
):
print
(
"
\033
[93m {}
\033
[00m
"
.
format
(
skk
))
def
prLightPurple
(
skk
):
print
(
"
\033
[94m {}
\033
[00m
"
.
format
(
skk
))
def
prPurple
(
skk
):
print
(
"
\033
[95m {}
\033
[00m
"
.
format
(
skk
))
def
prCyan
(
skk
):
print
(
"
\033
[96m {}
\033
[00m
"
.
format
(
skk
))
def
prLightGray
(
skk
):
print
(
"
\033
[97m {}
\033
[00m
"
.
format
(
skk
))
def
prBlack
(
skk
):
print
(
"
\033
[98m {}
\033
[00m
"
.
format
(
skk
))
# Input with colors
def
genericInput
(
skk
,
color
)
:
try
:
return
input
(
color
.
format
(
skk
))
except
KeyboardInterrupt
:
prRed
(
"
Generation Aborted, Ctrl-C detected
"
)
sys
.
exit
(
1
)
except
:
prRed
(
"
Generation Aborted
"
)
sys
.
exit
(
1
)
def
inRed
(
skk
):
return
genericInput
(
skk
,
"
\033
[91m {}
\033
[00m
"
)
def
inGreen
(
skk
):
return
genericInput
(
skk
,
"
\033
[92m {}
\033
[00m
"
)
def
inYellow
(
skk
):
return
genericInput
(
skk
,
"
\033
[93m {}
\033
[00m
"
)
def
inLightPurple
(
skk
):
return
genericInput
(
skk
,
"
\033
[94m {}
\033
[00m
"
)
def
inPurple
(
skk
):
return
genericInput
(
skk
,
"
\033
[95m {}
\033
[00m
"
)
def
inCyan
(
skk
):
return
genericInput
(
skk
,
"
\033
[96m {}
\033
[00m
"
)
def
inLightGray
(
skk
):
return
genericInput
(
skk
,
"
\033
[97m {}
\033
[00m
"
)
def
inBlack
(
skk
):
return
genericInput
(
skk
,
"
\033
[98m {}
\033
[00m
"
)
# Questions to user for SAR_MultiSlc* chains
# Questions to user for SAR_MultiSlc* chains
def
askForMultiSlc
(
dataConfig
)
:
def
askForMultiSlc
(
dataConfig
)
:
# Select sensor if SAR_MultiSlc
# Select sensor if SAR_MultiSlc
sensor
=
"
S1IW
"
sensor
=
"
S1IW
"
if
(
response
==
"
SAR_MultiSlc
"
)
:
if
(
response
==
"
SAR_MultiSlc
"
)
:
sensor
=
in
put
(
"
Please, select the wanted sensor S1SM
"
\
sensor
=
in
LightPurple
(
"
Please, select the wanted sensor S1SM
"
\
"
(for Sentinel-1 StripMap mode) or Cosmo
"
\
"
(for Sentinel-1 StripMap mode) or Cosmo
"
\
"
(for Cosmo-Skymed Spotligth and StriMap mode) :
"
)
"
(for Cosmo-Skymed Spotligth and StriMap mode) :
"
)
if
sensor
not
in
[
"
S1SM
"
,
"
Cosmo
"
]
:
if
sensor
not
in
[
"
S1SM
"
,
"
Cosmo
"
]
:
pr
int
(
"
Unknown sensor, please choose between S1SM or Cosmo
"
)
pr
Red
(
"
Unknown sensor, please choose between S1SM or Cosmo
"
)
quit
()
quit
()
# SRTM_Shapefile
# SRTM_Shapefile
SRTM_Shapefile
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to srtm shp :
"
))
SRTM_Shapefile
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to srtm shp :
"
))
func_utils
.
check_ifExist
(
SRTM_Shapefile
)
func_utils
.
check_ifExist
(
SRTM_Shapefile
)
# SRTM_Path
# SRTM_Path
SRTM_Path
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to srtm hgt files :
"
))
SRTM_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to srtm hgt files :
"
))
func_utils
.
check_ifDir
(
SRTM_Path
)
func_utils
.
check_ifDir
(
SRTM_Path
)
# Input/Output Paths
# Input/Output Paths
Input_Path
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to input images :
"
))
Input_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to input images :
"
))
func_utils
.
check_ifDir
(
Input_Path
)
func_utils
.
check_ifDir
(
Input_Path
)
Output_Path
=
os
.
path
.
realpath
(
in
put
(
"
Where would you like to store the output results :
"
))
Output_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Where would you like to store the output results :
"
))
#func_utils.check_ifDir(os.path.dirname(Output_Path))
#func_utils.check_ifDir(os.path.dirname(Output_Path))
func_utils
.
check_ifDir
(
Output_Path
)
func_utils
.
check_ifDir
(
Output_Path
)
# reference image (must be into Input_Path)
# reference image (must be into Input_Path)
reference_image
=
in
put
(
"
Which image is your reference :
"
)
reference_image
=
in
Purple
(
"
Which image is your reference :
"
)
func_utils
.
check_ifExist
(
reference_image
)
func_utils
.
check_ifExist
(
reference_image
)
reference_image
=
os
.
path
.
basename
(
reference_image
)
reference_image
=
os
.
path
.
basename
(
reference_image
)
if
not
func_utils
.
get_imgFromDir
(
reference_image
,
Input_Path
)
:
if
not
func_utils
.
get_imgFromDir
(
reference_image
,
Input_Path
)
:
pr
int
(
reference_image
+
"
not found into given input path
"
+
\
pr
Red
(
reference_image
+
"
not found into given input path
"
+
\
"
Input_Path
"
)
"
Input_Path
"
)
pr
int
(
"
Please check your input path
"
)
pr
Red
(
"
Please check your input path
"
)
quit
()
quit
()
else
:
else
:
correct
=
func_utils
.
check_image_pattern
(
reference_image
,
mode
=
sensor
)
correct
=
func_utils
.
check_image_pattern
(
reference_image
,
mode
=
sensor
)
if
not
correct
:
if
not
correct
:
pr
int
(
"
Reference image
"
+
reference_image
+
"
does not respect naming conventions for the
"
\
pr
Red
(
"
Reference image
"
+
reference_image
+
"
does not respect naming conventions for the
"
\
"
selected sensor
"
)
"
selected sensor
"
)
quit
()
quit
()
# Geoid file
# Geoid file
res_geoid
=
in
put
(
"
Would you like to add a geoid file (yes/no) :
"
)
res_geoid
=
in
Purple
(
"
Would you like to add a geoid file (yes/no) :
"
)
Geoid
=
None
Geoid
=
None
if
res_geoid
==
"
yes
"
:
if
res_geoid
==
"
yes
"
:
Geoid
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to your geoid file :
"
))
Geoid
=
os
.
path
.
realpath
(
in
LightPurple
(
"
Please, enter your path to your geoid file :
"
))
func_utils
.
check_ifExist
(
Geoid
)
func_utils
.
check_ifExist
(
Geoid
)
else
:
else
:
Geoid
=
os
.
getenv
(
'
OTB_GEOID_FILE
'
)
Geoid
=
os
.
getenv
(
'
OTB_GEOID_FILE
'
)
# Start/End date for image selection
# Start/End date for image selection
res_date
=
in
put
(
"
Would you like to specify a start and end date for image selection (yes/no) :
"
)
res_date
=
in
LightPurple
(
"
Would you like to specify a start and end date for image selection (yes/no) :
"
)
# Dummy dates to select by default all images into Input_Path
# Dummy dates to select by default all images into Input_Path
start_date
=
"
19000101
"
start_date
=
"
19000101
"
end_date
=
"
29000101
"
end_date
=
"
29000101
"
pattern
=
""
.
join
([
'
\d{8}
'
])
pattern
=
""
.
join
([
'
\d{8}
'
])
if
res_date
==
"
yes
"
:
if
res_date
==
"
yes
"
:
start_date
=
in
put
(
"
Please, indicate a start date with YYYYMMDD format :
"
)
start_date
=
in
Purple
(
"
Please, indicate a start date with YYYYMMDD format :
"
)
if
not
re
.
match
(
pattern
,
start_date
)
:
if
not
re
.
match
(
pattern
,
start_date
)
:
pr
int
(
"
start_date
"
+
start_date
+
"
does not respect the expected format YYYYMMDD
"
)
pr
Red
(
"
start_date
"
+
start_date
+
"
does not respect the expected format YYYYMMDD
"
)
quit
()
quit
()
end_date
=
in
put
(
"
Please, indicate a end date with YYYYMMDD format :
"
)
end_date
=
in
Purple
(
"
Please, indicate a end date with YYYYMMDD format :
"
)
if
not
re
.
match
(
pattern
,
end_date
)
:
if
not
re
.
match
(
pattern
,
end_date
)
:
pr
int
(
"
end_date
"
+
end_date
+
"
does not respect the expected format YYYYMMDD
"
)
pr
Red
(
"
end_date
"
+
end_date
+
"
does not respect the expected format YYYYMMDD
"
)
quit
()
quit
()
# Indicate to user, all selected images with given dates, polarisation and input_path
# Indicate to user, all selected images with given dates, polarisation and input_path
...
@@ -117,24 +148,24 @@ def askForMultiSlc(dataConfig) :
...
@@ -117,24 +148,24 @@ def askForMultiSlc(dataConfig) :
tiff_dates
=
func_utils
.
avoidDuplicates
(
tiff_dates
)
tiff_dates
=
func_utils
.
avoidDuplicates
(
tiff_dates
)
tiff_dates
.
remove
(
reference_image
)
tiff_dates
.
remove
(
reference_image
)
pr
int
(
"
For your information, the selected images for processings will be :
"
)
pr
Yellow
(
"
For your information, the selected images for processings will be :
"
)
pr
int
(
"
As reference :
"
+
reference_image
)
pr
Yellow
(
"
As reference :
"
+
reference_image
)
pr
int
(
"
As secondaries :
"
+
str
(
tiff_dates
))
pr
Yellow
(
"
As secondaries :
"
+
str
(
tiff_dates
))
# Ask to continue if selection OK
# Ask to continue if selection OK
res_continue
=
in
put
(
"
Do you agree to continue with this selection (yes/no) :
"
)
res_continue
=
in
LightPurple
(
"
Do you agree to continue with this selection (yes/no) :
"
)
if
res_continue
!=
"
yes
"
:
if
res_continue
!=
"
yes
"
:
pr
int
(
"
Previous selection does not
correspond to
your expectations, you can relaunch this script with new inputs
"
)
pr
Red
(
"
Previous selection does not
fullfill
your expectations, you can relaunch this script with new inputs
"
)
quit
()
quit
()
# EOF file
# EOF file
EOF_Path
=
None
EOF_Path
=
None
if
sensor
!=
"
Cosmo
"
:
if
sensor
!=
"
Cosmo
"
:
res_eof
=
in
put
(
"
Would you like to indicate fine orbits (yes/no) :
"
)
res_eof
=
in
LightPurple
(
"
Would you like to indicate fine orbits (yes/no) :
"
)
if
res_eof
==
"
yes
"
:
if
res_eof
==
"
yes
"
:
EOF_Path
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to .EOF files :
"
))
EOF_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to .EOF files :
"
))
func_utils
.
check_ifDir
(
EOF_Path
)
func_utils
.
check_ifDir
(
EOF_Path
)
...
@@ -160,53 +191,53 @@ def askForDiapOTB(dataConfig) :
...
@@ -160,53 +191,53 @@ def askForDiapOTB(dataConfig) :
# Select sensor if diapOTB
# Select sensor if diapOTB
sensor
=
"
S1IW
"
sensor
=
"
S1IW
"
if
(
response
==
"
diapOTB
"
)
:
if
(
response
==
"
diapOTB
"
)
:
sensor
=
in
put
(
"
Please, select the wanted sensor S1SM
"
\
sensor
=
in
LightPurple
(
"
Please, select the wanted sensor S1SM
"
\
"
(for Sentinel-1 StripMap mode) or Cosmo
"
\
"
(for Sentinel-1 StripMap mode) or Cosmo
"
\
"
(for Cosmo-Skymed Spotligth and StriMap mode) :
"
)
"
(for Cosmo-Skymed Spotligth and StriMap mode) :
"
)
if
sensor
not
in
[
"
S1SM
"
,
"
Cosmo
"
]
:
if
sensor
not
in
[
"
S1SM
"
,
"
Cosmo
"
]
:
pr
int
(
"
Unknown sensor, please choose between S1SM or Cosmo
"
)
pr
Red
(
"
Unknown sensor, please choose between S1SM or Cosmo
"
)
quit
()
quit
()
# reference image (path to image)
# reference image (path to image)
reference_image
=
os
.
path
.
realpath
(
in
put
(
"
Which image is your reference :
"
))
reference_image
=
os
.
path
.
realpath
(
in
Purple
(
"
Which image is your reference :
"
))
func_utils
.
check_ifExist
(
reference_image
)
func_utils
.
check_ifExist
(
reference_image
)
reference_image_base
=
os
.
path
.
basename
(
reference_image
)
reference_image_base
=
os
.
path
.
basename
(
reference_image
)
correct
=
func_utils
.
check_image_pattern
(
reference_image_base
,
mode
=
sensor
)
correct
=
func_utils
.
check_image_pattern
(
reference_image_base
,
mode
=
sensor
)
if
not
correct
:
if
not
correct
:
pr
int
(
"
Reference image
"
+
reference_image_base
+
"
does not respect naming conventions for the
"
\
pr
Red
(
"
Reference image
"
+
reference_image_base
+
"
does not respect naming conventions for the
"
\
"
selected sensor
"
)
"
selected sensor
"
)
quit
()
quit
()
# reference image (path to image)
# reference image (path to image)
secondary_image
=
os
.
path
.
realpath
(
in
put
(
"
Which image is secondary :
"
))
secondary_image
=
os
.
path
.
realpath
(
in
Purple
(
"
Which image is secondary :
"
))
func_utils
.
check_ifExist
(
secondary_image
)
func_utils
.
check_ifExist
(
secondary_image
)
secondary_image_base
=
os
.
path
.
basename
(
secondary_image
)
secondary_image_base
=
os
.
path
.
basename
(
secondary_image
)
correct
=
func_utils
.
check_image_pattern
(
secondary_image_base
,
mode
=
sensor
)
correct
=
func_utils
.
check_image_pattern
(
secondary_image_base
,
mode
=
sensor
)
if
not
correct
:
if
not
correct
:
pr
int
(
"
Reference image
"
+
secondary_image_base
+
"
does not respect naming conventions for the
"
\
pr
Red
(
"
Reference image
"
+
secondary_image_base
+
"
does not respect naming conventions for the
"
\
"
selected sensor
"
)
"
selected sensor
"
)
quit
()
quit
()
# DEM Path
# DEM Path
DEM_Path
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to your DEM :
"
))
DEM_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to your DEM :
"
))
func_utils
.
check_ifExist
(
DEM_Path
)
func_utils
.
check_ifExist
(
DEM_Path
)
# Output Path
# Output Path
Output_Path
=
os
.
path
.
realpath
(
in
put
(
"
Where would you like to store the output results :
"
))
Output_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Where would you like to store the output results :
"
))
func_utils
.
check_ifDir
(
os
.
path
.
dirname
(
Output_Path
))
func_utils
.
check_ifDir
(
os
.
path
.
dirname
(
Output_Path
))
# EOF file
# EOF file
EOF_Path
=
None
EOF_Path
=
None
if
sensor
!=
"
Cosmo
"
:
if
sensor
!=
"
Cosmo
"
:
res_eof
=
in
put
(
"
Would you like to indicate fine orbits (yes/no) :
"
)
res_eof
=
in
LightPurple
(
"
Would you like to indicate fine orbits (yes/no) :
"
)
if
res_eof
==
"
yes
"
:
if
res_eof
==
"
yes
"
:
EOF_Path
=
os
.
path
.
realpath
(
in
put
(
"
Please, enter your path to .EOF files :
"
))
EOF_Path
=
os
.
path
.
realpath
(
in
Purple
(
"
Please, enter your path to .EOF files :
"
))
func_utils
.
check_ifDir
(
EOF_Path
)
func_utils
.
check_ifDir
(
EOF_Path
)
...
@@ -227,19 +258,18 @@ def askForDiapOTB(dataConfig) :
...
@@ -227,19 +258,18 @@ def askForDiapOTB(dataConfig) :
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
######### Introduction prints #########
######### Introduction prints #########
pr
int
(
"
Welcome to DiapOTB remote module !
"
)
pr
Cyan
(
"
Welcome to DiapOTB remote module !
"
)
pr
int
(
"
You can generate configuration files for the four available processing chains : diapOTB,
"
\
pr
Cyan
(
"
You can generate configuration files for the four available processing chains : diapOTB,
"
\
"
diapOTB_S1IW, SAR_MultiSlc and SAR_MultiSlc_IW
"
)
"
diapOTB_S1IW, SAR_MultiSlc and SAR_MultiSlc_IW
"
)
######### Load the example for prepare the configuration file according to user's choice #########
######### Load the example for prepare the configuration file according to user's choice #########
# First choice for user : the selected chain
# First choice for user : the selected chain
response
=
in
put
(
"
Please, choose your p
o
rcessing chain (diapOTB, diapOTB_S1IW, SAR_MultiSlc and
"
\
response
=
in
LightGray
(
"
Please, choose your pr
o
cessing chain (diapOTB, diapOTB_S1IW, SAR_MultiSlc and
"
\
"
SAR_MultiSlc_IW) :
"
)
"
SAR_MultiSlc_IW) :
"
)
if
response
not
in
[
'
diapOTB
'
,
'
diapOTB_S1IW
'
,
'
SAR_MultiSlc
'
,
'
SAR_MultiSlc_IW
'
]
:
if
response
not
in
[
'
diapOTB
'
,
'
diapOTB_S1IW
'
,
'
SAR_MultiSlc
'
,
'
SAR_MultiSlc_IW
'
]
:
pr
int
(
"
Wrong chain, please choose between available chains
"
)
pr
Red
(
"
Wrong chain, please choose between available chains
"
)
quit
()
# Load examples according to the selected chain => Init a dictionnary with default parameters
# Load examples according to the selected chain => Init a dictionnary with default parameters
...
@@ -277,29 +307,36 @@ if __name__ == "__main__":
...
@@ -277,29 +307,36 @@ if __name__ == "__main__":
########## Ask to user for generic fields #########
########## Ask to user for generic fields #########
# SAR_MultiSlc* chains
# SAR_MultiSlc* chains
if
(
response
==
"
SAR_MultiSlc
"
or
response
==
"
SAR_MultiSlc_IW
"
)
:
if
(
response
==
"
SAR_MultiSlc
"
or
response
==
"
SAR_MultiSlc_IW
"
)
:
askForMultiSlc
(
dataConfig
)
try
:
askForMultiSlc
(
dataConfig
)
except
:
prRed
(
"
Generation Aborted
"
)
sys
.
exit
(
1
)
if
(
response
==
"
diapOTB
"
or
response
==
"
diapOTB_S1IW
"
)
:
if
(
response
==
"
diapOTB
"
or
response
==
"
diapOTB_S1IW
"
)
:
askForDiapOTB
(
dataConfig
)
try
:
askForDiapOTB
(
dataConfig
)
except
:
prRed
(
"
Generation Aborted
"
)
sys
.
exit
(
1
)
# Dump dataConfig with the new fields and the default parameters
# Dump dataConfig with the new fields and the default parameters
res_json
=
os
.
path
.
realpath
(
in
put
(
"
Where do you want store your configuration file :
"
))
res_json
=
os
.
path
.
realpath
(
in
LightGray
(
"
Where do you want store your configuration file :
"
))
# if directory
# if directory
if
os
.
path
.
isdir
(
res_json
)
:
if
os
.
path
.
isdir
(
res_json
)
:
res_json_name
=
in
put
(
"
Please, enter a name for your configuration
"
\
res_json_name
=
in
LightGray
(
"
Please, enter a name for your configuration
"
\
"
file (with .json extension) :
"
)
"
file (with .json extension) :
"
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
res_json
,
res_json_name
))
:
if
os
.
path
.
exists
(
os
.
path
.
join
(
res_json
,
res_json_name
))
:
res_json_overwrite
=
in
put
(
"
Would you like to overwrite the file
"
+
res_json_overwrite
=
in
LightGray
(
"
Would you like to overwrite the file
"
+
res_json_name
+
"
(yes/no) :
"
)
res_json_name
+
"
(yes/no) :
"
)
if
res_json_overwrite
==
"
yes
"
:
if
res_json_overwrite
==
"
yes
"
:
with
open
(
os
.
path
.
join
(
res_json
,
res_json_name
),
'
w
'
)
as
f
:
with
open
(
os
.
path
.
join
(
res_json
,
res_json_name
),
'
w
'
)
as
f
:
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
else
:
else
:
pr
int
(
"
Generation Aborted
"
)
pr
Red
(
"
Generation Aborted
"
)
quit
()
quit
()
else
:
else
:
...
@@ -311,26 +348,26 @@ if __name__ == "__main__":
...
@@ -311,26 +348,26 @@ if __name__ == "__main__":
if
os
.
path
.
isdir
(
os
.
path
.
dirname
(
res_json
))
:
if
os
.
path
.
isdir
(
os
.
path
.
dirname
(
res_json
))
:
if
os
.
path
.
exists
(
res_json
)
:
if
os
.
path
.
exists
(
res_json
)
:
res_json_overwrite
=
in
put
(
"
Would you like to overwrite the file
"
+
res_json_overwrite
=
in
LightGray
(
"
Would you like to overwrite the file
"
+
res_json
+
"
(yes/no) :
"
)
res_json
+
"
(yes/no) :
"
)
if
res_json_overwrite
==
"
yes
"
:
if
res_json_overwrite
==
"
yes
"
:
with
open
(
res_json
,
'
w
'
)
as
f
:
with
open
(
res_json
,
'
w
'
)
as
f
:
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
else
:
else
:
pr
int
(
"
Generation Aborted
"
)
pr
Red
(
"
Generation Aborted
"
)
quit
()
quit
()
else
:
else
:
with
open
(
res_json
,
'
w
'
)
as
f
:
with
open
(
res_json
,
'
w
'
)
as
f
:
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
json
.
dump
(
dataConfig
,
f
,
indent
=
2
,
sort_keys
=
False
)
else
:
else
:
pr
int
(
"
Wrong path for the configuration file, Generation Aborted
"
)
pr
Red
(
"
Wrong path for the configuration file, Generation Aborted
"
)
######### Conclusion prints #########
######### Conclusion prints #########
pr
int
(
"
The configuration file was generated !
"
)
pr
Green
(
"
The configuration file was generated !
"
)
pr
int
(
"
You can modify the parameters in it and launch the processing chain with this file as only argument
"
)
pr
Cyan
(
"
You can modify the parameters in it and launch the processing chain with this file as only argument
"
)
pr
int
(
"
You can find further information on https://gitlab.orfeo-toolbox.org/remote_modules/diapotb/-/wikis/
"
)
pr
Cyan
(
"
You can find further information on https://gitlab.orfeo-toolbox.org/remote_modules/diapotb/-/wikis/
"
)
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