File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import asyncio
33import mimetypes
44import os
5- import runpy
65import sys
76from pathlib import Path
87
9-
10- def _run_python_compat_mode_if_needed () -> None :
11- """Support subprocess calls that expect a Python interpreter in frozen mode."""
12- if not getattr (sys , "frozen" , False ):
13- return
14-
15- if len (sys .argv ) < 2 :
16- return
17-
18- command = sys .argv [1 ]
19-
20- if command == "-c" :
21- if len (sys .argv ) < 3 :
22- raise SystemExit ("astrbot-backend: argument expected for -c" )
23- code = sys .argv [2 ]
24- sys .argv = ["-c" , * sys .argv [3 :]]
25- exec (code , {"__name__" : "__main__" , "__package__" : None , "__spec__" : None }) # noqa: S102
26- raise SystemExit (0 )
27-
28- if command == "-m" :
29- if len (sys .argv ) < 3 :
30- raise SystemExit ("astrbot-backend: argument expected for -m" )
31- module_name = sys .argv [2 ]
32- sys .argv = [module_name , * sys .argv [3 :]]
33- runpy .run_module (module_name , run_name = "__main__" , alter_sys = True )
34- raise SystemExit (0 )
35-
36- script_path = Path (command )
37- if script_path .is_file ():
38- resolved_script = script_path .resolve ().as_posix ()
39- sys .argv = [resolved_script , * sys .argv [2 :]]
40- runpy .run_path (resolved_script , run_name = "__main__" )
41- raise SystemExit (0 )
42-
43-
44- _run_python_compat_mode_if_needed ()
45-
468import runtime_bootstrap # noqa: E402
479
4810runtime_bootstrap .initialize_runtime_bootstrap ()
You can’t perform that action at this time.
0 commit comments