summaryrefslogtreecommitdiffstats
path: root/segment.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-18 16:02:58 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-18 16:02:58 +0800
commit073f8d930c94a2209ddab12f2cd44f4ae05bbffd (patch)
treef1065351ffa067ca5cff8bdfc2a128905ddf48fc /segment.py
parentfa2643cf811583b489209ca51e5ecade1cc1a080 (diff)
downloadtrainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.tar.gz
trainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.tar.xz
trainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.zip
add status check to segment.py
Diffstat (limited to 'segment.py')
-rwxr-xr-xsegment.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/segment.py b/segment.py
index 6c6c173..288fb1d 100755
--- a/segment.py
+++ b/segment.py
@@ -3,6 +3,7 @@ import os
import os.path
from argparse import ArgumentParser
from subprocess import Popen, PIPE
+import utils
from myconfig import MyConfig
@@ -18,6 +19,12 @@ def handleError(error):
sys.exit(error)
def segmentOneText(infile, outfile, reportfile):
+ infilestatuspath = infile + config.getStatusPostfix()
+ infilestatus = utils.load_status(infilestatuspath)
+ if utils.check_epoch(infilestatus, 'Segment'):
+ return
+
+ #begin processing
cmdline = './ngseg <"' + infile + '" 2>"' + reportfile + '"'
subprocess = Popen(cmdline, shell=True, stdout=PIPE, \
close_fds=True)
@@ -27,8 +34,18 @@ def segmentOneText(infile, outfile, reportfile):
f.close()
os.waitpid(subprocess.pid, 0)
+ #end processing
+
+ utils.sign_epoch(infilestatus, 'Segment')
+ utils.store_status(infilestatuspath, infilestatus)
def handleOneIndex(indexpath):
+ indexstatuspath = indexpath + config.getStatusPostfix()
+ indexstatus = utils.load_status(indexstatuspath)
+ if utils.check_epoch(indexstatus, 'Segment'):
+ return
+
+ #begin processing
indexfile = open(indexpath, 'r')
for oneline in indexfile.readlines():
(title, textpath) = oneline.split('#')
@@ -42,6 +59,10 @@ def handleOneIndex(indexpath):
segmentOneText(infile, outfile, reportfile)
print("Processed "+ title + '#' + textpath)
indexfile.close()
+ #end processing
+
+ utils.sign_epoch(indexstatus)
+ utils.store_status(indexstatuspath, indexstatus)
def walkThroughIndex(path):
for root, dirs, files in os.walk(path, topdown=True, onerror=handleError):