Beremiz_service.py
author laurent
Fri, 30 Sep 2011 17:12:27 +0200
changeset 619 8584ddae9385
parent 612 f44651506a88
child 622 885a224a35be
permissions -rw-r--r--
Fixes after moving xmlclass and docutils into plcopeneditor
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     1
#!/usr/bin/env python
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     2
# -*- coding: utf-8 -*-
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     3
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     4
#This file is part of Beremiz, a Integrated Development Environment for
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     5
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. 
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     6
#
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     7
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     8
#
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
     9
#See COPYING file for copyrights details.
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    10
#
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    11
#This library is free software; you can redistribute it and/or
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    12
#modify it under the terms of the GNU General Public
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    13
#License as published by the Free Software Foundation; either
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    15
#
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    16
#This library is distributed in the hope that it will be useful,
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    19
#General Public License for more details.
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    20
#
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    21
#You should have received a copy of the GNU General Public
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    22
#License along with this library; if not, write to the Free Software
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    24
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    25
import os, sys, getopt
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    26
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    27
def usage():
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    28
    print """
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    29
Usage of Beremiz PLC execution service :\n
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    30
%s {[-n servicename] [-i ip] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    31
           -n        - zeroconf service name (default:disabled)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    32
           -i        - ip of interface to bind to (default:localhost)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    33
           -p        - port number default:3000
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    34
           -h        - print this help text and quit
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    35
           -a        - autostart PLC (0:disable 1:enable) (default:0)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    36
           -x        - enable/disable wxTaskbarIcon (0:disable 1:enable) (default:1)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    37
           -t        - enable/disable Twisted web interface (0:disable 1:enable) (default:1)
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    38
           
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    39
           working_dir - directory where are stored PLC files
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    40
"""%sys.argv[0]
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    41
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    42
try:
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
    43
    opts, argv = getopt.getopt(sys.argv[1:], "i:p:n:x:t:a:h")
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    44
except getopt.GetoptError, err:
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    45
    # print help information and exit:
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    46
    print str(err) # will print something like "option -a not recognized"
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    47
    usage()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    48
    sys.exit(2)
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    49
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    50
# default values
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    51
ip = ""
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    52
port = 3000
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    53
servicename = None
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
    54
autostart = False
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    55
enablewx = True
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    56
havewx = False
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
    57
enabletwisted = True
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
    58
havetwisted = False
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    59
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    60
for o, a in opts:
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    61
    if o == "-h":
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    62
        usage()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    63
        sys.exit()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    64
    elif o == "-i":
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    65
        if len(a.split(".")) == 4 or a == "localhost":
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    66
            ip = a
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    67
    elif o == "-p":
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    68
        # port: port that the service runs on
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    69
        port = int(a)
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    70
    elif o == "-n":
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
    71
        servicename = a
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    72
    elif o == "-x":
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    73
        enablewx = int(a)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
    74
    elif o == "-t":
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
    75
        enabletwisted = int(a)
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
    76
    elif o == "-a":
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
    77
        autostart = int(a)
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    78
    else:
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    79
        usage()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    80
        sys.exit()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    81
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
    82
if len(argv) > 1:
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    83
    usage()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    84
    sys.exit()
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
    85
elif len(argv) == 1:
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
    86
    WorkingDir = argv[0]
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
    87
elif len(argv) == 0:
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    88
    WorkingDir = os.getcwd()
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
    89
    argv=[WorkingDir]
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
    90
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
    91
import __builtin__
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
    92
if __name__ == '__main__':
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
    93
    __builtin__.__dict__['_'] = lambda x: x
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
    94
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    95
if enablewx:
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    96
    try:
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    97
        import wx, re
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
    98
        from threading import Thread, currentThread
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
    99
        from types import *
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   100
        havewx = True
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   101
    except:
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   102
        print "Wx unavailable !"
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   103
        havewx = False
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   104
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   105
    if havewx:
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   106
        app=wx.App(redirect=False)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   107
        
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   108
        # Import module for internationalization
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   109
        import gettext
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   110
        
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   111
        CWD = os.path.split(os.path.realpath(__file__))[0]
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   112
        
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   113
        # Get folder containing translation files
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   114
        localedir = os.path.join(CWD,"locale")
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   115
        # Get the default language
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   116
        langid = wx.LANGUAGE_DEFAULT
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   117
        # Define translation domain (name of translation files)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   118
        domain = "Beremiz"
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   119
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   120
        # Define locale for wx
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   121
        loc = __builtin__.__dict__.get('loc', None)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   122
        if loc is None:
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   123
            loc = wx.Locale(langid)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   124
            __builtin__.__dict__['loc'] = loc
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   125
        # Define location for searching translation files
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   126
        loc.AddCatalogLookupPathPrefix(localedir)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   127
        # Define locale domain
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   128
        loc.AddCatalog(domain)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   129
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   130
        def unicode_translation(message):
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   131
            return wx.GetTranslation(message).encode("utf-8")
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   132
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   133
        if __name__ == '__main__':
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   134
            __builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   135
        
294
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   136
        try:
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   137
            from wx.lib.embeddedimage import PyEmbeddedImage
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   138
        except:
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   139
            import cStringIO
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   140
            import base64
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   141
            
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   142
            class PyEmbeddedImage:
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   143
                def __init__(self, image_string):
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   144
                    stream = cStringIO.StringIO(base64.b64decode(image_string))
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   145
                    self.Image = wx.ImageFromStream(stream)
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   146
                def GetImage(self):
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   147
                    return self.Image
39b3d4a2195b Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
lbessard
parents: 290
diff changeset
   148
        
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   149
        defaulticon = PyEmbeddedImage(
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   150
        "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABc5J"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   151
        "REFUSIl9lW1MW9cZx3/n2vf6BQO2MZiXGBISILCVUEUlitYpjaKpXZJ1XZZ2kzJVY9r6IeLD"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   152
        "pGTaNG3KtGmNNGlbpW3VFhRp0l6aZCllpVUqtVNJtBFKE5QXLxCjpCYEY7DBr9hcm3vPPgQY"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   153
        "IQmPdKR7/vd5/v/n5dxzhZSSNeYBOoGDQGcoFPINDAyUDQ0NOUdGRmyGYSiBQGCpoaGhuGnT"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   154
        "psShQ4f6WltbewEBVAK3gCBgrjJKKZFSKlLKeillt5Ty40gkMnnw4MFFQG60ysrKZHd3dyoe"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   155
        "j//bNM0Le/fuPd/e3r5lmRMpJWK5ghrgFeBIT09P4/Hjx73pdFo47HaaNlfRutnJru0OKsoE"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   156
        "E3GVqaSNa6EUw1dvIKWkoqKCrVu3FoeHh9WamppfRiKRn6wUYAUcwE7g2e7u7vrTp09XGIZB"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   157
        "W1Mdv3qtmoBPrG0hHVsMhKLj6nqOqOWn/Pjnv2dgYIC5uTl1uSM71/pbgUbg6bNnz/rPnDnj"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   158
        "dzoddO0P8Oo+jY2suDDD1Zv9DA1dfghXVbVBCFEqpcwAKEDTxMSE58SJE8+oqsq3nq/l1X0a"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   159
        "QihYtNLHLqRET03wuYp7fO9r26mpKlsVUBSl0W63V6/shZTyyIEDB344Njb21JYaG7/5bgkA"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   160
        "Dm8zTS/+7bHZLy0mSN+7yNztt8nPjYHFwfvXDf1P70zZ0ok0LS0tZy9fvvxNAGswGFQnJyef"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   161
        "KnM5+NHLzuUDsrFZ7R68zS/hrGon1PcNMPI0BIzs9tcCNvNfDqxW64uqqvqKxWJc6e3trVVV"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   162
        "leaAk6ryJ5N/9tH3GXv7Je7/5xermN3diMPXCkDfgrkg3UU0txWLxeLw+/1fB1BGR0frbTYb"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   163
        "TXWWDbNeysUoZKbIRIZBPviOzKU8ejLMHyPFcMprrweQ7iUAXC7XPiGEak2lUk02m42mWn1D"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   164
        "gfrnTiKNIrbyzSAUjEKWCx+/Mf+HyELBrLBvBhAIKDdgGsrLy+sAv1UIUa1pGv7yxQ0FbGX1"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   165
        "D+0LQmHW7fVavE5Mo/gAFCCcoOs6NpvNA7gVRVGCmqYRz1hXg7NFU39rjshawjcuvs4P+o/y"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   166
        "24uvE1+I4VCdfGfXUb76+VdWfQQCkbJSKBQoFApJTdMsCvApQDSlAjCTN7I/y5CNllpq1wqE"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   167
        "YmPciIzwwdi7BKevreK7Gp5dfbYoFoozJrquo+v6rMViWbQCV4QQzGTsQJY3kzIhvFpgfYte"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   168
        "7jhCMp9kk7uep+ueWcWj6f8Xqioq8ck0xcIS6XT6vpRy3gqMqKpqRBfKLLNF1ZRV6YBiPDrw"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   169
        "vduefwTL6hl6b74FgFVR0T4rJTU3jcvlymcymal8Ph+z9vf3p7u6uv5y/vz5bw994ld2fmUH"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   170
        "7nYFRVG4Gb3Guv8FpmmQzCcIJ+5w8c5HRFL3UYRC+ZKX633j6LpObW3tDcMwrsODq4Jbt27V"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   171
        "HT58+N7o6KgCYHfY2f2lXfi+6CJbnsAwjUeyXzFFKLgdHqb+mmL8xh22bduWmJycfHN2dvbX"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   172
        "uVwuoQC0tbXlKisrYytBi/lFZsKzOErtTyQWCOxWO36ljvl/FLk+dJOSkhJTUZR35+fn+3K5"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   173
        "XAIeXNcASz6fbxzwrxDYVQdqpARvs498IYchDUxpogiBVVFxqE7U/5Zx4c8fEo/FKS0tlR0d"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   174
        "HZ8ODg6+l06nr6zwrAp4PJ6Qpmlf2L9/fywYDFaOXB0RI1dHaGpuoq29Fa1Uxe62YeZMInei"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   175
        "jAY/IRqNAtDZ2blUV1fXPzg4+F5VVdU/H6p0eYjqsWPHvnz37t0XwuHw7d27d4eTyeTvLl26"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   176
        "FJiamnpim6qrq9mzZ094fHz875FI5J3p6ekr631WBARgaWlpCezYsePeuXPnzFAo5Dp58uS+"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   177
        "dDp91GKxNBYKBW82m3Vomqa7XK7pbDYbnJmZuR2LxYL5fP79WCyWeeys1h/D9e97enqsp06d"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   178
        "8mWzWU+xWPTkcjmXaZpxwzDCsVhsbqNggP8BMJOU3UUUf+0AAAAASUVORK5CYII=")
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   179
        
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   180
        #----------------------------------------------------------------------
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   181
        starticon = PyEmbeddedImage(
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   182
        "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABbpJ"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   183
        "REFUSIl9lltsFNcdxn9nZnbHs15fd23j9TXYC0UCKzEhMQ+oIS2g1kQ1pbFStX0opFWsovSh"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   184
        "rUqp2pS2ioTUolaKFOGHqGkiJcKRuDhOaZRiZCsCXyBgCBBfMfbu+oa9s17wzuzl9MH24mDD"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   185
        "XzoPc/6fft+c72jOGSGlZEVlAU8D9cB20zQ9HR0duRcvXszq7e01EomEUlFREa+srLR8Pl+g"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   186
        "sbHx3zk5ORcAFfACA8Bt4CFUSomUUkgpS6SUB6SUH5umOXLgwIEHqqrKJfGao7S0VB49ejRo"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   187
        "2/YnUsrT+/fvb66pqSldYiKlRCytoBB4Gfjx6dOnq5qamjwTExOKqqqU+QrYUJFN7QY32Qbc"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   188
        "vSeYCGtcux1i5M5dAPx+P1VVVQvnzp0ziouLfx8MBt9cXoAGZABbgZ1HjhwpO378eEEymaSi"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   189
        "tIBjPy9lU5nKoyWExF2yjy+mN3HsH+/Q3d3NwMCAsZTI9pVaDXgK2Hr27Nn85ubmEpdh8IMX"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   190
        "ffxirwshVrGXHBQSC/dIRvoZGuz/WkvTtHIhhCGlXABQgI2Tk5P5hw8f3uZwOGj8VjGHXnoC"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   191
        "HJCpJFbkLtr8FXbX+XC79HRPVVW/qqre9LtIKX/S0NDwy76+vq1lhTr/fM2NAmTk+fHv/dea"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   192
        "BlZkDHP0PHODH2NHg1gykw8/X7Dfb7vjTNgJqqurT3R1db0GoF2/fl0fGhqqdWca/K7RhZLO"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   193
        "WSBU55oGGXlVZORVkeV7nsFPDqKL+9TWJCI3n9rojX2mYhjGj4QQv5FSziunTp0qdjqd4hvl"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   194
        "Lnz5j49lrPMNhv7zM6b63knPuQpryMj3A9A2L++nvDaZXheqqrrXrVu3D0C5detWudPpxO/T"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   195
        "Hk8HYnOD3J+8yr3bH6XnZNImHg3xfsgenfHo5QAyJwFAdnb2HiGEppmmWa3rOhtKrCcalNT9"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   196
        "llTSwvBsXISn4nRdbJ5/czRsWvlGhQAEYtFg0kl2dnYZUKgB5U6nk5L82BMNXIU1X3uOWFH5"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   197
        "eWIuy/YYWcjU4qQAxQ22bWMYhgfIU1RV/UrXdWaiDyOyUiLROktoJfDtC8fZfWQbb//v75ix"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   198
        "MDlGnvjVC3+gflNDWiMQKPMalmVh2/a8w+HQFKAHIBR2ABCOS+uN6cTMoFstXmlwZbSba7tv"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   199
        "8hfzT7z+7k+ZnZ0BoK5yR1qjCBV7MoVt29i2PaWqqq0BvUIIQqYORHlrKj6R9BoVj0b04oY9"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   200
        "nEt+yvz3Y5yR/+Xap3XsDb/EtvV1aY1DdTA7HsW2bCKRyLiUclYBelRVldNWAfPSm4oV5ZQJ"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   201
        "Vn/G9Zv2oWt6Ous7e4K81XiC1wNNBO6OIWKgB7Mwp000TYuFw+GxWCw2qbS2tk7k5uae/eDD"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   202
        "Fn594p6SFyxRCjKLUBWF8fBoegTNMVLLm/kwdMyGGON/nePLklv0dl/Cii3gdrtvAzdg8aig"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   203
        "vb296uDBgwMjIyMCwFvoZXv9NvRnIKqHSckUyQdJrtfexPqm5LGVAuNdVaofcCVywfpexLYD"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   204
        "CsDOnTvnioqKzGXdzNQMV9tvkJEyUITyeOAjpYyAc9gxYc/GWyK2HYDF4xog6fV6h1i8FwCo"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   205
        "LK/EncwhkWGxEH9AXLMXM2H1CpQBifI3yeapZ+70d43+cSo4+95yL23g8XiGFUWp3bVrV/Ty"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   206
        "5ctZnR2ddHZ08uxzz1K9eT1GRhJls1gFlsfieK+WpJ5e/3z7pcuXzmia1rJSs3xlOg8dOvTD"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   207
        "8fHx7wQCgb4tW7bMm6b55/Pnz+eGw+FFGJDT5iT1XRWlfxHMZ06+/Vz9dCAQeG9kZKR1x44d"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   208
        "nSdPnkyuZSAArbq6eqOiKAP9/f3xlpaWgra2tlei0eiryWSyKGKa2TcaL+muwcxU5aDf9Gi+"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   209
        "L0Oh0BehUOiaZVlnAoHAzFr7Ih75bVnVb2pqcvf09Phi0ei6+/rUC6lw1k0p5bSUctThcIwP"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   210
        "Dw/HnwT4P6CDl+TMvD0JAAAAAElFTkSuQmCC")
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   211
        
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   212
        #----------------------------------------------------------------------
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   213
        stopicon = PyEmbeddedImage(
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   214
        "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABPRJ"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   215
        "REFUSImdlllsVGUUx3/f/e4sd5iZLjNt6XSFdtgkjWFRePABDaCBGgjamIg81CU0aoxbRHww"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   216
        "+EDkhWjEB5rYGEMUxQTCJg8EoQ2BbgrFCNJWltplgC63naEzd+bO50NLLVAq4STfwz3nfP/f"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   217
        "PSf3O98VSikmmQ94HFgDLDdNM1BfX5955swZX0tLi5FKpbSSkpJkaWlpIhQKdVdVVX2XkZFx"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   218
        "EpBAEGgHLgH/iSqlUEoJpVSBUqpaKXXYNM0r1dXVt6WUajx5ylVYWKi2bdvWY1nWUaXUgQ0b"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   219
        "NtRWVFQUjmuilEKMV5ALvAhsPHDgQFlNTU2gr69Pk1JSFMphTomfRXO8+A243i/oG9I5f6mX"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   220
        "K1evAxAOhykrKxs9duyYkZ+f/0lPT8/2OwXogBtYDKzYunVr0c6dO3Ns26akMIcdbxQyv0hy"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   221
        "rwmh8Bas5/eb89nxRR1NTU20t7cb4x1ZPjlXB2YBiw8ePJhdW1tb4DEMXng6xJtrPQhxn/Y4"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   222
        "QSM12o89fJnOjst3hXRdLxZCGEqpUQANmBuJRLK3bNmy1OFwUPVMPm9VTiMOqLRNYvg6+shv"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   223
        "rFoWwutxTcSklGEpZXDiXZRSr6xbt+6dtra2xUW5Lr7c7EUD3Flhwmu/nRKQGO7CvHaCwY7D"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   224
        "WNEeEmoGe0+PWnuOXHWmrBTl5eW7GxsbNwPoFy5ccHV2di7yzjD4uMqDNtFngZDOKQHurDLc"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   225
        "WWX4Qk/ScfRVXCLGoorU8J+z5gbjxyWGYbwshPhQKTWi7d+/P9/pdIp5xR5C2Q9uS1fDp3T+"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   226
        "8jo32uomfJ7cCtzZYQCOjKhYOmgxI+hBSumdOXPmegDt4sWLxU6nk3BIf7A6EB/sIBY5R/+l"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   227
        "nyd8yrZIRnvZ02tduxVwFQOojBQAfr9/tRBC103TLHe5XMwpSEwLKFj2EWk7gRGYOyaeTtJ4"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   228
        "pnZk+7UhM5FtlAhAIMYAESd+v78IyNWBYqfTSUF2fFqAJ7firufhRFSdTg36rIDhQ6XHnAI0"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   229
        "L1iWhWEYASBLl1L+JaWcfSuqk+u3AUikRer4ADffg/w7gt80fs35r34k3BYh2xNAarooAJ4d"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   230
        "vsHgaP8EWMR17GiaVo8r0+Fw6DrQDDzXO+RgQSjBUFIlPh+wB0vLZD6TrLWrkWRXB29fGAK6"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   231
        "pql1rNXVmrCklJYGtAgh6DXHDsuuG8k+O9M5895tq+atpSwwZ9o2TjZlWTGl1IAGNEsp1c1E"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   232
        "DiMqmI7nZRQJ7j/G6xZWMS/vsYcGkEzG4vF4RDt06FBfZmbmwR/27uOD3f1aVk+BljMjD6lp"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   233
        "/DN07a4VTYw8tL4rrQZgbNixadOm90+dOvX82cZmcbaxmWBukOVrlvJudw1R1xDp8a+kuPM6"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   234
        "Gx8S4LXtCIwNO1asWDGYl5dn3gneunGLc7/+gTttoAntQRrTmgMmpimAHQwGOycnlBaX4rUz"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   235
        "8LszMRweXLr7kWB35oMdCAT+1jRt0cqVK6Otra2+hvoGGuobWPLEEsoXzkbPkLhvR4CBRwJY"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   236
        "Xq/3SGVlZbq7u7utsrJyxDTNz06cOJHZ0tRCS1MLAKuRwNQT9v8AyV27dn1fXl7eqmlae11d"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   237
        "XXLfvn0/+Xy+l6LR6Gu2befFYjFfzrk2FzeHp7mK7jdxz2/LffGamhpvc3NzyLKsbFd3z1PG"
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   238
        "aHyBTKdjum0POGzbFAp7qo0xVOtJZdf/C/wRDnL5FYGSAAAAAElFTkSuQmCC")
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   239
        
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   240
        class ParamsEntryDialog(wx.TextEntryDialog):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   241
            if wx.VERSION < (2, 6, 0):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   242
                def Bind(self, event, function, id = None):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   243
                    if id is not None:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   244
                        event(self, id, function)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   245
                    else:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   246
                        event(self, function)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   247
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   248
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   249
            def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   250
                               style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   251
                wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   252
                
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   253
                self.Tests = []
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   254
                if wx.VERSION >= (2, 8, 0):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   255
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetAffirmativeId())
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   256
                elif wx.VERSION >= (2, 6, 0):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   257
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   258
                else:
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   259
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   260
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   261
            def OnOK(self, event):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   262
                value = self.GetValue()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   263
                texts = {"value" : value}
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   264
                for function, message in self.Tests:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   265
                    if not function(value):
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   266
                        message = wx.MessageDialog(self, message%texts, _("Error"), wx.OK|wx.ICON_ERROR)
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   267
                        message.ShowModal()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   268
                        message.Destroy()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   269
                        return
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   270
                self.EndModal(wx.ID_OK)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   271
                event.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   272
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   273
            def GetValue(self):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   274
                return self.GetSizer().GetItem(1).GetWindow().GetValue()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   275
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   276
            def SetTests(self, tests):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   277
                self.Tests = tests
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   278
        
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   279
        class BeremizTaskBarIcon(wx.TaskBarIcon):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   280
            TBMENU_START = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   281
            TBMENU_STOP = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   282
            TBMENU_CHANGE_NAME = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   283
            TBMENU_CHANGE_PORT = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   284
            TBMENU_CHANGE_INTERFACE = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   285
            TBMENU_LIVE_SHELL = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   286
            TBMENU_WXINSPECTOR = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   287
            TBMENU_CHANGE_WD = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   288
            TBMENU_QUIT = wx.NewId()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   289
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   290
            def __init__(self, pyroserver):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   291
                wx.TaskBarIcon.__init__(self)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   292
                self.pyroserver = pyroserver
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   293
                # Set the image
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   294
                self.UpdateIcon(None)
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   295
                
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   296
                # bind some events
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   297
                self.Bind(wx.EVT_MENU, self.OnTaskBarStartPLC, id=self.TBMENU_START)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   298
                self.Bind(wx.EVT_MENU, self.OnTaskBarStopPLC, id=self.TBMENU_STOP)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   299
                self.Bind(wx.EVT_MENU, self.OnTaskBarChangeName, id=self.TBMENU_CHANGE_NAME)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   300
                self.Bind(wx.EVT_MENU, self.OnTaskBarChangeInterface, id=self.TBMENU_CHANGE_INTERFACE)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   301
                self.Bind(wx.EVT_MENU, self.OnTaskBarLiveShell, id=self.TBMENU_LIVE_SHELL)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   302
                self.Bind(wx.EVT_MENU, self.OnTaskBarWXInspector, id=self.TBMENU_WXINSPECTOR)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   303
                self.Bind(wx.EVT_MENU, self.OnTaskBarChangePort, id=self.TBMENU_CHANGE_PORT)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   304
                self.Bind(wx.EVT_MENU, self.OnTaskBarChangeWorkingDir, id=self.TBMENU_CHANGE_WD)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   305
                self.Bind(wx.EVT_MENU, self.OnTaskBarQuit, id=self.TBMENU_QUIT)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   306
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   307
            def CreatePopupMenu(self):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   308
                """
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   309
                This method is called by the base class when it needs to popup
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   310
                the menu for the default EVT_RIGHT_DOWN event.  Just create
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   311
                the menu how you want it and return it from this function,
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   312
                the base class takes care of the rest.
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   313
                """
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   314
                menu = wx.Menu()
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   315
                menu.Append(self.TBMENU_START, _("Start PLC"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   316
                menu.Append(self.TBMENU_STOP, _("Stop PLC"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   317
                menu.Append(self.TBMENU_CHANGE_NAME, _("Change Name"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   318
                menu.Append(self.TBMENU_CHANGE_INTERFACE, _("Change IP of interface to bind"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   319
                menu.Append(self.TBMENU_LIVE_SHELL, _("Launch a live Python shell"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   320
                menu.Append(self.TBMENU_WXINSPECTOR, _("Launch WX GUI inspector"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   321
                menu.Append(self.TBMENU_CHANGE_PORT, _("Change Port Number"))
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   322
                menu.AppendSeparator()
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   323
                menu.Append(self.TBMENU_CHANGE_WD, _("Change working directory"))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   324
                menu.Append(self.TBMENU_QUIT, _("Quit"))
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   325
                return menu
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   326
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   327
            def MakeIcon(self, img):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   328
                """
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   329
                The various platforms have different requirements for the
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   330
                icon size...
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   331
                """
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   332
                if "wxMSW" in wx.PlatformInfo:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   333
                    img = img.Scale(16, 16)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   334
                elif "wxGTK" in wx.PlatformInfo:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   335
                    img = img.Scale(22, 22)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   336
                # wxMac can be any size upto 128x128, so leave the source img alone....
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   337
                icon = wx.IconFromBitmap(img.ConvertToBitmap() )
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   338
                return icon
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   339
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   340
            def OnTaskBarStartPLC(self, evt):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   341
                if self.pyroserver.plcobj is not None: 
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   342
                    self.pyroserver.plcobj.StartPLC()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   343
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   344
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   345
            def OnTaskBarStopPLC(self, evt):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   346
                if self.pyroserver.plcobj is not None:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   347
                    self.pyroserver.plcobj.StopPLC()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   348
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   349
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   350
            def OnTaskBarChangeInterface(self, evt):
415
339fa2542481 improved english spelling and grammar and internationalization updated
laurent
parents: 411
diff changeset
   351
                dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip)
339fa2542481 improved english spelling and grammar and internationalization updated
laurent
parents: 411
diff changeset
   352
                dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")),
339fa2542481 improved english spelling and grammar and internationalization updated
laurent
parents: 411
diff changeset
   353
                               ( lambda ip :len([x for x in ip.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!"))
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   354
                               ])
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   355
                if dlg.ShowModal() == wx.ID_OK:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   356
                    self.pyroserver.ip = dlg.GetValue()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   357
                    self.pyroserver.Stop()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   358
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   359
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   360
            def OnTaskBarChangePort(self, evt):
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   361
                dlg = ParamsEntryDialog(None, _("Enter a port number "), defaultValue=str(self.pyroserver.port))
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   362
                dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port : 0 <= int(port) <= 65535 , _("Port number must be 0 <= port <= 65535!"))])
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   363
                if dlg.ShowModal() == wx.ID_OK:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   364
                    self.pyroserver.port = int(dlg.GetValue())
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   365
                    self.pyroserver.Stop()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   366
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   367
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   368
            def OnTaskBarChangeWorkingDir(self, evt):
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   369
                dlg = wx.DirDialog(None, _("Choose a working directory "), self.pyroserver.workdir, wx.DD_NEW_DIR_BUTTON)
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   370
                if dlg.ShowModal() == wx.ID_OK:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   371
                    self.pyroserver.workdir = dlg.GetPath()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   372
                    self.pyroserver.Stop()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   373
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   374
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   375
            def OnTaskBarChangeName(self, evt):
361
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   376
                dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=self.pyroserver.name)
331d698e1118 Adding support for internationalization
laurent
parents: 343
diff changeset
   377
                dlg.SetTests([(lambda name : len(name) is not 0 , _("Name must not be null!"))])
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   378
                if dlg.ShowModal() == wx.ID_OK:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   379
                    self.pyroserver.name = dlg.GetValue()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   380
                    self.pyroserver.Restart()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   381
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   382
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   383
            def OnTaskBarLiveShell(self, evt):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   384
                if self.pyroserver.plcobj is not None and self.pyroserver.plcobj.python_threads_vars is not None:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   385
                    from wx import py
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   386
                    #frame = py.shell.ShellFrame(locals=self.pyroserver.plcobj.python_threads_vars)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   387
                    frame = py.crust.CrustFrame(locals=self.pyroserver.plcobj.python_threads_vars)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   388
                    frame.Show()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   389
                else:
415
339fa2542481 improved english spelling and grammar and internationalization updated
laurent
parents: 411
diff changeset
   390
                    wx.MessageBox(_("No running PLC"), _("Error"))
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   391
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   392
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   393
            def OnTaskBarWXInspector(self, evt):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   394
                # Activate the widget inspection tool
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   395
                from wx.lib.inspection import InspectionTool
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   396
                if not InspectionTool().initialized:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   397
                    InspectionTool().Init(locals=self.pyroserver.plcobj.python_threads_vars)
271
ea7928fd07da add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents: 269
diff changeset
   398
                
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   399
                # Find a widget to be selected in the tree.  Use either the
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   400
                # one under the cursor, if any, or this frame.
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   401
                wnd = wx.FindWindowAtPointer()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   402
                if not wnd:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   403
                    wnd = wx.GetApp()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   404
                InspectionTool().Show(wnd, True)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   405
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   406
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   407
            def OnTaskBarQuit(self, evt):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   408
                self.pyroserver.Quit()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   409
                self.RemoveIcon()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   410
                wx.CallAfter(wx.GetApp().Exit)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   411
                evt.Skip()
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   412
            
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   413
            def UpdateIcon(self, plcstatus):
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   414
                if plcstatus is "Started" :
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   415
                    currenticon = self.MakeIcon(starticon.GetImage())
446
1edde533db19 Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents: 415
diff changeset
   416
                elif plcstatus is "Stopped":
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   417
                    currenticon = self.MakeIcon(stopicon.GetImage())
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   418
                else:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   419
                    currenticon = self.MakeIcon(defaulticon.GetImage())
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   420
                self.SetIcon(currenticon, "Beremiz Service")
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   421
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   422
from runtime import PLCObject, PLCprint, ServicePublisher
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   423
import Pyro.core as pyro
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   424
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   425
if not os.path.isdir(WorkingDir):
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   426
    os.mkdir(WorkingDir)
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   427
319
bdd82ac65f5d Fixed non-wx runtime python evaluation stuff.
etisserant
parents: 303
diff changeset
   428
def default_evaluator(callable, *args, **kwargs):
bdd82ac65f5d Fixed non-wx runtime python evaluation stuff.
etisserant
parents: 303
diff changeset
   429
    return callable(*args,**kwargs)
bdd82ac65f5d Fixed non-wx runtime python evaluation stuff.
etisserant
parents: 303
diff changeset
   430
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   431
class Server():
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   432
    def __init__(self, servicename, ip, port, workdir, argv, autostart=False, statuschange=None, evaluator=default_evaluator, website=None):
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   433
        self.continueloop = True
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   434
        self.daemon = None
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   435
        self.servicename = servicename
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   436
        self.ip = ip
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   437
        self.port = port
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   438
        self.workdir = workdir
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   439
        self.argv = argv
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   440
        self.plcobj = None
263
0bc32427a459 fix bug in beremiz_service with the MainLoop
greg
parents: 262
diff changeset
   441
        self.servicepublisher = None
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   442
        self.autostart = autostart
269
d29c5f71574f add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents: 263
diff changeset
   443
        self.statuschange = statuschange
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   444
        self.evaluator = evaluator
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   445
        self.website = website
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   446
    
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   447
    def Loop(self):
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   448
        while self.continueloop:
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   449
            self.Start()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   450
        
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   451
    def Restart(self):
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   452
        self.Stop()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   453
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   454
    def Quit(self):
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   455
        self.continueloop = False
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   456
        self.Stop()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   457
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   458
    def Start(self):
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   459
        pyro.initServer()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   460
        self.daemon=pyro.Daemon(host=self.ip, port=self.port)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   461
        self.plcobj = PLCObject(self.workdir, self.daemon, self.argv, self.statuschange, self.evaluator, self.website)
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   462
        uri = self.daemon.connect(self.plcobj,"PLCObject")
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   463
    
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   464
        print "Pyro port :",self.port
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   465
        print "Pyro object's uri :",uri
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   466
        print "Current working directory :",self.workdir
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   467
        
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   468
        # Configure and publish service
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   469
        # Not publish service if localhost in address params
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   470
        if self.servicename is not None and self.ip != "localhost" and self.ip != "127.0.0.1":    
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   471
            print "Publishing service on local network"
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   472
            self.servicepublisher = ServicePublisher.ServicePublisher()
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   473
            self.servicepublisher.RegisterService(self.servicename, self.ip, self.port)
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   474
        
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   475
        if self.autostart:
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   476
            self.plcobj.StartPLC()
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   477
        
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   478
        sys.stdout.flush()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   479
        
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   480
        self.daemon.requestLoop()
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   481
    
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   482
    def Stop(self):
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   483
        self.plcobj.StopPLC()
263
0bc32427a459 fix bug in beremiz_service with the MainLoop
greg
parents: 262
diff changeset
   484
        if self.servicepublisher is not None:
0bc32427a459 fix bug in beremiz_service with the MainLoop
greg
parents: 262
diff changeset
   485
            self.servicepublisher.UnRegisterService()
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   486
            self.servicepublisher = None
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   487
        self.daemon.shutdown(True)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   488
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   489
if enabletwisted:
612
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   490
    import warnings
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   491
    with warnings.catch_warnings():
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   492
        warnings.simplefilter("ignore")
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   493
        try:
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   494
            from threading import Thread, currentThread
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   495
            if havewx:
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   496
                from twisted.internet import wxreactor
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   497
                wxreactor.install()
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   498
            from twisted.internet import reactor, task
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   499
            from twisted.python import log, util
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   500
            from nevow import rend, appserver, inevow, tags, loaders, athena
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   501
            from nevow.page import renderer
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   502
            
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   503
            havetwisted = True
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   504
        except:
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   505
            print "Twisted unavailable !"
f44651506a88 silence warnings while importing twisted
Edouard Tisserant
parents: 606
diff changeset
   506
            havetwisted = False
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   507
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   508
if havetwisted:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   509
    
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   510
    xhtml_header = '''<?xml version="1.0" encoding="utf-8"?>
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   511
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   512
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   513
'''
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   514
381
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   515
    class PLCHMI(athena.LiveElement):
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   516
    
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   517
        initialised = False
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   518
    
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   519
        def HMIinitialised(self, result):
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   520
            self.initialised = True
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   521
        
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   522
        def HMIinitialisation(self):
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   523
            self.HMIinitialised(None)
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   524
    
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   525
    class DefaultPLCStartedHMI(PLCHMI):
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   526
        docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[                                    
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   527
                                             tags.h1["PLC IS NOW STARTED"],
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   528
                                             ])
381
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   529
        
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   530
    class PLCStoppedHMI(PLCHMI):
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   531
        docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
396
d1083f580ca1 Many bugs on PLCOpenEditor integration fixed
laurent
parents: 381
diff changeset
   532
                                             tags.h1["PLC IS STOPPED"],
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   533
                                             ])
396
d1083f580ca1 Many bugs on PLCOpenEditor integration fixed
laurent
parents: 381
diff changeset
   534
    
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   535
    class MainPage(athena.LiveElement):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   536
        jsClass = u"WebInterface.PLC"
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   537
        docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   538
                                                        tags.div(id='content')[                         
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   539
                                                        tags.div(render = tags.directive('PLCElement')),
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   540
                                                        ]])
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   541
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   542
        def __init__(self, *a, **kw):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   543
            athena.LiveElement.__init__(self, *a, **kw)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   544
            self.pcl_state = False
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   545
            self.HMI = None
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   546
            self.resetPLCStartedHMI()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   547
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   548
        def setPLCState(self, state):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   549
            self.pcl_state = state
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   550
            if self.HMI is not None:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   551
                self.callRemote('updateHMI')
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   552
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   553
        def setPLCStartedHMI(self, hmi):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   554
            self.PLCStartedHMIClass = hmi
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   555
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   556
        def resetPLCStartedHMI(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   557
            self.PLCStartedHMIClass = DefaultPLCStartedHMI
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   558
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   559
        def getHMI(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   560
            return self.HMI
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   561
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   562
        def HMIexec(self, function, *args, **kwargs):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   563
            if self.HMI is not None:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   564
                getattr(self.HMI, function, lambda:None)(*args, **kwargs)
369
bd54d41a7573 Adding support for twisted website HMI
laurent
parents: 368
diff changeset
   565
        athena.expose(HMIexec)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   566
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   567
        def resetHMI(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   568
            self.HMI = None
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   569
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   570
        def PLCElement(self, ctx, data):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   571
            return self.getPLCElement()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   572
        renderer(PLCElement)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   573
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   574
        def getPLCElement(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   575
            self.detachFragmentChildren()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   576
            if self.pcl_state:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   577
                f = self.PLCStartedHMIClass()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   578
            else:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   579
                f = PLCStoppedHMI()
369
bd54d41a7573 Adding support for twisted website HMI
laurent
parents: 368
diff changeset
   580
            f.setFragmentParent(self)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   581
            self.HMI = f
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   582
            return f
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   583
        athena.expose(getPLCElement)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   584
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   585
        def detachFragmentChildren(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   586
            for child in self.liveFragmentChildren[:]:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   587
                child.detach()
396
d1083f580ca1 Many bugs on PLCOpenEditor integration fixed
laurent
parents: 381
diff changeset
   588
    
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   589
    class WebInterface(athena.LivePage):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   590
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   591
        docFactory = loaders.stan([tags.raw(xhtml_header),
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   592
                                   tags.html(xmlns="http://www.w3.org/1999/xhtml")[
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   593
                                       tags.head(render=tags.directive('liveglue')),
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   594
                                       tags.body[
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   595
                                           tags.div[
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   596
                                                   tags.div( render = tags.directive( "MainPage" ))
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   597
                                                   ]]]])
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   598
        MainPage = MainPage()
381
5c0f34a9ab00 Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents: 369
diff changeset
   599
        PLCHMI = PLCHMI
396
d1083f580ca1 Many bugs on PLCOpenEditor integration fixed
laurent
parents: 381
diff changeset
   600
        
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   601
        def __init__(self, plcState=False, *a, **kw):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   602
            super(WebInterface, self).__init__(*a, **kw)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   603
            self.jsModules.mapping[u'WebInterface'] = util.sibpath(__file__, 'webinterface.js')
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   604
            self.plcState = plcState
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   605
            self.MainPage.setPLCState(plcState)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   606
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   607
        def getHMI(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   608
            return self.MainPage.getHMI()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   609
        
369
bd54d41a7573 Adding support for twisted website HMI
laurent
parents: 368
diff changeset
   610
        def LoadHMI(self, hmi, jsmodules):
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   611
            for name, path in jsmodules.iteritems():
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   612
                self.jsModules.mapping[name] = os.path.join(WorkingDir, path)
369
bd54d41a7573 Adding support for twisted website HMI
laurent
parents: 368
diff changeset
   613
            self.MainPage.setPLCStartedHMI(hmi)
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   614
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   615
        def UnLoadHMI(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   616
            self.MainPage.resetPLCStartedHMI()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   617
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   618
        def PLCStarted(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   619
            self.plcState = True
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   620
            self.MainPage.setPLCState(True)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   621
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   622
        def PLCStopped(self):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   623
            self.plcState = False
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   624
            self.MainPage.setPLCState(False)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   625
            
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   626
        def renderHTTP(self, ctx):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   627
            """
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   628
            Force content type to fit with SVG
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   629
            """
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   630
            req = inevow.IRequest(ctx)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   631
            req.setHeader('Content-type', 'application/xhtml+xml')
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   632
            return super(WebInterface, self).renderHTTP(ctx)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   633
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   634
        def render_MainPage(self, ctx, data):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   635
            f = self.MainPage
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   636
            f.setFragmentParent(self)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   637
            return ctx.tag[f]
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   638
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   639
        def child_(self, ctx):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   640
            self.MainPage.detachFragmentChildren()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   641
            return WebInterface(plcState=self.plcState)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   642
            
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   643
        def beforeRender(self, ctx):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   644
            d = self.notifyOnDisconnect()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   645
            d.addErrback(self.disconnected)
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   646
        
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   647
        def disconnected(self, reason):
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   648
            self.MainPage.resetHMI()
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   649
            #print reason
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   650
            #print "We will be called back when the client disconnects"
396
d1083f580ca1 Many bugs on PLCOpenEditor integration fixed
laurent
parents: 381
diff changeset
   651
        
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   652
    if havewx:
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   653
        reactor.registerWxApp(app)
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   654
    website = WebInterface()
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   655
    site = appserver.NevowSite(website)
409
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   656
    
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   657
    website_port = 8009
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   658
    listening = False
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   659
    while not listening:
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   660
        try:
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   661
            reactor.listenTCP(website_port, site)
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   662
            listening = True
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   663
        except:
63249a965feb Allowing multiple Beremiz_service instances to run on same target.
laurent
parents: 396
diff changeset
   664
            website_port += 1
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   665
    print "Http interface port :",website_port
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   666
else:
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   667
    website = None
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   668
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   669
if havewx:
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   670
    from threading import Semaphore
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   671
    wx_eval_lock = Semaphore(0)
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   672
    mythread = currentThread()
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   673
    
269
d29c5f71574f add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents: 263
diff changeset
   674
    def statuschange(status):
d29c5f71574f add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents: 263
diff changeset
   675
        wx.CallAfter(taskbar_instance.UpdateIcon,status)
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   676
        
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   677
    eval_res = None
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   678
    def wx_evaluator(callable, *args, **kwargs):
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   679
        global eval_res
343
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   680
        try:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   681
            eval_res=callable(*args,**kwargs)
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   682
        except Exception,e:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   683
            PLCprint("#EXCEPTION : "+str(e))
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   684
        finally:
fe2d1936b546 Add try/except in wx_evaluator to get and print exception when command failed and unlock in all cases to not block the python thread
greg
parents: 330
diff changeset
   685
            wx_eval_lock.release()
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   686
        
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   687
    def evaluator(callable, *args, **kwargs):
330
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   688
        # call directly the callable function if call from the wx mainloop (avoid dead lock) 
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   689
        if(mythread == currentThread()):
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   690
            callable(*args,**kwargs)
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   691
        else:
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   692
            wx.CallAfter(wx_evaluator,callable,*args,**kwargs)
fdf81615ed04 add autostart plc feature for beremiz_service (bug fixed)
greg
parents: 319
diff changeset
   693
            wx_eval_lock.acquire()
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   694
        return eval_res
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   695
    
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   696
    pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, statuschange, evaluator, website)
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   697
    taskbar_instance = BeremizTaskBarIcon(pyroserver)
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   698
else:
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   699
    pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, website=website)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   700
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   701
if havetwisted or havewx:
301
87c925eaaa3a Added support for wxglade GUIs.
etisserant
parents: 294
diff changeset
   702
    pyro_thread=Thread(target=pyroserver.Loop)
262
141a7145c099 add taskbaricon to beremiz_service.
greg
parents: 217
diff changeset
   703
    pyro_thread.start()
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   704
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   705
    if havetwisted:
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   706
        reactor.run()
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   707
    elif havewx:
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   708
        app.MainLoop()
368
86ecd8374dae Adding support for twisted website HMI
laurent
parents: 362
diff changeset
   709
else:
606
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   710
    try :
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   711
        pyroserver.Loop()
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   712
    except KeyboardInterrupt,e:
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   713
        pass
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   714
pyroserver.Quit()
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   715
sys.exit(0)
780bd150ebba Fixed runtime with twisted but without Wx (-x 0 -t 1), made non-Zeroconf a default option, i.e when -n not specified
Edouard Tisserant
parents: 446
diff changeset
   716