summaryrefslogtreecommitdiffstats
path: root/segment.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-18 17:09:38 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-18 17:09:38 +0800
commitc60c7a70e1af20ee46f57817137df980b6392133 (patch)
tree21d8798113fd13db4979944afa031d344be6dfb5 /segment.py
parent073f8d930c94a2209ddab12f2cd44f4ae05bbffd (diff)
downloadtrainer-c60c7a70e1af20ee46f57817137df980b6392133.tar.gz
trainer-c60c7a70e1af20ee46f57817137df980b6392133.tar.xz
trainer-c60c7a70e1af20ee46f57817137df980b6392133.zip
clean up zero length segment report
Diffstat (limited to 'segment.py')
-rwxr-xr-xsegment.py15
1 files changed, 9 insertions, 6 deletions
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):