PDFTranslate / script /_pystand_static.int
Ryuichi
Initial deployment
179eccc
Raw History Blame Contribute Delete
1.02 kB
import sys
import pdf2zh_next.main
import os
import babeldoc.assets.assets
import pathlib
import asyncio
import multiprocessing
WAIT_FOR_INPUT = False
if len(sys.argv) == 1:
sys.argv.append("--gui") # 无参数时自动添加 -i 参数
WAIT_FOR_INPUT = True
multiprocessing.set_executable(os.path.join(os.path.dirname(__file__), 'runtime', 'pythonw.exe'))
files = os.listdir(os.path.dirname(__file__))
for file in files:
if file.endswith(".zip") and file.startswith("offline_assets_"):
print('find offline_assets_zip file: ', file, ' try restore...')
babeldoc.assets.assets.restore_offline_assets_package(pathlib.Path(os.path.dirname(__file__)))
try:
code = asyncio.run(pdf2zh_next.main.main())
print(f"pdf2zh_next.main.main() return code: {code}")
if WAIT_FOR_INPUT:
input("Press Enter to continue...")
sys.exit(code)
except Exception:
import traceback
traceback.print_exc()
if WAIT_FOR_INPUT:
input("Press Enter to continue...")
sys.exit(1)