25 __version__ = "$Revision$" |
25 __version__ = "$Revision$" |
26 |
26 |
27 import os, sys, getopt, wx |
27 import os, sys, getopt, wx |
28 import tempfile |
28 import tempfile |
29 import shutil |
29 import shutil |
|
30 import random |
30 |
31 |
31 _local_path = os.path.split(os.path.realpath(__file__))[0] |
32 _local_path = os.path.split(os.path.realpath(__file__))[0] |
32 def Bpath(*args): |
33 def Bpath(*args): |
33 return os.path.join(_local_path,*args) |
34 return os.path.join(_local_path,*args) |
34 |
35 |
357 def __init__(self, parent, projectOpen): |
358 def __init__(self, parent, projectOpen): |
358 self._init_ctrls(parent) |
359 self._init_ctrls(parent) |
359 |
360 |
360 self.Log = LogPseudoFile(self.LogConsole) |
361 self.Log = LogPseudoFile(self.LogConsole) |
361 |
362 |
|
363 # create temporary directory for runtime working directory |
362 self.local_runtime_tmpdir = tempfile.mkdtemp() |
364 self.local_runtime_tmpdir = tempfile.mkdtemp() |
|
365 # choose an arbitrary random port for runtime |
|
366 runtime_port = int(random.random() * 1000) + 61131 |
|
367 # launch local runtime |
363 self.local_runtime = ProcessLogger(self.Log, |
368 self.local_runtime = ProcessLogger(self.Log, |
364 "%s %s -i localhost %s"%(sys.executable, |
369 "%s %s -p %s -i localhost %s"%(sys.executable, |
365 Bpath("Beremiz_service.py"), |
370 Bpath("Beremiz_service.py"), |
|
371 runtime_port, |
366 self.local_runtime_tmpdir)) |
372 self.local_runtime_tmpdir)) |
367 |
373 |
368 # Add beremiz's icon in top left corner of the frame |
374 # Add beremiz's icon in top left corner of the frame |
369 self.SetIcon(wx.Icon(Bpath( "images", "brz.ico"), wx.BITMAP_TYPE_ICO)) |
375 self.SetIcon(wx.Icon(Bpath( "images", "brz.ico"), wx.BITMAP_TYPE_ICO)) |
370 |
376 |
371 self.PluginRoot = PluginsRoot(self, self.Log) |
377 self.PluginRoot = PluginsRoot(self, self.Log, runtime_port) |
372 self.DisableEvents = False |
378 self.DisableEvents = False |
373 |
379 |
374 self.PluginInfos = {} |
380 self.PluginInfos = {} |
375 |
381 |
376 if projectOpen: |
382 if projectOpen: |