Skip to content

Commit ccb3774

Browse files
dependency check
1 parent 0767d56 commit ccb3774

2 files changed

Lines changed: 46 additions & 33 deletions

File tree

kratos.gid/kratos.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ proc Kratos::Event_BeforeRunCalculation { batfilename basename dir problemtypedi
516516
}
517517
set app_run_brake [apps::ExecuteOnCurrentApp BreakRunCalculation]
518518
if {[write::isBooleanTrue $app_run_brake]} {return "-cancel-"}
519-
Kratos::CheckDependencies
519+
if {[Kratos::CheckDependencies] ne 0} {return [list "-cancel-" "Unable to run. Missing dependencies"]}
520520

521521
}
522522

kratos.gid/scripts/Launch.tcl

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ proc Kratos::GetPythonExeName { } {
4545
proc Kratos::GetDefaultPythonPath { } {
4646
set pat ""
4747
catch {
48-
set py [Kratos::GetPythonExeName]
49-
set pat [exec $py -c "import sys; print(sys.executable)" 2>@1]
48+
set py [Kratos::GetPythonExeName]
49+
set pat [exec $py -c "import sys; print(sys.executable)" 2>@1]
5050
}
5151
return $pat
5252
}
@@ -97,51 +97,57 @@ proc Kratos::GetMissingPipPackages { } {
9797

9898
proc Kratos::CheckDependencies { } {
9999
set curr_mode [Kratos::GetLaunchMode]
100-
# W $curr_mode
100+
set ret 0
101+
101102
if {[dict exists $curr_mode dependency_check]} {
102103
set deps [dict get $curr_mode dependency_check]
103-
$deps
104+
set ret [$deps]
104105
}
106+
ShowErrorsAndActions $ret
107+
return $ret
105108
}
106109

107-
proc Kratos::CheckDependenciesPipMode {} {
110+
proc Kratos::ShowErrorsAndActions {errs} {
108111
if { [GidUtils::IsTkDisabled] } {
109112
return 0
110113
}
111-
set py [Kratos::GetPythonExeName]
112-
set py_version [Kratos::pythonVersion $py]
113-
if {$py_version <= 0} {
114-
set msgBox_type yesno
115-
# -do_not_ask_again 1 -do_not_ask_again_key "kratos_install_python"
116-
set reply [tk_messageBox -icon warning -type $msgBox_type -parent .gid \
117-
-message "Python 3 not installed on this system. Do you want Kratos to install it?" \
118-
-title [_ "Missing python"]]
119-
if {[string equal $reply "yes"]} {
120-
Kratos::InstallAllPythonDependencies
114+
switch $errs {
115+
"MISSING_PYTHON" {
116+
W "Python 3 is not installed on this system. Please install it before run the case."
117+
}
118+
"MISSING_PIP" {
119+
W "Pip is not installed on your system. Please install it."
120+
}
121+
"MISSING_PIP_PACKAGES" {
122+
W "Run the following command on a terminal:\npip install --upgrade --force-reinstall --no-cache-dir KratosMultiphysics-all"
123+
}
124+
"DOCKER_NOT_FOUND" {
125+
W "Could not start docker. Please check if the Docker service is enabled."
121126
}
122-
if {[string equal $reply "cancel"]} {
127+
"EXE_NOT_FOUND" {
123128

124129
}
125130
}
126-
set pip_version [Kratos::pipVersion]
127-
if {$pip_version <= 0} {
128-
WarnWin "pip is not installed on your system. Please install it."
129-
} else {
130-
set missing_packages [Kratos::GetMissingPipPackages]
131-
if {[llength $missing_packages] > 0} {
132-
set msgBox_type yesno
133-
# -do_not_ask_again 1 -do_not_ask_again_key "kratos_install_python"
134-
set reply [tk_messageBox -icon warning -type $msgBox_type -parent .gid \
135-
-message "Python $py_version is installed, but there are some missing packages. Do you want Kratos to install them? \n\nPackages to be installed: \n$missing_packages" \
136-
-title [_ "Missing python packages"]]
137-
if {[string equal $reply "yes"]} {
138-
Kratos::InstallAllPythonDependencies
139-
}
140-
if {[string equal $reply "cancel"]} {
131+
}
141132

133+
proc Kratos::CheckDependenciesPipMode {} {
134+
set ret 0
135+
set py [Kratos::GetPythonExeName]
136+
set py_version [Kratos::pythonVersion $py]
137+
if {$py_version <= 0} {
138+
set ret "MISSING_PYTHON"
139+
} else {
140+
set pip_version [Kratos::pipVersion]
141+
if {$pip_version <= 0} {
142+
set ret "MISSING_PIP"
143+
} else {
144+
set missing_packages [Kratos::GetMissingPipPackages]
145+
if {[llength $missing_packages] > 0} {
146+
set ret "MISSING_PIP_PACKAGES"
142147
}
143148
}
144149
}
150+
return $ret
145151
}
146152
proc Kratos::CheckDependenciesLocalPipMode {} {
147153

@@ -150,7 +156,14 @@ proc Kratos::CheckDependenciesLocalMode {} {
150156

151157
}
152158
proc Kratos::CheckDependenciesDockerMode {} {
153-
159+
set ret 0
160+
try {
161+
exec docker ps
162+
} on error {msg} {
163+
W $msg
164+
set ret "DOCKER_NOT_FOUND"
165+
}
166+
return $ret
154167
}
155168

156169
proc Kratos::GetLaunchConfigurationFile { } {

0 commit comments

Comments
 (0)