mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GT-3199: Corrected logging issue in pcodetest python error handling.
This commit is contained in:
parent
66299066e2
commit
74281c745d
1 changed files with 14 additions and 9 deletions
|
@ -35,8 +35,8 @@ class BuildUtil(object):
|
||||||
try:
|
try:
|
||||||
sp = subprocess.Popen(cmd, stdout=f, stderr=subprocess.PIPE)
|
sp = subprocess.Popen(cmd, stdout=f, stderr=subprocess.PIPE)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
self.log_err(cmd)
|
self.log_err("Command: " + str)
|
||||||
self.log_err(e)
|
self.log_err(e.message)
|
||||||
return 0,e.message#raise
|
return 0,e.message#raise
|
||||||
if stdout: f.close()
|
if stdout: f.close()
|
||||||
out, err = sp.communicate()
|
out, err = sp.communicate()
|
||||||
|
@ -185,25 +185,30 @@ class BuildUtil(object):
|
||||||
self.num_errors = 0
|
self.num_errors = 0
|
||||||
self.num_warnings = 0
|
self.num_warnings = 0
|
||||||
|
|
||||||
def log_pr(self, what):
|
def log_pr(self, prefix, what):
|
||||||
|
if isinstance(what, basestring):
|
||||||
|
log_string = prefix + what
|
||||||
|
else:
|
||||||
|
log_string = prefix + repr(what)
|
||||||
|
|
||||||
if self.log:
|
if self.log:
|
||||||
self.log.write(what + '\n')
|
self.log.write(log_string + '\n')
|
||||||
self.log.flush()
|
self.log.flush()
|
||||||
else:
|
else:
|
||||||
print what
|
print log_string
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
def log_err(self, what):
|
def log_err(self, what):
|
||||||
self.log_pr('# ERROR: ' + what)
|
self.log_pr('# ERROR: ', what)
|
||||||
self.num_errors += 1
|
self.num_errors += 1
|
||||||
|
|
||||||
def log_warn(self, what):
|
def log_warn(self, what):
|
||||||
self.log_pr('# WARNING: ' + what)
|
self.log_pr('# WARNING: ', what)
|
||||||
self.num_warnings += 1
|
self.num_warnings += 1
|
||||||
|
|
||||||
def log_info(self, what):
|
def log_info(self, what):
|
||||||
self.log_pr('# INFO: ' + what)
|
self.log_pr('# INFO: ', what)
|
||||||
|
|
||||||
# create a file with size, type, and symbol info
|
# create a file with size, type, and symbol info
|
||||||
# the function is here because it is useful and has no dependencies
|
# the function is here because it is useful and has no dependencies
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue