Beremiz_service.py
changeset 2431 6923074540dd
parent 2427 9554952d36d7
child 2439 f0a040f1de1b
equal deleted inserted replaced
2427:9554952d36d7 2431:6923074540dd
    30 import sys
    30 import sys
    31 import getopt
    31 import getopt
    32 import threading
    32 import threading
    33 from threading import Thread, Semaphore, Lock
    33 from threading import Thread, Semaphore, Lock
    34 import traceback
    34 import traceback
    35 import __builtin__
    35 from six.moves import builtins
    36 import Pyro
    36 import Pyro
    37 import Pyro.core as pyro
    37 import Pyro.core as pyro
    38 
    38 
    39 from runtime import PLCObject, ServicePublisher, MainWorker
    39 from runtime import PLCObject, ServicePublisher, MainWorker
    40 from runtime.xenomai import TryPreloadXenomai
    40 from runtime.xenomai import TryPreloadXenomai
   141 elif len(argv) == 0:
   141 elif len(argv) == 0:
   142     WorkingDir = os.getcwd()
   142     WorkingDir = os.getcwd()
   143     argv = [WorkingDir]
   143     argv = [WorkingDir]
   144 
   144 
   145 if __name__ == '__main__':
   145 if __name__ == '__main__':
   146     __builtin__.__dict__['_'] = lambda x: x
   146     builtins.__dict__['_'] = lambda x: x
   147     # TODO: add a cmdline parameter if Trying Preloading Xenomai makes problem
   147     # TODO: add a cmdline parameter if Trying Preloading Xenomai makes problem
   148     TryPreloadXenomai()
   148     TryPreloadXenomai()
   149     version()
   149     version()
   150 
   150 
   151 
   151 
   160     langid = wx.LANGUAGE_DEFAULT
   160     langid = wx.LANGUAGE_DEFAULT
   161     # Define translation domain (name of translation files)
   161     # Define translation domain (name of translation files)
   162     domain = "Beremiz"
   162     domain = "Beremiz"
   163 
   163 
   164     # Define locale for wx
   164     # Define locale for wx
   165     loc = __builtin__.__dict__.get('loc', None)
   165     loc = builtins.__dict__.get('loc', None)
   166     if loc is None:
   166     if loc is None:
   167         wx.LogGui.EnableLogging(False)
   167         wx.LogGui.EnableLogging(False)
   168         loc = wx.Locale(langid)
   168         loc = wx.Locale(langid)
   169         wx.LogGui.EnableLogging(True)
   169         wx.LogGui.EnableLogging(True)
   170         __builtin__.__dict__['loc'] = loc
   170         builtins.__dict__['loc'] = loc
   171         # Define location for searching translation files
   171         # Define location for searching translation files
   172     loc.AddCatalogLookupPathPrefix(localedir)
   172     loc.AddCatalogLookupPathPrefix(localedir)
   173     # Define locale domain
   173     # Define locale domain
   174     loc.AddCatalog(domain)
   174     loc.AddCatalog(domain)
   175 
   175 
   184     # automatically converted to 'ascii' string.
   184     # automatically converted to 'ascii' string.
   185     def unicode_translation(message):
   185     def unicode_translation(message):
   186         return wx.GetTranslation(message).encode(default_locale)
   186         return wx.GetTranslation(message).encode(default_locale)
   187 
   187 
   188     if __name__ == '__main__':
   188     if __name__ == '__main__':
   189         __builtin__.__dict__['_'] = unicode_translation
   189         builtins.__dict__['_'] = unicode_translation
   190         # __builtin__.__dict__['_'] = wx.GetTranslation
   190         # builtins.__dict__['_'] = wx.GetTranslation
   191 
   191 
   192 
   192 
   193 # Life is hard... have a candy.
   193 # Life is hard... have a candy.
   194 # pylint: disable=wrong-import-position,wrong-import-order
   194 # pylint: disable=wrong-import-position,wrong-import-order
   195 if enablewx:
   195 if enablewx: