def regenerate_file(filename, edge, root='.', dryrun='', job_server=None, jobs=None): command = edge.command input_files = [ input_file[0] for input_file in edge.sourceFiles(root=root, filelist=[filename]) ] target = edge.target output_file = edge.targetFiles(root=root, filelist=[filename])[0] runnable = False if len(input_files) == 1: if edge.daemon: msg = '# processing %s to %s via %s:%d daemon' % ( input_files[0], output_file, 'localhost', edge.port) if dryrun: if dryrun == 'normal': print msg else: if not job_server: logg(msg) daemon.process(input_files[0], output_file, 'localhost', edge.port) else: jobs.append((input_files[0], output_file)) else: to_run = 'cat %(input)s | %(command)s > %(output)s' % { 'input': input_files[0], 'output': output_file, 'command': command } if dryrun: if dryrun == 'normal': print to_run else: runnable = True elif len(input_files) >= 2: to_run = command + ' ' + ' '.join(input_files) + ' >' + output_file if dryrun: if dryrun == 'normal': print to_run else: runnable = True if runnable: if not job_server: logg(to_run) if not os.system(to_run) == 0: logg("Wrong return status of last command") sys.exit(-1) else: print to_run jobs.append( job_server.submit(processCommand, (to_run, ), (processCommand, ), ('os', )))
def regenerate_file(filename, edge, root='.', dryrun='', job_server=None, jobs=None): command = edge.command input_files = [input_file[0] for input_file in edge.sourceFiles(root=root,filelist=[filename])] target = edge.target output_file = edge.targetFiles(root=root, filelist=[filename])[0] runnable = False if len(input_files)==1: if edge.daemon: msg = '# processing %s to %s via %s:%d daemon' % ( input_files[0], output_file, 'localhost', edge.port) if dryrun: if dryrun == 'normal': print msg else: if not job_server: logg(msg) daemon.process(input_files[0], output_file, 'localhost', edge.port) else: jobs.append((input_files[0], output_file)) else: to_run = 'cat %(input)s | %(command)s > %(output)s' % { 'input': input_files[0], 'output': output_file, 'command': command } if dryrun: if dryrun=='normal': print to_run else: runnable = True elif len(input_files)>=2: to_run = command + ' ' + ' '.join(input_files) + ' >' + output_file if dryrun: if dryrun=='normal': print to_run else: runnable = True if runnable: if not job_server: logg(to_run) if not os.system(to_run) == 0: logg("Wrong return status of last command") sys.exit(-1) else: print to_run jobs.append( job_server.submit(processCommand, (to_run, ), (processCommand, ) , ('os',) ) )
def do_all(cmd, port, files): pid, host, port = start_daemon(cmd, port) time.sleep(60) for f_in, f_out in files: process(f_in, f_out, 'localhost', port) os.kill(pid, signal.SIGKILL)