def init(): rs_lib_path = util.find_library('rtipyroutingserviced') if rs_lib_path is None: raise ImportError('RoutingService native library not found.') rs_lib = PyDLL(rs_lib_path) if rs_lib.PyService_load() != 0: print(sys.last_value)
def comtypes_to_pywin(ptr, interface=None): _PyCom_PyObjectFromIUnknown = PyDLL(pythoncom.__file__).PyCom_PyObjectFromIUnknown _PyCom_PyObjectFromIUnknown.restype = py_object if interface is None: interface = IUnknown return _PyCom_PyObjectFromIUnknown(ptr, byref(interface._iid_), True)
def find_libRgraphapp(rhome): libRdir = os.path.join(rhome, "bin", "x64" if sys.maxsize > 2**32 else "i386") libRgraphapppath = os.path.join(libRdir, "Rgraphapp.dll") if not os.path.exists(libRgraphapppath): raise RuntimeError("Cannot locate Rgraphapp share library.") if RTLD_GLOBAL: return PyDLL(str(libRgraphapppath), mode=RTLD_GLOBAL) else: return PyDLL(str(libRgraphapppath))
def __comtype_to_pywin_obj(ptr, interface): """Convert a comtypes pointer 'ptr' into a pythoncom PyI<interface> object. 'interface' specifies the interface we want; it must be a comtypes interface class. The interface must be implemented by the object; and the interface must be known to pythoncom. """ com_obj = PyDLL(pythoncom.__file__).PyCom_PyObjectFromIUnknown com_obj.restype = ctypes.py_object com_obj.argtypes = (ctypes.POINTER(IUnknown), ctypes.c_void_p, BOOL) # noinspection PyProtectedMember return com_obj(ptr._comobj, byref(interface._iid_), True)
def __init__(self, r_home): if sys.platform.startswith("win"): libR_dir = os.path.join(r_home, "bin", "x64" if sys.maxsize > 2**32 else "i386") libR_path = os.path.join(libR_dir, "R.dll") elif sys.platform == "darwin": libR_path = os.path.join(r_home, "lib", "libR.dylib") elif sys.platform.startswith("linux"): libR_path = os.path.join(r_home, "lib", "libR.so") if not os.path.exists(libR_path): raise RuntimeError("Cannot locate R share library.") self.libR = PyDLL(str(libR_path)) if not hasattr(self.libR, "R_tryCatchError"): raise RuntimeError("rtichoke requires R 3.4.0 or above.")
def load_libR(rhome): if sys.platform.startswith("win"): libRdir = os.path.join(rhome, "bin", "x64" if sys.maxsize > 2**32 else "i386") libRpath = os.path.join(libRdir, "R.dll") elif sys.platform == "darwin": libRpath = os.path.join(rhome, "lib", "libR.dylib") else: libRpath = os.path.join(rhome, "lib", "libR.so") if not os.path.exists(libRpath): raise RuntimeError("Cannot locate R share library.") if RTLD_GLOBAL: return PyDLL(str(libRpath), mode=RTLD_GLOBAL) else: return PyDLL(str(libRpath))
def __init__(self, engine: str, logger=None) -> None: # Provide a default logger, if None provided if logger is None: logger = logging.getLogger('OpenEarthBMI') self.logger = logger # Assume C++ DLL with Python C API (i.e. Python.h) self.dll = dll = PyDLL(engine) # cache properties here self._implemented = {} # {name: bool or None} class Level(IntEnum): LEVEL_ALL = 0 LEVEL_DEBUG = 1 LEVEL_INFO = 2 LEVEL_WARNING = 3 LEVEL_ERROR = 4 LEVEL_FATAL = 5 LEVEL_NONE = 6 # typedef void (CALLCONV *Logger)(Level level, const char *msg) LOGGER = CFUNCTYPE(None, c_int, c_char_p) def logger_message(level, msg): """Logger message function for ctypes callback""" level = Level(level) msg = msg.decode() if level in (Level.LEVEL_ALL, Level.LEVEL_DEBUG): self.logger.debug(msg) elif level == Level.LEVEL_INFO: self.logger.info(msg) elif level == Level.LEVEL_WARNING: self.logger.warning(msg) elif level == Level.LEVEL_ERROR: self.logger.error(msg) elif level == Level.LEVEL_FATAL: self.logger.fatal(msg) elif level == Level.LEVEL_NONE: pass else: raise ValueError(level) # Important: keep this variable alive to prevent DLL crash self._callback_function = LOGGER(logger_message) # BMI_API void set_logger(Logger callback) dll.set_logger.argtypes = [LOGGER] dll.set_logger.restype = None
def __init__(self): if 'R_HOME' not in os.environ: Rhome = subprocess.check_output(["R", "RHOME"]).decode("utf-8").strip() os.environ['R_HOME'] = Rhome else: Rhome = os.environ['R_HOME'] os.environ["R_DOC_DIR"] = os.path.join(Rhome, "doc") os.environ["R_INCLUDE_DIR"] = os.path.join(Rhome, "include") os.environ["R_SHARE_DIR"] = os.path.join(Rhome, "share") if sys.platform.startswith("win"): libR_path = os.path.join(Rhome, "bin", ['i386', 'x64'][sys.maxsize > 2**32], "R.dll") elif sys.platform == "darwin": libR_path = os.path.join(Rhome, "lib", "libR.dylib") elif sys.platform.startswith("linux"): libR_path = os.path.join(Rhome, "lib", "libR.so") if not os.path.exists(libR_path): raise RuntimeError("Cannot locate R share library.") self.libR = PyDLL(str(libR_path))
def __init__(self): if 'R_HOME' not in os.environ: try: Rhome = subprocess.check_output(["R", "RHOME"]).decode("utf-8").strip() except Exception as e: if sys.platform.startswith("win"): Rexe = os.path.join( read_registry("Software\\R-Core\\R", "InstallPath")[0], "bin", "R.exe") Rhome = subprocess.check_output([Rexe, "RHOME"]).decode("utf-8").strip() else: raise e os.environ['R_HOME'] = Rhome else: Rhome = os.environ['R_HOME'] os.environ["R_DOC_DIR"] = os.path.join(Rhome, "doc") os.environ["R_INCLUDE_DIR"] = os.path.join(Rhome, "include") os.environ["R_SHARE_DIR"] = os.path.join(Rhome, "share") if sys.platform.startswith("win"): libR_dir = os.path.join(Rhome, "bin", ['i386', 'x64'][sys.maxsize > 2**32]) os.environ['PATH'] = libR_dir + ";" + os.environ['PATH'] libR_path = os.path.join(libR_dir, "R.dll") elif sys.platform == "darwin": libR_path = os.path.join(Rhome, "lib", "libR.dylib") elif sys.platform.startswith("linux"): libR_path = os.path.join(Rhome, "lib", "libR.so") if not os.path.exists(libR_path): raise RuntimeError("Cannot locate R share library.") self.libR = PyDLL(str(libR_path)) if not hasattr(self.libR, "R_tryCatchError"): raise RuntimeError("rice requires R 3.4.0 or above.")
import atexit from ctypes import cdll, CDLL, PyDLL, CFUNCTYPE, c_char_p, c_void_p from ctypes.util import find_library import os import sys from ctypes_declarations import prototype if sys.platform == 'win32': try: local_dlls = os.path.abspath(os.__file__ + "../../../DLLs") original_path = os.environ['PATH'] os.environ['PATH'] = "%s;%s" % (local_dlls, original_path) lgeos = PyDLL("geos.dll") except (ImportError, WindowsError): raise def free(m): try: cdll.msvcrt.free(m) except WindowsError: # XXX: See http://trac.gispython.org/projects/PCL/ticket/149 pass elif sys.platform == 'darwin': lib = find_library('geos_c') if lib is None: ## try a few more locations lib_paths = [ # The Framework build from Kyng Chaos: "/Library/Frameworks/GEOS.framework/Versions/Current/GEOS",
from __future__ import with_statement from contextlib import contextmanager, nested from threading import Thread from tempfile import mkdtemp from os.path import join as pjoin from os import (dup, fdopen, open as osopen, O_NONBLOCK, O_RDONLY, remove, rmdir, mkfifo) from fcntl import fcntl, F_GETFL, F_SETFL from select import select from sys import stdout, stderr from ctypes import PyDLL, CDLL, c_void_p, c_char_p, py_object pyapi = PyDLL(None) this_exe = CDLL(None) def make_fn(what, res, *args): what.restype = res what.argtypes = args return what FILE_p = c_void_p PyFile_AsFile = make_fn(pyapi.PyFile_AsFile, FILE_p, py_object) freopen = make_fn(this_exe.freopen, FILE_p, c_char_p, c_char_p, FILE_p)
if len(pylambda_workers) > 1: _write_log("WARNING: multiple pylambda worker libraries.") if len(pylambda_workers) == 0: _write_log("ERROR: Cannot find pylambda_worker extension library.", error = True) sys.exit(202) _write_log("INFO: Loading pylambda worker library: %s." % pylambda_workers[0]) # Set the dll load path if we are on windows if sys.platform == 'win32': set_windows_dll_path() try: pylambda_lib = PyDLL(pylambda_workers[0]) except Exception, e: _write_log("Error loading lambda library %s: %s" % (pylambda_workers[0], repr(e)), error = True) sys.exit(203) try: pylambda_lib.pylambda_worker_main.argtypes = [c_char_p, c_char_p] pylambda_lib.pylambda_worker_main.restype = c_int except Exception, e: _write_log("Error accessing pylambda_worker_main: %s\n" % repr(e), error = True) sys.exit(204) if not dry_run: # This call only returns after the parent process is done. result = pylambda_lib.pylambda_worker_main(c_char_p(main_dir), c_char_p(sys.argv[1])) else:
class RSession(object): libR = None _offset = None read_console = None write_console_ex = None process_event = None show_message = None clean_up = None def __init__(self): if 'R_HOME' not in os.environ: try: Rhome = subprocess.check_output(["R", "RHOME"]).decode("utf-8").strip() except Exception as e: if sys.platform.startswith("win"): Rexe = os.path.join( read_registry("Software\\R-Core\\R", "InstallPath")[0], "bin", "R.exe") Rhome = subprocess.check_output([Rexe, "RHOME"]).decode("utf-8").strip() else: raise e os.environ['R_HOME'] = Rhome else: Rhome = os.environ['R_HOME'] os.environ["R_DOC_DIR"] = os.path.join(Rhome, "doc") os.environ["R_INCLUDE_DIR"] = os.path.join(Rhome, "include") os.environ["R_SHARE_DIR"] = os.path.join(Rhome, "share") if sys.platform.startswith("win"): libR_dir = os.path.join(Rhome, "bin", ['i386', 'x64'][sys.maxsize > 2**32]) os.environ['PATH'] = libR_dir + ";" + os.environ['PATH'] libR_path = os.path.join(libR_dir, "R.dll") elif sys.platform == "darwin": libR_path = os.path.join(Rhome, "lib", "libR.dylib") elif sys.platform.startswith("linux"): libR_path = os.path.join(Rhome, "lib", "libR.so") if not os.path.exists(libR_path): raise RuntimeError("Cannot locate R share library.") self.libR = PyDLL(str(libR_path)) if not hasattr(self.libR, "R_tryCatchError"): raise RuntimeError("rice requires R 3.4.0 or above.") def run(self): _argv = ["rice", "--no-save", "--no-restore-data", "--quiet"] argn = len(_argv) argv = (c_char_p * argn)() for i, a in enumerate(_argv): argv[i] = c_char_p(a.encode('utf-8')) if sys.platform.startswith("win"): self.libR.R_setStartTime() self.setup_callbacks_win32() self.libR.R_set_command_line_arguments(argn, argv) else: self.libR.Rf_initialize_R(argn, argv) self.setup_callbacks_posix() self.libR.Rf_mainloop() @property def offset(self): if not self._offset: s = ccall("Rf_ScalarInteger", self.libR, c_void_p, [c_int], 0) self._offset = ccall("INTEGER", self.libR, c_void_p, [c_void_p], s).value - s.value return self._offset def polled_events(self): pass def ask_yes_no_cancel(self, string): raise "not yet implemented" def r_busy(self, which): pass def setup_callbacks_win32(self): rstart = RStart() self.libR.R_DefParams(pointer(rstart)) rstart.rhome = ccall("get_R_HOME", self.libR, POINTER(c_char), []) rstart.home = ccall("getRUser", self.libR, POINTER(c_char), []) rstart.CharacterMode = 0 rstart.ReadConsole = cast( CFUNCTYPE(c_int, c_char_p, POINTER(c_char), c_int, c_int)(self.read_console), c_void_p) rstart.WriteConsole = None rstart.WriteConsoleEx = cast( CFUNCTYPE(None, c_char_p, c_int, c_int)(self.write_console_ex), c_void_p) rstart.CallBack = cast(CFUNCTYPE(None)(self.polled_events), c_void_p) rstart.ShowMessage = cast(CFUNCTYPE(None, c_char_p)(self.show_message), c_void_p) rstart.YesNoCancel = cast(CFUNCTYPE(c_int, c_char_p)(self.ask_yes_no_cancel), c_void_p) rstart.Busy = cast(CFUNCTYPE(None, c_int)(self.r_busy), c_void_p) rstart.R_Quiet = 1 rstart.R_Interactive = 1 rstart.RestoreAction = 0 rstart.SaveAction = 0 self.libR.R_SetParams(pointer(rstart)) self.rstart = rstart def setup_callbacks_posix(self): # ptr_R_Suicide if self.show_message: self.ptr_show_message = CFUNCTYPE(None, c_char_p)(self.show_message) ptr = c_void_p.in_dll(self.libR, 'ptr_R_ShowMessage') ptr.value = cast(self.ptr_show_message, c_void_p).value if self.read_console: # make sure it is not gc'ed self.ptr_read_console = \ CFUNCTYPE(c_int, c_char_p, POINTER(c_char), c_int, c_int)(self.read_console) ptr = c_void_p.in_dll(self.libR, 'ptr_R_ReadConsole') ptr.value = cast(self.ptr_read_console, c_void_p).value if self.write_console_ex: c_void_p.in_dll(self.libR, 'ptr_R_WriteConsole').value = None # make sure it is not gc'ed self.ptr_write_console_ex = \ CFUNCTYPE(None, c_char_p, c_int, c_int)(self.write_console_ex) ptr = c_void_p.in_dll(self.libR, 'ptr_R_WriteConsoleEx') ptr.value = cast(self.ptr_write_console_ex, c_void_p).value # ptr_R_ResetConsole # ptr_R_FlushConsole # ptr_R_ClearerrConsole if self.r_busy: self.ptr_r_busy = CFUNCTYPE(None, c_int)(self.r_busy) ptr = c_void_p.in_dll(self.libR, 'ptr_R_Busy') ptr.value = cast(self.ptr_r_busy, c_void_p).value if self.clean_up: ptr = c_void_p.in_dll(self.libR, 'ptr_R_CleanUp') R_CleanUp = ctypes.PYFUNCTYPE(None, c_int, c_int, c_int)(ptr.value) def _handler(save_type, status, runlast): self.clean_up(save_type, status, runlast) R_CleanUp(save_type, status, runlast) self.ptr_r_clean_up = ctypes.PYFUNCTYPE(None, c_int, c_int, c_int)(_handler) ptr.value = cast(self.ptr_r_clean_up, c_void_p).value # ptr_R_ShowFiles # ptr_R_ChooseFile # ptr_R_EditFile # ptr_R_loadhistory # ptr_R_savehistory # ptr_R_addhistory # ptr_R_EditFiles # ptr_do_selectlist # ptr_do_dataentry # ptr_do_dataviewer if self.process_event: self.ptr_process_event = CFUNCTYPE(None)(self.process_event) ptr = c_void_p.in_dll(self.libR, 'ptr_R_ProcessEvents') ptr.value = cast(self.ptr_process_event, c_void_p).value if self.polled_events: self.ptr_polled_events = CFUNCTYPE(None)(self.polled_events) ptr = c_void_p.in_dll(self.libR, 'R_PolledEvents') ptr.value = cast(self.ptr_polled_events, c_void_p).value
"""Trace code, so that libpymemprofile_api know's where we are.""" import atexit from ctypes import PyDLL from datetime import datetime import os import sys import threading import webbrowser from ._utils import timestamp_now, library_path from ._report import render_report preload = PyDLL(library_path("_filpreload")) preload.fil_initialize_from_python() def start_tracing(output_path: str): path = os.path.join(output_path, timestamp_now()).encode("utf-8") preload.fil_reset(path) threading.setprofile(_start_thread_trace) preload.register_fil_tracer() def _start_thread_trace(frame, event, arg): """Trace function that can be passed to sys.settrace. All this does is register the underlying C trace function, using the mechanism described in https://github.com/nedbat/coveragepy/blob/master/coverage/ctracer/tracer.c's CTracer_call.
visited_files.append((name, repr(os.lstat(name)))) except: visited_files.append((name, "ERROR calling os.lstat.")) def strip_name(n): if n[:len(main_dir)] == main_dir: return "<root>/" + n[len(main_dir):] else: return n print "\n".join((" %s: %s" % (strip_name(name), stats)) for name, stats in sorted(visited_files)) print "INFO: Loading pylambda worker library: ", pylambda_workers[0] pylambda_lib = PyDLL(pylambda_workers[0]) pylambda_lib.pylambda_worker_main.argtypes = [c_char_p, c_char_p] pylambda_lib.pylambda_worker_main.restype = c_int if not debug_mode: # This call only returns after the parent process is done. result = pylambda_lib.pylambda_worker_main(c_char_p(main_dir), c_char_p(sys.argv[1])) else: # This version will print out a bunch of diagnostic information and then exit. result = pylambda_lib.pylambda_worker_main(c_char_p(main_dir), c_char_p("debug")) if debug_mode: print "Process exited with code %d." % result
import os import sys import shutil # Rough way to add to the Python path. # TODO: find a cleaner way to implement this. You have to switch # directories currently to find it. for src in ["ocaml.so", "../_build/default/python/ocaml.so"]: if os.path.exists(src): shutil.copyfile(src, "mcl/ocaml.so") sys.path.append(".") ## Enables the shared object file to be understood by Python from ctypes import PyDLL, RTLD_GLOBAL, c_char_p curdir = dir_path = os.path.dirname(os.path.realpath(__file__)) dll = PyDLL(f"{curdir}/ocaml.so", RTLD_GLOBAL) argv_t = c_char_p * 2 argv = argv_t("ocaml.so".encode('utf-8'), None) dll.caml_startup(argv) # Import relevant files from ZXBuilder import ZXBuilder from CirqBuilder import StrictCirqBuilder, ValidCirqBuilder
return ptr def is_hwnd_xl_app(hwnd): try: child_hwnd = win32gui.FindWindowEx(hwnd, 0, 'XLDESK', None) child_hwnd = win32gui.FindWindowEx(child_hwnd, 0, 'EXCEL7', None) ptr = accessible_object_from_window(child_hwnd) return True except WindowsError: return False except pywintypes.error: return False _PyCom_PyObjectFromIUnknown = PyDLL( pythoncom.__file__).PyCom_PyObjectFromIUnknown _PyCom_PyObjectFromIUnknown.restype = py_object def get_xl_app_from_hwnd(hwnd): pythoncom.CoInitialize() child_hwnd = win32gui.FindWindowEx(hwnd, 0, 'XLDESK', None) child_hwnd = win32gui.FindWindowEx(child_hwnd, 0, 'EXCEL7', None) ptr = accessible_object_from_window(child_hwnd) p = _PyCom_PyObjectFromIUnknown(ptr, byref(_IDISPATCH_GUID), True) disp = COMRetryObjectWrapper(Dispatch(p)) return disp.Application def get_excel_hwnds():
import sys # The libgraphserver.so object: lgs = None # Try loading from the source tree. If that doesn't work, fall back to the installed location. _dlldirs = [ os.path.dirname(os.path.abspath(__file__)), os.path.dirname(os.path.abspath(__file__)) + '/../../core', '/usr/lib', '/usr/local/lib' ] for _dlldir in _dlldirs: _dllpath = os.path.join(_dlldir, 'libgraphserver.so') if os.path.exists(_dllpath): lgs = PyDLL(_dllpath) break if not lgs: raise ImportError( "unable to find libgraphserver shared library in the usual locations: %s" % "\n".join(_dlldirs)) libc = cdll.LoadLibrary(find_library('c')) class _EmptyClass(object): pass def instantiate(cls):
try: import pythoncom except ImportError: # pywin32 not installed... pass else: # pywin32 is available. The pythoncom dll contains two handy # exported functions that allow to create a VARIANT from a Python # object, also a function that unpacks a VARIANT into a Python # object. # # This allows us to create und unpack SAFEARRAY instances # contained in VARIANTs, and check for consistency with the # comtypes code. _dll = PyDLL(pythoncom.__file__) # c:/sf/pywin32/com/win32com/src/oleargs.cpp 213 # PyObject *PyCom_PyObjectFromVariant(const VARIANT *var) unpack = _dll.PyCom_PyObjectFromVariant unpack.restype = py_object unpack.argtypes = POINTER(VARIANT), # c:/sf/pywin32/com/win32com/src/oleargs.cpp 54 # BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var) _pack = _dll.PyCom_VariantFromPyObject _pack.argtypes = py_object, POINTER(VARIANT) _pack.restype = BOOL def pack(obj): var = VARIANT()
from comtypes.automation import IDispatch from comtypes.test import requires requires("pythoncom") import pythoncom import win32com.client # We use the PyCom_PyObjectFromIUnknown function in pythoncom25.dll to # convert a comtypes COM pointer into a pythoncom COM pointer. # Fortunately this function is exported by the dll... # # This is the C prototype; we must pass 'True' as third argument: # # PyObject *PyCom_PyObjectFromIUnknown(IUnknown *punk, REFIID riid, BOOL bAddRef) _PyCom_PyObjectFromIUnknown = PyDLL(pythoncom.__file__).PyCom_PyObjectFromIUnknown _PyCom_PyObjectFromIUnknown.restype = py_object _PyCom_PyObjectFromIUnknown.argtypes = (POINTER(IUnknown), c_void_p, BOOL) def comtypes2pywin(ptr, interface=None): """Convert a comtypes pointer 'ptr' into a pythoncom PyI<interface> object. 'interface' specifies the interface we want; it must be a comtypes interface class. The interface must be implemented by the object; and the interface must be known to pythoncom. If 'interface' is specified, comtypes.IUnknown is used. """ if interface is None: interface = IUnknown
# We use the PyCom_PyObjectFromIUnknown function in pythoncom25.dll to # convert a comtypes COM pointer into a pythoncom COM pointer. # Fortunately this function is exported by the dll... # # This is the C prototype; we must pass 'True' as third argument: # # PyObject *PyCom_PyObjectFromIUnknown(IUnknown *punk, REFIID riid, BOOL bAddRef) _PyCom_PyObjectFromIUnknown = PyDLL( pythoncom.__file__).PyCom_PyObjectFromIUnknown _PyCom_PyObjectFromIUnknown.restype = py_object _PyCom_PyObjectFromIUnknown.argtypes = (POINTER(IUnknown), c_void_p, BOOL) def comtypes2pywin(ptr, interface=None): """Convert a comtypes pointer 'ptr' into a pythoncom PyI<interface> object. 'interface' specifies the interface we want; it must be a comtypes
from ctypes import PyDLL, py_object, c_int from sys import exit from os import path import numpy as np my_path = path.abspath(path.dirname(__file__)) path = path.join(my_path, "./bin/libmotion_detector_optimization.so") try: lib = PyDLL(path) lib.c_scan.restype = py_object lib.c_scan.argtypes = [py_object, c_int] lib.c_find_bounding_boxes.restype = py_object lib.c_find_bounding_boxes.argtypes = [py_object] lib.c_pack.restype = py_object lib.c_pack.argtypes = [py_object, py_object] except OSError: print("Error when loading lib") exit(1) def scan(img: np.ndarray, expansion_step: int): return lib.c_scan(img, expansion_step) def optimize_bounding_boxes(rectangles): if rectangles is None or not len(rectangles): return [] return lib.c_find_bounding_boxes(rectangles)
_write_log("WARNING: multiple pylambda worker libraries.") if len(pylambda_workers) == 0: _write_log("ERROR: Cannot find pylambda_worker extension library.", error=True) sys.exit(202) _write_log("INFO: Loading pylambda worker library: %s." % pylambda_workers[0]) # Set the dll load path if we are on windows if sys.platform == 'win32': set_windows_dll_path() try: pylambda_lib = PyDLL(pylambda_workers[0]) except Exception, e: _write_log("Error loading lambda library %s: %s" % (pylambda_workers[0], repr(e)), error=True) sys.exit(203) try: pylambda_lib.pylambda_worker_main.argtypes = [ c_char_p, c_char_p, c_int ] pylambda_lib.pylambda_worker_main.restype = c_int except Exception, e: _write_log("Error accessing pylambda_worker_main: %s\n" % repr(e), error=True) sys.exit(204)