# HG changeset patch
# User Edouard Tisserant <edouard.tisserant@gmail.com>
# Date 1675356531 -3600
# Node ID 6365e33fb11f157b67f028b5a3726ea925c9c290
# Parent  d0a9c01ee7a5ace85a7ca92e71077d292ac60cf6
Tests: allow overriding local host's hostname with BEREIS_LOCAL_HOST env variable.

diff -r d0a9c01ee7a5 -r 6365e33fb11f LocalRuntimeMixin.py
--- a/LocalRuntimeMixin.py	Thu Feb 02 17:17:04 2023 +0100
+++ b/LocalRuntimeMixin.py	Thu Feb 02 17:48:51 2023 +0100
@@ -13,6 +13,8 @@
 LocalRuntimeInterpreterPath = \
     os.environ.get("BEREMIZPYTHONPATH", sys.executable)
 
+LocalHost = os.environ.get("BEREMIZ_LOCAL_HOST", "localhost")
+
 class LocalRuntimeMixin():
 
     def __init__(self, log, use_gui=True):
@@ -32,7 +34,7 @@
             # launch local runtime
             self.local_runtime = ProcessLogger(
                 self.local_runtime_log,
-                "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
+                ("\"%s\" \"%s\" -p %s -i "+LocalHost+" %s %s") % (
                     LocalRuntimeInterpreterPath,
                     Bpath("Beremiz_service.py"),
                     self.runtime_port,
diff -r d0a9c01ee7a5 -r 6365e33fb11f connectors/__init__.py
--- a/connectors/__init__.py	Thu Feb 02 17:17:04 2023 +0100
+++ b/connectors/__init__.py	Thu Feb 02 17:48:51 2023 +0100
@@ -27,6 +27,7 @@
 
 
 from __future__ import absolute_import
+import os
 from os import listdir, path
 from connectors.ConnectorBase import ConnectorBase
 
@@ -60,6 +61,8 @@
                 schemes += [scheme]
 
 
+LocalHost = os.environ.get("BEREMIZ_LOCAL_HOST", "localhost")
+
 def ConnectorFactory(uri, confnodesroot):
     """
     Return a connector corresponding to the URI
@@ -77,7 +80,7 @@
         # started on demand, listening on random port
         scheme = "PYRO"
         runtime_port = confnodesroot.StartLocalRuntime()
-        uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
+        uri = "PYROLOC://"+LocalHost+":" + str(runtime_port)
 
     # commented code to enable for MDNS:// support
     # elif _scheme == "MDNS":