Permalink
Browse files

fixes generate.py

  • Loading branch information...
1 parent 4f59393 commit aea6fed973fd987426b2776a66ae5a3606bb0ac9 @epico epico committed Sep 17, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 generate.py
View
@@ -2,6 +2,7 @@
import os
import os.path
import sys
+import shutil
from subprocess import Popen, PIPE
from argparse import ArgumentParser
import utils
@@ -63,6 +64,10 @@ def generateOneText(infile, modelfile, reportfile):
def handleOneIndex(indexpath, subdir, indexname, fast):
inMemoryFile = "model.db"
+ modeldir = os.path.join(config.getModelDir(), subdir, indexname)
+ os.makedirs(modeldir, exist_ok=True)
+
+
def cleanupInMemoryFile():
modelfile = os.path.join(config.getInMemoryFileSystem(), inMemoryFile)
reportfile = modelfile + config.getReportPostfix()
@@ -77,8 +82,10 @@ def copyoutInMemoryFile(modelfile):
inmemoryreportfile = inmemoryfile + config.getReportPostfix()
reportfile = modelfile + config.getReportPostfix()
- shutil.copyfile(inmemoryfile, modelfile)
- shutil.copyfile(inmemoryreportfile, reportfile)
+ if os.access(inmemoryfile, os.F_OK):
+ shutil.copyfile(inmemoryfile, modelfile)
+ if os.access(inmemoryreportfile, os.F_OK):
+ shutil.copyfile(inmemoryreportfile, reportfile)
def cleanupFiles(modelnum):
modeldir = os.path.join(config.getModelDir(), subdir, indexname)
@@ -138,8 +145,6 @@ def storeModelStatus(modelfile, textnum, nexttextnum):
print("Skipping " + title + '#' + textpath)
continue
- modeldir = os.path.join(config.getModelDir(), subdir, indexname)
- os.makedirs(modeldir, exist_ok=True)
if fast:
modelfile = os.path.join(config.getInMemoryFileSystem(), \
inMemoryFile)

0 comments on commit aea6fed

Please sign in to comment.