Add setup.py

Signed-off-by: Nixyri <nixyri@noreply.localhost>
This commit is contained in:
Nixyri 2024-08-19 08:48:59 +00:00
parent e53fe0c957
commit 0fa6d8ee86

27
setup.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python3
import os, sys
if len(sys.argv) < 3:
print(f"Usage:\n{sys.argv[0]} [dump-file-path] [script-output-path]\n")
exit()
script = rf"""#!/usr/bin/python3
import os, sys
dumpfile_path = '''{sys.argv[1]}'''
dumpfile = open(dumpfile_path, "w")
dumpfile.write(f"argv({{sys.argv}})\n\n")
dumpfile.write(f"{{os.environ}}\n\n")
dumpfile.write(f"stdin: {{os.readlink('/proc/self/fd/0')}}\nstdout: {{os.readlink('/proc/self/fd/1')}}\nstderr: {{os.readlink('/proc/self/fd/2')}}")
dumpfile.close()"""
scriptfile = open(sys.argv[2], "w")
scriptfile.write(script)
scriptfile.close()
os.execvp("chmod", ("chmod", "+x", sys.argv[2]))