import subprocessimport sysret = subprocess.check_call(['ls', '-l'])if ret != 0: # something wrong! To deal with the exception sys.exit(ret)ret = subprocess.check_call(['rm', '-f', 'file_to_delete'])if ret != 0: # similar to the above #......