File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -766,3 +766,52 @@ check_config() {
766
766
check_return " config_value_${c} "
767
767
done
768
768
}
769
+
770
+ major () {
771
+ # shellcheck disable=SC2039
772
+ local pv=" ${1} "
773
+ echo " ${pv} " | awk -F' .' ' {print $1}'
774
+ }
775
+
776
+ minor () {
777
+ # shellcheck disable=SC2039
778
+ local pv=" ${1} "
779
+ echo " ${pv} " | awk -F' .' ' {print $2}'
780
+ }
781
+
782
+ check_python_version () {
783
+ # send in "python --version"
784
+ local pv=" ${1} "
785
+ python_version=$( echo " ${pv} " | awk -F' ' ' {print $NF}' )
786
+ # example "3.9"
787
+ local min_version=" ${2} "
788
+ local err=" ${3} "
789
+ # shellcheck disable=SC2155
790
+ local x=" $( major " ${python_version} " ) "
791
+ # shellcheck disable=SC2155
792
+ local y=" $( minor " ${python_version} " ) "
793
+ # shellcheck disable=SC2155
794
+ local mx=" $( major " ${min_version} " ) "
795
+ # shellcheck disable=SC2155
796
+ local my=" $( minor " ${min_version} " ) "
797
+ # shellcheck disable=SC2155
798
+ local str=" Wrong Python version installed ${pv} "
799
+ if [ " ${x} " -lt " ${mx} " ]; then
800
+ if [ " ${err} " = " Error" ]; then
801
+ error_msg " ${str} "
802
+ else
803
+ warn_msg " ${str} "
804
+ return
805
+ fi
806
+ fi
807
+
808
+ if [ " ${y} " -lt " ${my} " ]; then
809
+ if [ " ${x} " -le " ${mx} " ]; then
810
+ if [ " ${err} " = " Error" ]; then
811
+ error_msg " ${str} "
812
+ else
813
+ warn_msg " ${str} "
814
+ fi
815
+ fi
816
+ fi
817
+ }
You can’t perform that action at this time.
0 commit comments