From fe2c0bb9e424d9e54edd292a431b9c4844a6c8dc Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 5 Jan 2015 14:00:54 +0000 Subject: [PATCH] Move un/setenv from python backend to utils --- source/carla_backend.py | 26 ------------------ source/carla_database.py | 4 +-- source/carla_utils.py | 28 ++++++++++++++++++++ source/native-plugins/resources/carla-plugin | 2 +- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/source/carla_backend.py b/source/carla_backend.py index b43d4136b..aa5199914 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -1215,32 +1215,6 @@ class CarlaHostMeta(object): self.pathBinaries = "" self.pathResources = "" - # use _putenv on windows - if not WINDOWS: - self.msvcrt = None - return - - self.msvcrt = cdll.msvcrt - self.msvcrt._putenv.argtypes = [c_char_p] - self.msvcrt._putenv.restype = None - - # set environment variable - def setenv(self, key, value): - environ[key] = value - - if WINDOWS: - keyvalue = "%s=%s" % (key, value) - self.msvcrt._putenv(keyvalue.encode("utf-8")) - - # unset environment variable - def unsetenv(self, key): - if environ.get(key) is not None: - environ.pop(key) - - if WINDOWS: - keyrm = "%s=" % key - self.msvcrt._putenv(keyrm.encode("utf-8")) - # Get how many engine drivers are available. @abstractmethod def get_engine_driver_count(self): diff --git a/source/carla_database.py b/source/carla_database.py index 14ef20bd7..1d29f10ec 100755 --- a/source/carla_database.py +++ b/source/carla_database.py @@ -1038,9 +1038,9 @@ class PluginRefreshW(QDialog): self.ui.group_options.setEnabled(False) if self.ui.ch_do_checks.isChecked(): - self.host.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS") + gCarla.utils.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS") else: - self.host.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true") + gCarla.utils.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true") native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(), self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(), diff --git a/source/carla_utils.py b/source/carla_utils.py index 0eb5d72e5..1d2547dcd 100644 --- a/source/carla_utils.py +++ b/source/carla_utils.py @@ -214,6 +214,34 @@ class CarlaUtils(object): self.lib.carla_pipe_client_destroy.argtypes = [CarlaPipeClientHandle] self.lib.carla_pipe_client_destroy.restype = None + # use _putenv on windows + if not WINDOWS: + self.msvcrt = None + return + + self.msvcrt = cdll.msvcrt + self.msvcrt._putenv.argtypes = [c_char_p] + self.msvcrt._putenv.restype = None + + # -------------------------------------------------------------------------------------------------------- + + # set environment variable + def setenv(self, key, value): + environ[key] = value + + if WINDOWS: + keyvalue = "%s=%s" % (key, value) + self.msvcrt._putenv(keyvalue.encode("utf-8")) + + # unset environment variable + def unsetenv(self, key): + if environ.get(key) is not None: + environ.pop(key) + + if WINDOWS: + keyrm = "%s=" % key + self.msvcrt._putenv(keyrm.encode("utf-8")) + # -------------------------------------------------------------------------------------------------------- # Get the complete license text of used third-party code and features. diff --git a/source/native-plugins/resources/carla-plugin b/source/native-plugins/resources/carla-plugin index ea865e9fa..d4a0a2832 100755 --- a/source/native-plugins/resources/carla-plugin +++ b/source/native-plugins/resources/carla-plugin @@ -461,7 +461,7 @@ if __name__ == '__main__': except: winId = 0 - host.setenv("CARLA_PLUGIN_EMBED_WINID", "0") + gCarla.utils.setenv("CARLA_PLUGIN_EMBED_WINID", "0") if LINUX and winId != 0 and not config_UseQt5: gui = CarlaEmbedW(host, winId)