beakerlib/SOURCES/handle-missing-python.patch

53 lines
1.7 KiB
Diff

diff -u b/src/journal.sh b/src/journal.sh
--- b/src/journal.sh
+++ b/src/journal.sh
@@ -283,8 +297,25 @@
#=cut
__INTERNAL_JournalXMLCreate() {
- [[ "$BEAKERLIB_JOURNAL" == "0" ]] || $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \
- "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL"
+ local res=0
+ [[ "$BEAKERLIB_JOURNAL" == "0" ]] || {
+ if which python &> /dev/null; then
+ $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \
+ "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL"
+ res=$?
+ if [[ $res -eq 2 ]]; then
+ rlLogError "cannot create journal.xml due to missing some python module"
+ elif [[ $res -eq 3 ]]; then
+ rlLogError "cannot create journal.xml due to missing python lxml module"
+ elif [[ $res -ne 0 ]]; then
+ rlLogError "journal.xml creation failed!"
+ fi
+ else
+ rlLogError "cannot create journal.xml due to missing python interpreter"
+ let res++
+ fi
+ }
+ return $res
}
diff -u b/src/python/journalling.py b/src/python/journalling.py
--- b/src/python/journalling.py
+++ b/src/python/journalling.py
@@ -30,11 +30,15 @@
import six
import time
import base64
- from lxml import etree
from optparse import OptionParser
except ImportError as e:
sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n")
- exit(1)
+ exit(2)
+try:
+ from lxml import etree
+except ImportError as e:
+ sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n")
+ exit(3)
xmlForbidden = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20,