Error when calling a python script from expect script -
i have python script called mypython.py has logger module imported. mypython.py called expect script called myexpect.exp. issue when add logger.info('test') statement in mypython.py , call myexpect.exp myexpect.exp fails. if replace logger.log('test') statement print statement working fine.
content of python script
import os import sys import datetime import time import argparse import logging logging.basicconfig(format="%(asctime)s %(message)s", datefmt='%m/%d/%y %i:%m:%s %p', level=logging.info) logger = logging.getlogger(__name__) *** *** def main(): args = get_args() print 'this print statement ' + args.test_arg ### ok logger.info("this logger statement" + " " + args.test_arg) ### has issue
content of expect script
#!/usr/bin/expect -- #exec python mypath/stratus/bin/mypython.py "test" ">@stdout" exec python prnt_stmt.py -t arg_from_exp ">@stdout"
error got
this print statement arg_from_exp 03/06/2014 03:16:55 logger statement arg_from_exp while executing "exec python mypython.py -t arg_from_exp ">@stdout"" (file "./myexpect.exp" line 9)
can me out in this?
tcl's exec
command bit weird. throw error if
- the exec'ed command returns non-zero exit status, or
- the exec'ed command writes stderr.
see "child status" section of http://wiki.tcl.tk/exec
you might do:
set status [catch {exec -ignorestderr python mypython.py -t arg_from_exp} output] if {$status == 0} { puts "no problem" } else { puts "non-zero exit status" }
Comments
Post a Comment