From 8fea983b7ef65620b009bc7d8fd67d3399100128 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 29 Mar 2021 16:48:27 +0100 Subject: [PATCH] CHanged custom_logging_function so that the custom temp dir is used properly --- binarycpython/utils/custom_logging_functions.py | 8 ++++++-- binarycpython/utils/grid.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/binarycpython/utils/custom_logging_functions.py b/binarycpython/utils/custom_logging_functions.py index c0d963c43..218f3ae97 100644 --- a/binarycpython/utils/custom_logging_functions.py +++ b/binarycpython/utils/custom_logging_functions.py @@ -366,7 +366,7 @@ def compile_shared_lib( def create_and_load_logging_function( - custom_logging_code: str, verbose: int = 0 + custom_logging_code: str, verbose: int = 0, custom_tmp_dir=None ) -> Tuple[int, str]: """ Function to automatically compile the shared library with the given @@ -382,9 +382,13 @@ def create_and_load_logging_function( Returns: memory adress of the custom logging function in a int type. """ - # + if not custom_tmp_dir: + tmp_dir = temp_dir() + else: + tmp_dir = custom_tmp_dir + library_name = os.path.join( temp_dir(), "libcustom_logging_{}.so".format(uuid.uuid4().hex) ) diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index 91f6b16ef..8d788d11c 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -586,7 +586,7 @@ class Population: self.grid_options["custom_logging_func_memaddr"], self.grid_options["_custom_logging_shared_library_file"], ) = create_and_load_logging_function( - custom_logging_code, verbose=self.grid_options["verbosity"] + custom_logging_code, verbose=self.grid_options["verbosity"], custom_tmp_dir=self.grid_options["tmp_dir"] ) elif self.grid_options["C_auto_logging"]: @@ -606,7 +606,7 @@ class Population: self.grid_options["custom_logging_func_memaddr"], self.grid_options["_custom_logging_shared_library_file"], ) = create_and_load_logging_function( - custom_logging_code, verbose=self.grid_options["verbosity"] + custom_logging_code, verbose=self.grid_options["verbosity"], custom_tmp_dir=self.grid_options["tmp_dir"] ) ################################################### -- GitLab