proton: Check that we're running as a script

This commit is contained in:
Andrew Eikum 2019-07-29 14:09:28 -05:00
parent 055e095af7
commit d0346080bd

75
proton
View File

@ -660,52 +660,53 @@ class Session:
self.run_proc([g_proton.wine_bin, "steam"] + sys.argv[2:]) self.run_proc([g_proton.wine_bin, "steam"] + sys.argv[2:])
if not "STEAM_COMPAT_DATA_PATH" in os.environ: if __name__ == "__main__":
log("No compat data path?") if not "STEAM_COMPAT_DATA_PATH" in os.environ:
sys.exit(1) log("No compat data path?")
sys.exit(1)
g_proton = Proton(os.path.dirname(sys.argv[0])) g_proton = Proton(os.path.dirname(sys.argv[0]))
g_proton.extract_tarball() g_proton.extract_tarball()
g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"]) g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"])
g_session = Session() g_session = Session()
g_session.init_wine() g_session.init_wine()
g_proton.make_default_prefix() g_proton.make_default_prefix()
g_session.init_session() g_session.init_session()
if sys.version_info[0] == 2: if sys.version_info[0] == 2:
binary_stdout = sys.stdout binary_stdout = sys.stdout
elif sys.version_info[0] == 3: elif sys.version_info[0] == 3:
binary_stdout = sys.stdout.buffer binary_stdout = sys.stdout.buffer
else: else:
raise Exception("Unsupported python version") raise Exception("Unsupported python version")
#determine mode #determine mode
if sys.argv[1] == "run": if sys.argv[1] == "run":
#start target app #start target app
g_session.run() g_session.run()
elif sys.argv[1] == "waitforexitandrun": elif sys.argv[1] == "waitforexitandrun":
#wait for wineserver to shut down #wait for wineserver to shut down
g_session.run_proc([g_proton.wineserver_bin, "-w"]) g_session.run_proc([g_proton.wineserver_bin, "-w"])
#then run #then run
g_session.run() g_session.run()
elif sys.argv[1] == "getcompatpath": elif sys.argv[1] == "getcompatpath":
#linux -> windows path #linux -> windows path
path = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", sys.argv[2]], env=g_session.env, stderr=g_session.log_file) path = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", sys.argv[2]], env=g_session.env, stderr=g_session.log_file)
binary_stdout.write(path) binary_stdout.write(path)
elif sys.argv[1] == "getnativepath": elif sys.argv[1] == "getnativepath":
#windows -> linux path #windows -> linux path
path = subprocess.check_output([g_proton.wine_bin, "winepath", sys.argv[2]], env=g_session.env, stderr=g_session.log_file) path = subprocess.check_output([g_proton.wine_bin, "winepath", sys.argv[2]], env=g_session.env, stderr=g_session.log_file)
binary_stdout.write(path) binary_stdout.write(path)
else: else:
log("Need a verb.") log("Need a verb.")
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)
# vim: set syntax=python: # vim: set syntax=python: