File size: 1,023 Bytes
179eccc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)