#!/usr/bin/env python """ Execute postprocessing_saudi script in parallel using IPython's parallel computing features. Make sure "ipcluster local n -2" has run in a separate shell window before running this script """ # Gokhan Sever # University of North Dakota - Dept. of Atmospheric Sciences # Written : October 18, 2009 with help from Brain Granger from IPython.kernel.client import TaskClient from subprocess import call import os def find_sea_files(): file_list, path_list = [], [] init = os.getcwd() for root, dirs, files in os.walk('.'): dirs.sort() for file in files: if file.endswith('.sea'): file_list.append(file) os.chdir(root) path_list.append(os.getcwd()) os.chdir(init) return file_list, path_list def process_all(path, file): import os from subprocess import call os.chdir(path) call(['postprocessing_saudi', file]) if __name__ == '__main__': tc = TaskClient() files, paths = find_sea_files() tc.map(process_all, paths, files)