def test_failure(self): """ Harvester should raise exception if clumpp generation sees weird line structure. """ tmpDirParent = makeTempDirParent() tmpDirs = [] for example in td.clumppLineStructure: tmpDirs.append( os.path.abspath( makeTempDir('clumppLineStructure_%s' % example.name))) results = os.path.join(tmpDirs[-1], 'results') out = os.path.join(tmpDirs[-1], 'out') if not os.path.exists(out): os.mkdir(out) populateExample(example, tmpDirs[-1]) files = glob(os.path.join(results, '*_f')) for f in files: data = hc.Data() data.records = {} # key is K, value is an array run, errorString = hc.readFile(f, data) self.assertTrue(run is not None) data.records.setdefault(run.k, []).append(run) data.sortedKs = data.records.keys() data.sortedKs.sort() self.assertRaises(hc.ClumppLineStructure, hc.clumppPopFile, results, out, data) [self.addCleanup(removeDir, d) for d in tmpDirs] self.addCleanup(removeDirIfEmpty, tmpDirParent)
def test_failure(self): """ Harvester should raise exception if clumpp generation sees weird line structure. """ tmpDirParent = makeTempDirParent() tmpDirs = [] for example in td.clumppLineStructure: tmpDirs.append( os.path.abspath(makeTempDir('clumppLineStructure_%s' % example.name))) results = os.path.join(tmpDirs[-1], 'results') out = os.path.join(tmpDirs[-1], 'out') if not os.path.exists(out): os.mkdir(out) populateExample(example, tmpDirs[-1]) files = glob(os.path.join(results, '*_f')) for f in files: data = hc.Data() data.records = {} # key is K, value is an array run, errorString = hc.readFile(f, data) self.assertTrue(run is not None) data.records.setdefault(run.k, []).append(run) data.sortedKs = data.records.keys() data.sortedKs.sort() self.assertRaises(hc.ClumppLineStructure, hc.clumppPopFile, results, out, data) [self.addCleanup(removeDir, d) for d in tmpDirs] self.addCleanup(removeDirIfEmpty, tmpDirParent)
def harvestFiles(data, options): files = glob.glob(os.path.join(options.resultsDir, '*_f')) if len(files) < 1: sys.stderr.write('Error, unable to locate any _f files in ' 'the results directory %s' % options.resultsDir) sys.exit(1) data.records = {} # key is K, value is an array for f in files: run, errorString = hc.readFile(f, data, badValue) if run is not None: if run.k not in data.records: data.records[run.k] = [] data.records[run.k].append(run) else: sys.stderr.write('Error, unable to extract results from file %s.\n' % f) sys.stderr.write('%s\n' % errorString) sys.exit(1) data.sortedKs = data.records.keys() data.sortedKs.sort()
def harvestFiles(data, options): files = glob.glob(os.path.join(options.resultsDir, '*_f')) if len(files) < 1: sys.stderr.write('Error, unable to locate any _f files in ' 'the results directory %s' % options.resultsDir) sys.exit(1) data.records = {} # key is K, value is an array for f in files: run, errorString = hc.readFile(f, data, badValue) if run is not None: if run.k not in data.records: data.records[run.k] = [] data.records[run.k].append(run) else: sys.stderr.write( 'Error, unable to extract results from file %s.\n' % f) sys.stderr.write('%s\n' % errorString) sys.exit(1) data.sortedKs = data.records.keys() data.sortedKs.sort()
def harvestFiles(data, args): files = glob.glob(os.path.join(args.resultsDir, '*_f')) if len(files) < 1: sys.stderr.write('Error, unable to locate any _f files in ' 'the results directory %s' % args.resultsDir) sys.exit(1) data.records = {} # key is K, value is an array for f in files: try: run, errorString = hc.readFile(f, data) except hc.UnexpectedValue as e: unexpectedValue(e.filename, e.valuename, e.value, e.data) if run is not None: data.records.setdefault(run.k, []).append(run) else: sys.stderr.write( 'Error, unable to extract results from file %s.\n' % f) sys.stderr.write('%s\n' % errorString) sys.exit(1) data.sortedKs = data.records.keys() data.sortedKs.sort()