mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
shrink the exe + add errorhandler
This commit is contained in:
parent
75a58b435d
commit
9d2e390b6a
|
@ -23,10 +23,16 @@ python copyparty-sfx.py --version
|
|||
rm -rf mods; mkdir mods
|
||||
cp -pR $TEMP/pe-copyparty/copyparty/ $TEMP/pe-copyparty/{ftp,j2}/* mods/
|
||||
|
||||
af() { awk "$1" <$2 >tf; mv tf "$2"; }
|
||||
|
||||
rm -rf mods/magic/
|
||||
grep -lR 'import multiprocessing' | while read x; do
|
||||
sed -ri 's/import multiprocessing/import fgsfds/' $x
|
||||
done
|
||||
|
||||
sed -ri /pickle/d mods/jinja2/_compat.py
|
||||
sed -ri '/(bccache|PackageLoader)/d' mods/jinja2/__init__.py
|
||||
af '/^class/{s=0}/^class PackageLoader/{s=1}!s' mods/jinja2/loaders.py
|
||||
|
||||
sed -ri /fork_process/d mods/pyftpdlib/servers.py
|
||||
af '/^class _Base/{s=1}!s' mods/pyftpdlib/authorizers.py
|
||||
|
||||
read a b c d _ < <(
|
||||
grep -E '^VERSION =' mods/copyparty/__version__.py |
|
||||
|
@ -37,6 +43,18 @@ sed -r 's/1,2,3,0/'$a,$b,$c,$d'/;s/1\.2\.3/'$a.$b.$c/ <loader.rc >loader.rc2
|
|||
|
||||
$APPDATA/python/python37/scripts/pyinstaller \
|
||||
-y --clean -p mods --upx-dir=. \
|
||||
--exclude-module copyparty.broker_mp \
|
||||
--exclude-module copyparty.broker_mpw \
|
||||
--exclude-module curses \
|
||||
--exclude-module ctypes.macholib \
|
||||
--exclude-module multiprocessing \
|
||||
--exclude-module pdb \
|
||||
--exclude-module pickle \
|
||||
--exclude-module pyftpdlib.prefork \
|
||||
--exclude-module urllib.request \
|
||||
--exclude-module urllib.response \
|
||||
--exclude-module urllib.robotparser \
|
||||
--exclude-module zipfile \
|
||||
--version-file loader.rc2 -i loader.ico -n copyparty -c -F loader.py \
|
||||
--add-data 'mods/copyparty/res;copyparty/res' \
|
||||
--add-data 'mods/copyparty/web;copyparty/web'
|
||||
|
|
|
@ -17,10 +17,23 @@ import re
|
|||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import traceback
|
||||
import subprocess as sp
|
||||
|
||||
|
||||
def meicln(mod, pids):
|
||||
def confirm(rv):
|
||||
print()
|
||||
print("retcode", rv if rv else traceback.format_exc())
|
||||
print("*** hit enter to exit ***")
|
||||
try:
|
||||
input()
|
||||
except:
|
||||
pass
|
||||
|
||||
sys.exit(rv or 1)
|
||||
|
||||
|
||||
def meicln(mod):
|
||||
pdir, mine = os.path.split(mod)
|
||||
dirs = os.listdir(pdir)
|
||||
dirs = [x for x in dirs if x.startswith("_MEI") and x != mine]
|
||||
|
@ -61,7 +74,7 @@ def meichk():
|
|||
|
||||
mod = os.path.dirname(os.path.realpath(__file__))
|
||||
if os.path.basename(mod).startswith("_MEI") and len(pids) == 2:
|
||||
meicln(mod, pids)
|
||||
meicln(mod)
|
||||
|
||||
|
||||
meichk()
|
||||
|
@ -69,4 +82,13 @@ meichk()
|
|||
|
||||
from copyparty.__main__ import main
|
||||
|
||||
try:
|
||||
main()
|
||||
except SystemExit as ex:
|
||||
c = ex.code
|
||||
if c not in [0, -15]:
|
||||
confirm(ex.code)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except:
|
||||
confirm(0)
|
||||
|
|
Loading…
Reference in a new issue