From c60c7a70e1af20ee46f57817137df980b6392133 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 18 Jul 2011 17:09:38 +0800 Subject: clean up zero length segment report --- segment.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'segment.py') diff --git a/segment.py b/segment.py index 288fb1d..24c4295 100755 --- a/segment.py +++ b/segment.py @@ -25,13 +25,16 @@ def segmentOneText(infile, outfile, reportfile): return #begin processing - cmdline = './ngseg <"' + infile + '" 2>"' + reportfile + '"' - subprocess = Popen(cmdline, shell=True, stdout=PIPE, \ + cmdline = './ngseg <"' + infile + '" >"' + outfile + '"' + subprocess = Popen(cmdline, shell=True, stderr=PIPE, \ close_fds=True) - with open(outfile, 'wb') as f: - f.writelines(subprocess.stdout.readlines()) - f.close() + data = ''.join(subprocess.stderr.readlines()) + if data: + print('found error report') + with open(reportfile, 'wb') as f: + f.writelines([data]) + f.close() os.waitpid(subprocess.pid, 0) #end processing @@ -61,7 +64,7 @@ def handleOneIndex(indexpath): indexfile.close() #end processing - utils.sign_epoch(indexstatus) + utils.sign_epoch(indexstatus, 'Segment') utils.store_status(indexstatuspath, indexstatus) def walkThroughIndex(path): -- cgit