asset.sh
#!/bin/bash
_ASSERT()
{
result=$1
lineno=$(($2 - 1))
if [ -z "$3" ];then
ok_return_codes="0"
else
ok_return_codes=$3
fi
#ASSERT_PATH=$(cd `dirname $0`;pwd)
#ASSERT_PATH=/home/ctmagt/bin/
#ASSERT_PATH=/usr/bin/
#ASSERT_PATH=/wls/wls81/ctm/shell
python /mnt/sda/kettle/ddp/script/assert.py $result $lineno $ok_return_codes
assert_result=$?
if [ $assert_result -ne 0 ] ;then
echo "作业失败"
exit $assert_result
fi
}
asset.py
import os
import sys
def _assert(result, lineno, ok_return_codes):
if result in ok_return_codes:
return 0
else:
print "Return Code=%s,line=%s" %(result, lineno)
return result
if __name__ == "__main__":
if(len(sys.argv)) < 3:
print 'error passing parameters to python'
sys.exit(-1)
result = str(sys.argv[1])
lineno = str(sys.argv[2])
ok_return_codes = list(sys.argv[3].split(','))
is_ok = _assert(result, lineno, ok_return_codes)
sys.exit(is_ok)