LocalRuntimeMixin.py
branchwxPython4
changeset 3566 7f5659b1eeb8
parent 3539 c2eec6aae07e
child 3714 c3a13fcbda3a
equal deleted inserted replaced
3565:6d3cb1ab1ef7 3566:7f5659b1eeb8
     1 #!/usr/bin/env python
     1 #!/usr/bin/env python
     2 # -*- coding: utf-8 -*-
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 import os
     3 import sys
     5 import sys
     4 import tempfile
     6 import tempfile
     5 import random
     7 import random
     6 import shutil
     8 import shutil
     7 from util.ProcessLogger import ProcessLogger
     9 from util.ProcessLogger import ProcessLogger
     8 from util.paths import Bpath
    10 from util.paths import Bpath
       
    11 
       
    12 LocalRuntimeInterpreterPath = \
       
    13     os.environ["BEREMIZPYTHONPATH"] \
       
    14     if os.environ.has_key("BEREMIZPYTHONPATH") \
       
    15     else sys.executable
     9 
    16 
    10 class LocalRuntimeMixin():
    17 class LocalRuntimeMixin():
    11 
    18 
    12     def __init__(self, log, use_gui=True):
    19     def __init__(self, log, use_gui=True):
    13         self.local_runtime_log = log
    20         self.local_runtime_log = log
    25             self.local_runtime_log.write(_("Starting local runtime...\n"))
    32             self.local_runtime_log.write(_("Starting local runtime...\n"))
    26             # launch local runtime
    33             # launch local runtime
    27             self.local_runtime = ProcessLogger(
    34             self.local_runtime = ProcessLogger(
    28                 self.local_runtime_log,
    35                 self.local_runtime_log,
    29                 "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
    36                 "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
    30                     sys.executable,
    37                     LocalRuntimeInterpreterPath,
    31                     Bpath("Beremiz_service.py"),
    38                     Bpath("Beremiz_service.py"),
    32                     self.runtime_port,
    39                     self.runtime_port,
    33                     {False: "-x 0", True: "-x 1"}[self.use_gui],
    40                     {False: "-x 0", True: "-x 1"}[self.use_gui],
    34                     self.local_runtime_tmpdir),
    41                     self.local_runtime_tmpdir),
    35                 no_gui=False,
    42                 no_gui=False,