37 import subprocess,os,sys,math
41 if (
not os.path.isfile(fileName)):
42 sys.stderr.write(
'ERROR: file not found: ' + fileName +
'\n')
47 printDebug(7,
"Executing command: " + sysCommand +
"\n")
48 return os.system(sysCommand)
51 printDebug(7,
"Executing command: " + sysCommand +
"\n")
52 syspipe = os.popen(sysCommand)
53 for sysLine
in syspipe:
54 outList.append(sysLine .strip())
55 return (syspipe.close() ==
None)
58 printDebug(7,
"Writing " + toWrite +
"\n to: " + sysCommand +
"\n")
59 newfsmpipe = os.popen(sysCommand,
'w')
60 newfsmpipe.write(toWrite.strip() +
"\n")
64 printDebug(7,
"Reading output from writing " + toWrite +
"\n to: " + sysCommand +
"\n")
65 (pin, pout) = os.popen2(sysCommand)
66 pin.write(toWrite.strip() +
"\n")
69 outList.append(sysLine.strip())
74 if (DEBUG >= debLevel):
75 sys.stderr.write(errStr)
79 sys.stderr.write(
"INFO: " + errStr +
"\n")
82 sys.stderr.write(
"WARN: " + errStr +
"\n")
85 sys.stderr.write(
"ERROR: " + errStr +
"\n")
89 if (x < (y - math.log(1e200))):
91 if (y < (x - math.log(1e200))):
95 if (x > y
and logdiff > x):
97 if (y > x
and logdiff > y):
100 return y + math.log(1.0 + math.exp(logdiff))
106 printDebug(7,
"Starting up process: " + sysCommand)
107 self.
evalp_ = subprocess.Popen(sysCommand, shell=
True, bufsize=0,
108 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
110 if self.evalp_.poll():
111 printError(100,
"Command " + sysCommand +
" did not start up correctly.")
114 self.evalp_.stdin.write(toWrite.strip() +
"\n")
115 return self.evalp_.stdout.readline().strip()