# Temp data tempDir = tempfile.mkdtemp(prefix='kts46-') statesFilePath = os.path.join(tempDir, options.statesFile) carsFilePath = os.path.join(tempDir, options.carsFile) # Remove temp directory atexit.register(lambda dir: os.rmdir(dir), tempDir) for inputFilePath in inputFilePaths: # Get model definition with open(inputFilePath) as f: definition = yaml.load(f.read()) # Simulate ss = SimulationServer(cfg) statesFile = open(statesFilePath, "wb") carsFile = open(carsFilePath, "wb") storage = CSVStateStorage(statesFile, carsFile, definition['simulationParameters']['batchLength']) job = OfflineJob(definition) ss.runSimulationJob(job, storage) # Close files for writing and reopen for reading. statesFile.close(), carsFile.close() #statesFile = open(statesFilePath, "rb") #carsFile = open(carsFilePath, "rb") # Compress tarName = os.path.splitext(os.path.split(inputFilePath)[1])[0] outpath = os.path.join(options.output, tarName + ".tar.bz2") tar = tarfile.open(outpath, "w:bz2")