pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytron/__init__.py +112 -0
- pytron/application.py +562 -0
- pytron/apputils/__init__.py +0 -0
- pytron/apputils/chrome_ipc.py +203 -0
- pytron/apputils/codegen.py +261 -0
- pytron/apputils/config.py +303 -0
- pytron/apputils/deadmansswitch.py +47 -0
- pytron/apputils/extras.py +76 -0
- pytron/apputils/native.py +148 -0
- pytron/apputils/shell.py +73 -0
- pytron/apputils/windows.py +286 -0
- pytron/cli.py +384 -0
- pytron/commands/__init__.py +0 -0
- pytron/commands/android.py +28 -0
- pytron/commands/build.py +26 -0
- pytron/commands/doctor.py +221 -0
- pytron/commands/engine.py +23 -0
- pytron/commands/frontend.py +60 -0
- pytron/commands/harvest.py +112 -0
- pytron/commands/helpers.py +239 -0
- pytron/commands/info.py +50 -0
- pytron/commands/init.py +521 -0
- pytron/commands/install.py +294 -0
- pytron/commands/login.py +130 -0
- pytron/commands/package.py +228 -0
- pytron/commands/plugin.py +442 -0
- pytron/commands/run.py +312 -0
- pytron/commands/scan.py +210 -0
- pytron/commands/show.py +23 -0
- pytron/commands/uninstall.py +150 -0
- pytron/commands/utils.py +42 -0
- pytron/commands/workflow.py +95 -0
- pytron/console.py +133 -0
- pytron/core.py +18 -0
- pytron/dependencies/WebView2Loader.dll +0 -0
- pytron/dependencies/__init__.py +1 -0
- pytron/dependencies/pytron_native.so +0 -0
- pytron/engines/chrome/adapter.py +445 -0
- pytron/engines/chrome/engine.py +576 -0
- pytron/engines/chrome/forge.py +147 -0
- pytron/engines/chrome/shell/package.json +8 -0
- pytron/engines/chrome/shell/preload.js +12 -0
- pytron/engines/chrome/shell/shell.js +534 -0
- pytron/exceptions.py +36 -0
- pytron/inspector.py +201 -0
- pytron/inspector_ui.py +512 -0
- pytron/installer/Installation.nsi +236 -0
- pytron/installer/header.bmp +0 -0
- pytron/installer/pytron.ico +0 -0
- pytron/installer/sidebar.bmp +0 -0
- pytron/llms.md +98 -0
- pytron/manifests/README.md +29 -0
- pytron/manifests/windows-utf8.manifest +44 -0
- pytron/menu.py +128 -0
- pytron/nsis-setup.exe +0 -0
- pytron/pack/__init__.py +0 -0
- pytron/pack/assets.py +131 -0
- pytron/pack/compilers.py +289 -0
- pytron/pack/crystal.py +297 -0
- pytron/pack/graph.py +377 -0
- pytron/pack/inference.py +157 -0
- pytron/pack/installers.py +402 -0
- pytron/pack/introspect.py +357 -0
- pytron/pack/metadata.py +213 -0
- pytron/pack/modules.py +618 -0
- pytron/pack/nuitka.py +108 -0
- pytron/pack/pipeline.py +107 -0
- pytron/pack/pyinstaller.py +176 -0
- pytron/pack/rust_engine.py +273 -0
- pytron/pack/secure.py +309 -0
- pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
- pytron/pack/secure_loader/icon.ico +0 -0
- pytron/pack/utils.py +110 -0
- pytron/pack/virtual_root.py +124 -0
- pytron/platforms/__init__.py +0 -0
- pytron/platforms/android/__init__.py +3 -0
- pytron/platforms/android/android.py +103 -0
- pytron/platforms/android/builder.py +736 -0
- pytron/platforms/android/ops/build.py +79 -0
- pytron/platforms/android/ops/init.py +63 -0
- pytron/platforms/android/ops/run.py +79 -0
- pytron/platforms/android/ops/sync.py +770 -0
- pytron/platforms/android/ops/utils.py +8 -0
- pytron/platforms/android/shell/README.md +30 -0
- pytron/platforms/android/shell/app/build.gradle +64 -0
- pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
- pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
- pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
- pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
- pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- pytron/platforms/android/shell/build.gradle +11 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
- pytron/platforms/android/shell/gradle.properties +2 -0
- pytron/platforms/android/shell/gradlew.bat +85 -0
- pytron/platforms/android/shell/settings.gradle +16 -0
- pytron/platforms/darwin.py +82 -0
- pytron/platforms/darwin_ops/libs.py +31 -0
- pytron/platforms/darwin_ops/system.py +182 -0
- pytron/platforms/darwin_ops/utils.py +85 -0
- pytron/platforms/darwin_ops/webview.py +5 -0
- pytron/platforms/darwin_ops/window.py +102 -0
- pytron/platforms/interface.py +152 -0
- pytron/platforms/linux.py +82 -0
- pytron/platforms/linux_ops/libs.py +49 -0
- pytron/platforms/linux_ops/system.py +316 -0
- pytron/platforms/linux_ops/utils.py +19 -0
- pytron/platforms/linux_ops/webview.py +5 -0
- pytron/platforms/linux_ops/window.py +115 -0
- pytron/platforms/windows.py +136 -0
- pytron/platforms/windows_ops/__init__.py +0 -0
- pytron/platforms/windows_ops/constants.py +126 -0
- pytron/platforms/windows_ops/system.py +518 -0
- pytron/platforms/windows_ops/utils.py +3 -0
- pytron/platforms/windows_ops/webview.py +5 -0
- pytron/platforms/windows_ops/window.py +361 -0
- pytron/plugin.py +467 -0
- pytron/rcedit-x64.exe +0 -0
- pytron/router.py +146 -0
- pytron/serializer.py +240 -0
- pytron/shortcuts.py +279 -0
- pytron/state.py +76 -0
- pytron/tray.py +399 -0
- pytron/updater.py +181 -0
- pytron/utf8_hook.py +112 -0
- pytron/utils.py +44 -0
- pytron/webview.py +722 -0
- pytron_kit-0.3.12.dist-info/METADATA +131 -0
- pytron_kit-0.3.12.dist-info/RECORD +419 -0
- pytron_kit-0.3.12.dist-info/WHEEL +5 -0
- pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
- pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
- pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
import threading
|
|
6
|
+
import socket
|
|
7
|
+
import uuid
|
|
8
|
+
import struct
|
|
9
|
+
import subprocess
|
|
10
|
+
import tempfile
|
|
11
|
+
import ctypes
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from ...dependencies import pytron_native
|
|
15
|
+
except ImportError:
|
|
16
|
+
pytron_native = None
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger("Pytron.ChromeAdapter")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ChromeIPCServer:
|
|
22
|
+
"""
|
|
23
|
+
A robust Platform-Native IPC server for the Chrome Engine.
|
|
24
|
+
Uses TWO Simplex Named Pipes (Windows) or Sockets (Unix) to avoid Duplex Blocking Deadlocks.
|
|
25
|
+
|
|
26
|
+
- Windows:
|
|
27
|
+
- \\\\.\\pipe\\pytron-{uuid}-in (Python Writes -> Electron Reads)
|
|
28
|
+
- \\\\.\\pipe\\pytron-{uuid}-out (Electron Writes -> Python Reads)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self):
|
|
32
|
+
self.connected = False
|
|
33
|
+
self._lock = threading.Lock()
|
|
34
|
+
self.listening_event = threading.Event()
|
|
35
|
+
self.pipe_path_base = None
|
|
36
|
+
|
|
37
|
+
# Native implementation (Rust)
|
|
38
|
+
self._native = None
|
|
39
|
+
if pytron_native:
|
|
40
|
+
try:
|
|
41
|
+
self._native = pytron_native.ChromeIPC()
|
|
42
|
+
except:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
# Windows Handles (Fallback)
|
|
46
|
+
self._win_in_handle = None
|
|
47
|
+
self._win_out_handle = None
|
|
48
|
+
|
|
49
|
+
# Unix Sockets (Fallback)
|
|
50
|
+
self._sock = None
|
|
51
|
+
|
|
52
|
+
self.is_windows = sys.platform == "win32"
|
|
53
|
+
|
|
54
|
+
def listen(self):
|
|
55
|
+
uid = str(uuid.uuid4())
|
|
56
|
+
|
|
57
|
+
if self._native:
|
|
58
|
+
try:
|
|
59
|
+
self.pipe_path_base = self._native.listen(uid)
|
|
60
|
+
self.listening_event.set()
|
|
61
|
+
logger.info(f"Mojo IPC (Native) listening on: {self.pipe_path_base}")
|
|
62
|
+
self._native.wait_for_connection()
|
|
63
|
+
self.connected = True
|
|
64
|
+
logger.info("Mojo Shell connected via Native Pipes")
|
|
65
|
+
return
|
|
66
|
+
except Exception as e:
|
|
67
|
+
logger.warning(
|
|
68
|
+
f"Native IPC failed to listen ({e}), falling back to ctypes."
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if self.is_windows:
|
|
72
|
+
self._listen_windows(uid)
|
|
73
|
+
else:
|
|
74
|
+
self._listen_unix(uid)
|
|
75
|
+
|
|
76
|
+
def _listen_windows(self, uid):
|
|
77
|
+
# We need TWO pipes.
|
|
78
|
+
# 1. OUTBOUND (Python -> Electron)
|
|
79
|
+
# 2. INBOUND (Electron -> Python)
|
|
80
|
+
|
|
81
|
+
self.pipe_path_base = f"\\\\.\\pipe\\pytron-{uid}"
|
|
82
|
+
path_in = self.pipe_path_base + "-in" # We Write
|
|
83
|
+
path_out = self.pipe_path_base + "-out" # We Read
|
|
84
|
+
|
|
85
|
+
PIPE_ACCESS_DUPLEX = 0x00000003 # Node.js expects Duplex even if we use simplex
|
|
86
|
+
PIPE_TYPE_BYTE = 0x00000000
|
|
87
|
+
PIPE_READMODE_BYTE = 0x00000000
|
|
88
|
+
PIPE_WAIT = 0x00000000
|
|
89
|
+
INVALID_HANDLE_VALUE = -1
|
|
90
|
+
|
|
91
|
+
# 1. Create IN Pipe (Python Write)
|
|
92
|
+
self._win_in_handle = ctypes.windll.kernel32.CreateNamedPipeW(
|
|
93
|
+
path_in,
|
|
94
|
+
PIPE_ACCESS_DUPLEX, # 0x3
|
|
95
|
+
PIPE_TYPE_BYTE | PIPE_WAIT,
|
|
96
|
+
1,
|
|
97
|
+
65536,
|
|
98
|
+
65536,
|
|
99
|
+
0,
|
|
100
|
+
None,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# 2. Create OUT Pipe (Python Read)
|
|
104
|
+
self._win_out_handle = ctypes.windll.kernel32.CreateNamedPipeW(
|
|
105
|
+
path_out,
|
|
106
|
+
PIPE_ACCESS_DUPLEX, # 0x3
|
|
107
|
+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
|
|
108
|
+
1,
|
|
109
|
+
65536,
|
|
110
|
+
65536,
|
|
111
|
+
0,
|
|
112
|
+
None,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
self._win_in_handle == INVALID_HANDLE_VALUE
|
|
117
|
+
or self._win_out_handle == INVALID_HANDLE_VALUE
|
|
118
|
+
):
|
|
119
|
+
raise RuntimeError(f"Failed to create Dual Named Pipes")
|
|
120
|
+
|
|
121
|
+
# SIGNAL READY
|
|
122
|
+
self.listening_event.set()
|
|
123
|
+
logger.info(
|
|
124
|
+
f"Mojo IPC listening on Dual Pipes: {self.pipe_path_base} (-in/-out)"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# BLOCK until client connects to BOTH
|
|
128
|
+
# Electron must connect to IN (Reader) then OUT (Writer)
|
|
129
|
+
|
|
130
|
+
# Connect IN
|
|
131
|
+
logger.info("Waiting for Electron to connect to IN pipe...")
|
|
132
|
+
# ConnectNamedPipe returns 0 on failure, non-zero on success.
|
|
133
|
+
# But if client already connected between Create and Connect, it returns 0 and GetLastError=ERROR_PIPE_CONNECTED (535)
|
|
134
|
+
conn_res_in = ctypes.windll.kernel32.ConnectNamedPipe(self._win_in_handle, None)
|
|
135
|
+
if conn_res_in == 0:
|
|
136
|
+
err = ctypes.GetLastError()
|
|
137
|
+
if err != 535: # ERROR_PIPE_CONNECTED
|
|
138
|
+
logger.error(f"ConnectNamedPipe (IN) failed with error {err}")
|
|
139
|
+
return
|
|
140
|
+
|
|
141
|
+
# Connect OUT
|
|
142
|
+
logger.info("Waiting for Electron to connect to OUT pipe...")
|
|
143
|
+
conn_res_out = ctypes.windll.kernel32.ConnectNamedPipe(
|
|
144
|
+
self._win_out_handle, None
|
|
145
|
+
)
|
|
146
|
+
if conn_res_out == 0:
|
|
147
|
+
err = ctypes.GetLastError()
|
|
148
|
+
if err != 535: # ERROR_PIPE_CONNECTED
|
|
149
|
+
logger.error(f"ConnectNamedPipe (OUT) failed with error {err}")
|
|
150
|
+
return
|
|
151
|
+
|
|
152
|
+
self.connected = True
|
|
153
|
+
logger.info("Mojo Shell connected via Dual Pipes")
|
|
154
|
+
|
|
155
|
+
def _listen_unix(self, uid):
|
|
156
|
+
# Fallback to single socket for Unix for now unless requested
|
|
157
|
+
self.pipe_path_base = os.path.join(tempfile.gettempdir(), f"pytron-{uid}.sock")
|
|
158
|
+
if os.path.exists(self.pipe_path_base):
|
|
159
|
+
os.remove(self.pipe_path_base)
|
|
160
|
+
|
|
161
|
+
self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
162
|
+
self._sock.bind(self.pipe_path_base)
|
|
163
|
+
self._sock.listen(1)
|
|
164
|
+
|
|
165
|
+
self.listening_event.set()
|
|
166
|
+
logger.info(f"Mojo IPC listening on UDS: {self.pipe_path_base}")
|
|
167
|
+
|
|
168
|
+
self.conn, addr = self._sock.accept()
|
|
169
|
+
self.conn.setblocking(True)
|
|
170
|
+
self.connected = True
|
|
171
|
+
logger.info(f"Mojo Shell connected from {addr}")
|
|
172
|
+
|
|
173
|
+
def read_loop(self, callback):
|
|
174
|
+
if self._native:
|
|
175
|
+
try:
|
|
176
|
+
# The native read loop runs in its own thread and calls back to Python
|
|
177
|
+
self._native.start_read_loop(callback)
|
|
178
|
+
# We need to block here like the original read_loop did, to keep the thread alive
|
|
179
|
+
# or until disconnect.
|
|
180
|
+
while self.connected:
|
|
181
|
+
threading.Event().wait(1.0)
|
|
182
|
+
return
|
|
183
|
+
except Exception as e:
|
|
184
|
+
logger.error(f"Native IPC Read Loop Error: {e}")
|
|
185
|
+
self.connected = False
|
|
186
|
+
return
|
|
187
|
+
|
|
188
|
+
while self.connected:
|
|
189
|
+
try:
|
|
190
|
+
# 1. Read 4-byte Header
|
|
191
|
+
header = self._recv_bytes(4)
|
|
192
|
+
if not header or len(header) != 4:
|
|
193
|
+
break
|
|
194
|
+
msg_len = struct.unpack("<I", header)[0]
|
|
195
|
+
|
|
196
|
+
# 2. Read Body
|
|
197
|
+
body = self._recv_bytes(msg_len)
|
|
198
|
+
if not body or len(body) != msg_len:
|
|
199
|
+
break
|
|
200
|
+
|
|
201
|
+
# 3. Dispatch
|
|
202
|
+
msg = json.loads(body.decode("utf-8"))
|
|
203
|
+
callback(msg)
|
|
204
|
+
except Exception as e:
|
|
205
|
+
logger.error(f"IPC Read Error: {e}")
|
|
206
|
+
break
|
|
207
|
+
self.connected = False
|
|
208
|
+
# Cleanup
|
|
209
|
+
if self.is_windows:
|
|
210
|
+
if self._win_in_handle:
|
|
211
|
+
ctypes.windll.kernel32.CloseHandle(self._win_in_handle)
|
|
212
|
+
if self._win_out_handle:
|
|
213
|
+
ctypes.windll.kernel32.CloseHandle(self._win_out_handle)
|
|
214
|
+
if not self.is_windows and self.pipe_path_base:
|
|
215
|
+
try:
|
|
216
|
+
os.remove(self.pipe_path_base)
|
|
217
|
+
except:
|
|
218
|
+
pass
|
|
219
|
+
|
|
220
|
+
def _recv_bytes(self, n):
|
|
221
|
+
if self.is_windows:
|
|
222
|
+
buf = ctypes.create_string_buffer(n)
|
|
223
|
+
read = ctypes.c_ulong(0)
|
|
224
|
+
# Read from OUT handle
|
|
225
|
+
res = ctypes.windll.kernel32.ReadFile(
|
|
226
|
+
self._win_out_handle, buf, n, ctypes.byref(read), None
|
|
227
|
+
)
|
|
228
|
+
if res == 0:
|
|
229
|
+
err = ctypes.GetLastError()
|
|
230
|
+
# 109 = ERROR_BROKEN_PIPE (Normal EOF when client disconnects)
|
|
231
|
+
if err != 109:
|
|
232
|
+
logger.error(f"ReadFile Failed. Error: {err}, Requested: {n}")
|
|
233
|
+
else:
|
|
234
|
+
logger.warning(f"Pipe Disconnected (ERROR_BROKEN_PIPE).")
|
|
235
|
+
return None
|
|
236
|
+
|
|
237
|
+
if read.value != n:
|
|
238
|
+
logger.error(f"ReadFile checking Partial Read: Got {read.value} / {n}")
|
|
239
|
+
return None
|
|
240
|
+
|
|
241
|
+
return buf.raw
|
|
242
|
+
else:
|
|
243
|
+
# Unix Socket
|
|
244
|
+
data = bytearray()
|
|
245
|
+
while len(data) < n:
|
|
246
|
+
packet = self.conn.recv(n - len(data))
|
|
247
|
+
if not packet:
|
|
248
|
+
return None
|
|
249
|
+
data.extend(packet)
|
|
250
|
+
return data
|
|
251
|
+
|
|
252
|
+
def send(self, data_dict):
|
|
253
|
+
if not self.connected:
|
|
254
|
+
return
|
|
255
|
+
with self._lock:
|
|
256
|
+
try:
|
|
257
|
+
body_str = json.dumps(data_dict)
|
|
258
|
+
|
|
259
|
+
if self._native:
|
|
260
|
+
self._native.send(body_str)
|
|
261
|
+
return
|
|
262
|
+
|
|
263
|
+
body = body_str.encode("utf-8")
|
|
264
|
+
header = struct.pack("<I", len(body))
|
|
265
|
+
full_msg = header + body
|
|
266
|
+
|
|
267
|
+
if self.is_windows:
|
|
268
|
+
written = ctypes.c_ulong(0)
|
|
269
|
+
# Write to IN handle
|
|
270
|
+
ctypes.windll.kernel32.WriteFile(
|
|
271
|
+
self._win_in_handle,
|
|
272
|
+
full_msg,
|
|
273
|
+
len(full_msg),
|
|
274
|
+
ctypes.byref(written),
|
|
275
|
+
None,
|
|
276
|
+
)
|
|
277
|
+
else:
|
|
278
|
+
self.conn.sendall(full_msg)
|
|
279
|
+
|
|
280
|
+
except Exception as e:
|
|
281
|
+
if self.connected:
|
|
282
|
+
logger.error(f"IPC Send Error: {e}")
|
|
283
|
+
self.connected = False
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class ChromeAdapter:
|
|
287
|
+
def __init__(self, binary_path, config=None):
|
|
288
|
+
self.binary_path = binary_path
|
|
289
|
+
self.config = config or {}
|
|
290
|
+
self.process = None
|
|
291
|
+
self.ipc = None
|
|
292
|
+
self.ready = False
|
|
293
|
+
self._raw_callback = None
|
|
294
|
+
self._queue = []
|
|
295
|
+
self._flush_lock = threading.Lock()
|
|
296
|
+
|
|
297
|
+
def start(self):
|
|
298
|
+
self.ipc = ChromeIPCServer()
|
|
299
|
+
|
|
300
|
+
# Start the server thread
|
|
301
|
+
def _server_launcher():
|
|
302
|
+
self.ipc.listen()
|
|
303
|
+
self.ipc.read_loop(self._on_message)
|
|
304
|
+
|
|
305
|
+
threading.Thread(target=_server_launcher, daemon=True).start()
|
|
306
|
+
|
|
307
|
+
# WAIT FOR THE PIPE NAME
|
|
308
|
+
if not self.ipc.listening_event.wait(timeout=10.0):
|
|
309
|
+
raise RuntimeError("Failed to init IPC pipe within 10 seconds")
|
|
310
|
+
|
|
311
|
+
app_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "shell"))
|
|
312
|
+
|
|
313
|
+
# FIX: Pass current working directory as root for pytron:// protocol
|
|
314
|
+
pipe_arg = (
|
|
315
|
+
self.ipc.pipe_path_base if self.ipc.is_windows else self.ipc.pipe_path_base
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
# Use explicit CWD from config if available (set by Engine calculation)
|
|
319
|
+
# otherwise fall back to process CWD.
|
|
320
|
+
pytron_root = self.config.get("cwd", os.getcwd())
|
|
321
|
+
|
|
322
|
+
cmd = [
|
|
323
|
+
self.binary_path,
|
|
324
|
+
app_path,
|
|
325
|
+
f"--pytron-pipe={pipe_arg}",
|
|
326
|
+
f"--pytron-root={pytron_root}",
|
|
327
|
+
]
|
|
328
|
+
|
|
329
|
+
# Force software rendering if needed (optional, good for VM stability)
|
|
330
|
+
if self.config.get("software_render"):
|
|
331
|
+
cmd.append("--disable-gpu")
|
|
332
|
+
|
|
333
|
+
if self.config.get("debug"):
|
|
334
|
+
cmd.append("--inspect")
|
|
335
|
+
|
|
336
|
+
# FIX: Set the subprocess CWD to the Project Root (pytron_root)
|
|
337
|
+
# instead of the Shell Binary Directory.
|
|
338
|
+
# This ensures process.cwd() in Electron matches the Project Root,
|
|
339
|
+
# which is critical for 'pytron://' protocol resolution if the flag is ignored.
|
|
340
|
+
|
|
341
|
+
# Ensure we don't break binary loading, though.
|
|
342
|
+
# binary_path is abs path, and app_path is abs path. Should be fine.
|
|
343
|
+
|
|
344
|
+
logger.info(f"Spawning Mojo Process (IPC): {' '.join(cmd)}")
|
|
345
|
+
self.process = subprocess.Popen(
|
|
346
|
+
cmd,
|
|
347
|
+
stdout=subprocess.PIPE,
|
|
348
|
+
stderr=subprocess.PIPE,
|
|
349
|
+
cwd=pytron_root,
|
|
350
|
+
text=True,
|
|
351
|
+
bufsize=1,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
# Dead Man's Switch: Kill Python if Electron dies
|
|
355
|
+
from ...apputils.deadmansswitch import DeadMansSwitch
|
|
356
|
+
|
|
357
|
+
self._dms = DeadMansSwitch(self.process)
|
|
358
|
+
|
|
359
|
+
threading.Thread(
|
|
360
|
+
target=self._proxy_logs, args=(self.process.stdout, "STDOUT"), daemon=True
|
|
361
|
+
).start()
|
|
362
|
+
threading.Thread(
|
|
363
|
+
target=self._proxy_logs, args=(self.process.stderr, "STDERR"), daemon=True
|
|
364
|
+
).start()
|
|
365
|
+
|
|
366
|
+
def _proxy_logs(self, pipe, prefix):
|
|
367
|
+
try:
|
|
368
|
+
while True:
|
|
369
|
+
line = pipe.readline()
|
|
370
|
+
if not line:
|
|
371
|
+
break
|
|
372
|
+
|
|
373
|
+
content = line.strip()
|
|
374
|
+
if not content:
|
|
375
|
+
continue
|
|
376
|
+
|
|
377
|
+
# Filter out benign Electron noises
|
|
378
|
+
if "DevTools listening on" in content:
|
|
379
|
+
continue
|
|
380
|
+
if "GpuProcess" in content and "error" in content.lower():
|
|
381
|
+
# Common benign GPU errors in headless/embedded
|
|
382
|
+
continue
|
|
383
|
+
|
|
384
|
+
if prefix == "STDOUT":
|
|
385
|
+
# If it's a console.log from our Shell.js, it might already have a tag
|
|
386
|
+
if content.startswith("[Mojo-Shell]"):
|
|
387
|
+
logger.info(content)
|
|
388
|
+
else:
|
|
389
|
+
logger.debug(f"[Electron] {content}")
|
|
390
|
+
else:
|
|
391
|
+
# STDERR usually contains Chromium warnings
|
|
392
|
+
logger.warning(f"[Electron-Err] {content}")
|
|
393
|
+
|
|
394
|
+
except Exception as e:
|
|
395
|
+
logger.debug(f"Log proxy error: {e}")
|
|
396
|
+
|
|
397
|
+
def _flush_queue(self):
|
|
398
|
+
with self._flush_lock:
|
|
399
|
+
count = len(self._queue)
|
|
400
|
+
logger.info(f"Flushing {count} queued messages via IPC...")
|
|
401
|
+
flushed = 0
|
|
402
|
+
while self._queue:
|
|
403
|
+
msg = self._queue.pop(0)
|
|
404
|
+
try:
|
|
405
|
+
# Log the critical 'show' or 'init' commands to verify order
|
|
406
|
+
action = msg.get("action") if isinstance(msg, dict) else "unknown"
|
|
407
|
+
if action in ["init", "show", "navigate"]:
|
|
408
|
+
logger.info(f"Flushing critical command: {action}")
|
|
409
|
+
|
|
410
|
+
self.ipc.send(msg)
|
|
411
|
+
flushed += 1
|
|
412
|
+
# Reduced sleep to 0, relying on OS buffering
|
|
413
|
+
except Exception as e:
|
|
414
|
+
logger.error(f"Failed to flush message {action}: {e}")
|
|
415
|
+
logger.info(f"Flush complete. Sent {flushed}/{count} messages.")
|
|
416
|
+
|
|
417
|
+
def _on_message(self, msg):
|
|
418
|
+
if isinstance(msg, str):
|
|
419
|
+
try:
|
|
420
|
+
msg = json.loads(msg)
|
|
421
|
+
except Exception as e:
|
|
422
|
+
logger.error(f"Failed to parse native IPC message: {e}")
|
|
423
|
+
return
|
|
424
|
+
|
|
425
|
+
msg_type = msg.get("type")
|
|
426
|
+
payload = msg.get("payload")
|
|
427
|
+
logger.debug(f"Mojo Received: {msg_type} -> {payload}")
|
|
428
|
+
|
|
429
|
+
if msg_type == "lifecycle" and payload == "app_ready":
|
|
430
|
+
logger.info("Mojo Handshake (app_ready) received. Initiating flush.")
|
|
431
|
+
self.ready = True
|
|
432
|
+
threading.Thread(target=self._flush_queue, daemon=True).start()
|
|
433
|
+
|
|
434
|
+
if self._raw_callback:
|
|
435
|
+
self._raw_callback(msg)
|
|
436
|
+
|
|
437
|
+
def send(self, payload):
|
|
438
|
+
if self.ipc and self.ipc.connected and self.ready:
|
|
439
|
+
self.ipc.send(payload)
|
|
440
|
+
else:
|
|
441
|
+
with self._flush_lock:
|
|
442
|
+
self._queue.append(payload)
|
|
443
|
+
|
|
444
|
+
def bind_raw(self, callback):
|
|
445
|
+
self._raw_callback = callback
|