def check_syntax_script(prog, commandline, script): if not script: return False # TODO: test that "prog" is available/executable tmpfile, tmpname = Pkg.mktemp() try: tmpfile.write(script) tmpfile.close() ret = Pkg.getstatusoutput((prog, commandline, tmpname)) finally: tmpfile.close() os.remove(tmpname) return ret[0]