mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
sfx: improvements from r0c
This commit is contained in:
parent
7af159f5f6
commit
edf0d3684c
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: latin-1
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import os, sys, time, shutil, signal, tarfile, hashlib, platform, tempfile
|
import os, sys, time, shutil, runpy, tarfile, hashlib, platform, tempfile, traceback
|
||||||
import subprocess as sp
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
run me with any version of python, i will unpack and run copyparty
|
run me with any version of python, i will unpack and run copyparty
|
||||||
|
@ -344,20 +343,24 @@ def get_payload():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def confirm():
|
def confirm(rv):
|
||||||
msg()
|
msg()
|
||||||
|
msg(traceback.format_exc())
|
||||||
msg("*** hit enter to exit ***")
|
msg("*** hit enter to exit ***")
|
||||||
try:
|
try:
|
||||||
raw_input() if PY2 else input()
|
raw_input() if PY2 else input()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
sys.exit(rv)
|
||||||
|
|
||||||
|
|
||||||
def run(tmp, j2ver):
|
def run(tmp, j2ver):
|
||||||
global cpp
|
global cpp
|
||||||
|
|
||||||
msg("jinja2:", j2ver or "bundled")
|
msg("jinja2:", j2ver or "bundled")
|
||||||
msg("sfxdir:", tmp)
|
msg("sfxdir:", tmp)
|
||||||
|
msg()
|
||||||
|
|
||||||
# "systemd-tmpfiles-clean.timer"?? HOW do you even come up with this shit
|
# "systemd-tmpfiles-clean.timer"?? HOW do you even come up with this shit
|
||||||
try:
|
try:
|
||||||
|
@ -373,30 +376,16 @@ def run(tmp, j2ver):
|
||||||
if j2ver:
|
if j2ver:
|
||||||
del ld[-1]
|
del ld[-1]
|
||||||
|
|
||||||
cmd = (
|
for x in ld:
|
||||||
"import sys, runpy; "
|
sys.path.insert(0, x)
|
||||||
+ "".join(['sys.path.insert(0, r"' + x + '"); ' for x in ld])
|
|
||||||
+ 'runpy.run_module("copyparty", run_name="__main__")'
|
|
||||||
)
|
|
||||||
cmd = [sys.executable, "-c", cmd] + list(sys.argv[1:])
|
|
||||||
|
|
||||||
cmd = [str(x) for x in cmd]
|
|
||||||
msg("\n", cmd, "\n")
|
|
||||||
cpp = sp.Popen(cmd)
|
|
||||||
try:
|
try:
|
||||||
cpp.wait()
|
runpy.run_module(str("copyparty"), run_name=str("__main__"))
|
||||||
|
except SystemExit as ex:
|
||||||
|
if ex.code:
|
||||||
|
confirm(ex.code)
|
||||||
except:
|
except:
|
||||||
cpp.wait()
|
confirm(1)
|
||||||
|
|
||||||
if cpp.returncode != 0:
|
|
||||||
confirm()
|
|
||||||
|
|
||||||
sys.exit(cpp.returncode)
|
|
||||||
|
|
||||||
|
|
||||||
def bye(sig, frame):
|
|
||||||
if cpp is not None:
|
|
||||||
cpp.terminate()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -430,8 +419,6 @@ def main():
|
||||||
|
|
||||||
# skip 0
|
# skip 0
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, bye)
|
|
||||||
|
|
||||||
tmp = unpack()
|
tmp = unpack()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -439,7 +426,7 @@ def main():
|
||||||
except:
|
except:
|
||||||
j2ver = None
|
j2ver = None
|
||||||
|
|
||||||
return run(tmp, j2ver)
|
run(tmp, j2ver)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue