diff --git a/peikarband/__init__.py b/peikarband/__init__.py index a1a3a68..2aa2aed 100644 --- a/peikarband/__init__.py +++ b/peikarband/__init__.py @@ -43,14 +43,42 @@ try: # Look for peikarband/peikarband/__init__.py _peikarband_submodule_path = os.path.join(_peikarband_dir, 'peikarband', '__init__.py') + # #region agent log + try: + with open(_log_path, "a") as f: + f.write(json.dumps({"sessionId":"debug-session","runId":"run1","hypothesisId":"A","location":"peikarband/__init__.py:45","message":"Trying to register peikarband.peikarband","data":{"_peikarband_dir":_peikarband_dir,"_peikarband_submodule_path":_peikarband_submodule_path,"exists":os.path.exists(_peikarband_submodule_path)},"timestamp":int(os.path.getmtime(__file__)*1000) if os.path.exists(__file__) else 0})+"\n") + except: pass + # #endregion + if os.path.exists(_peikarband_submodule_path): _spec = importlib.util.spec_from_file_location("peikarband.peikarband", _peikarband_submodule_path) if _spec and _spec.loader: _peikarband_module = importlib.util.module_from_spec(_spec) # Register in sys.modules BEFORE exec_module sys.modules["peikarband.peikarband"] = _peikarband_module + + # #region agent log + try: + with open(_log_path, "a") as f: + f.write(json.dumps({"sessionId":"debug-session","runId":"run1","hypothesisId":"A","location":"peikarband/__init__.py:55","message":"Before exec_module","data":{"registered":"peikarband.peikarband" in sys.modules},"timestamp":int(os.path.getmtime(__file__)*1000) if os.path.exists(__file__) else 0})+"\n") + except: pass + # #endregion + _spec.loader.exec_module(_peikarband_module) -except Exception: + + # #region agent log + try: + with open(_log_path, "a") as f: + f.write(json.dumps({"sessionId":"debug-session","runId":"run1","hypothesisId":"A","location":"peikarband/__init__.py:60","message":"After exec_module","data":{"has_app":hasattr(_peikarband_module,"app"),"in_sys_modules":"peikarband.peikarband" in sys.modules},"timestamp":int(os.path.getmtime(__file__)*1000) if os.path.exists(__file__) else 0})+"\n") + except: pass + # #endregion +except Exception as e: + # #region agent log + try: + with open(_log_path, "a") as f: + f.write(json.dumps({"sessionId":"debug-session","runId":"run1","hypothesisId":"A","location":"peikarband/__init__.py:65","message":"Exception during registration","data":{"error":str(e),"error_type":type(e).__name__},"timestamp":int(os.path.getmtime(__file__)*1000) if os.path.exists(__file__) else 0})+"\n") + except: pass + # #endregion # Silently fail - if we can't register it, Python will try to import it normally pass