def run_os_command(command_map):
 success = True
 for (executable, commands) in command_map.items():
  if find_executable(executable):
   if isinstance(commands, basestring):
    commands = [commands]
   for command in commands:
    returncode = subprocess.check_call(command, shell=True)
    success = (success and (returncode == 0))
   break
 return success

def run_os_command ( command_map ) : success = True for ( executable , commands ) in command_map . items ( ) : if find_executable ( executable ) : if isinstance ( commands , basestring ) : commands = [ commands ] for command in commands : returncode = subprocess . check_call ( command , shell = True ) success = ( success and ( returncode == 0 ) ) break return success
command_map is a dictionary of {executable: command} .