def feedQueue(step, scriptPath, optionParser=None): """ Process a queue file """ # Import custom modules from fp.lib import parameter_store, folder_store # If there is no option parser, build one if not optionParser: optionParser = buildOptionParser() # Add usage optionParser.usage = '%prog [options] queuePath' # Add options optionParser.add_option('-0', '--database', dest='via_database', action='store_true', help='use the database', default=False) optionParser.add_option('-d', '--directory', dest='directory', metavar='DIRECTORY', help='save results in DIRECTORY', default='.') optionParser.add_option('-t', '--test', dest='is_test', action='store_true', help='test the queuePath without running it', default=False) # Parse options, arguments = optionParser.parse_args() # If the user did not supply the right number of arguments, if len(arguments) != 1: # Show help and exit return optionParser.print_help() # Connect if options.via_database: connect(options) # Extract queuePath = arguments[0] try: # Load information parameterByTaskByName = store.loadQueue(queuePath, parameter_store.convertByName) # Initialize testFolderPath = os.path.join(options.directory, 'test') if options.is_test: options.directory = store.makeFolderSafely(testFolderPath) folderStore = folder_store.Store(options.directory) # Step through each task for taskName, parameterByName in parameterByTaskByName.iteritems(): step(taskName, parameterByName, folderStore, options) except (store.QueueError, folder_store.FolderError, ScriptError), scriptError: return '%s %s\n%s' % (store.extractFileBaseName(scriptPath), queuePath, scriptError)
def __init__(self): self.queues = [store.loadQueue(x, parameter_store.convertByName) for x in glob.glob('*.queue')] self.queues_sampleWindows = self.filterQueues('example count per region')