runtime/NevowServer.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Wed, 04 Oct 2023 16:24:00 +0200
branchpython3
changeset 3854 d29d67e86532
parent 3804 ef65e5b07464
child 3881 0b3ac94f494c
permissions -rw-r--r--
Merge
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     3
1667
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
     4
# This file is part of Beremiz runtime.
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     5
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     6
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
1680
6db967480b7d make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1667
diff changeset
     7
# Copyright (C) 2017: Andrey Skvortsov
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
     8
#
1667
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
     9
# See COPYING.Runtime file for copyrights details.
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
    10
#
1667
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    11
# This library is free software; you can redistribute it and/or
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    12
# modify it under the terms of the GNU Lesser General Public
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    13
# License as published by the Free Software Foundation; either
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    14
# version 2.1 of the License, or (at your option) any later version.
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    15
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    16
# This library is distributed in the hope that it will be useful,
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1667
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    19
# Lesser General Public License for more details.
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    20
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    21
# You should have received a copy of the GNU Lesser General Public
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    22
# License along with this library; if not, write to the Free Software
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1595
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1453
diff changeset
    24
1826
91796f408540 fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
    25
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3703
diff changeset
    26
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3703
diff changeset
    27
1438
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    28
import os
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
    29
import collections
3703
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
    30
import shutil
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
    31
import platform as platform_module
3800
a5a6ee271e65 WIP python3 support for runtime
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
    32
from zope.interface import implementer
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
    33
from nevow import appserver, inevow, tags, loaders, athena, url, rend
1438
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    34
from nevow.page import renderer
2266
ed415982a9aa NevowServer : Added minimalist css style customization and a link to go to settings page and back
dporopat <denis.poropat@smarteh.si>
parents: 2219
diff changeset
    35
from nevow.static import File
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
    36
from formless import annotate
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
    37
from formless import webform
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    38
from formless import configurable
1439
a68cd4253259 Added stub code for runtime WAMP client. Added runtime command line switch to select WAMP url and Nevow web site port. Web port is now fixed, next port number is not tested if bind fails.
Edouard Tisserant
parents: 1438
diff changeset
    39
from twisted.internet import reactor
2210
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
    40
1919
ccea0fa6ea91 Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents: 1881
diff changeset
    41
import util.paths as paths
2210
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
    42
from runtime.loglevels import LogLevels, LogLevelsDict
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
    43
from runtime import MainWorker, GetPLCObjectSingleton
1438
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    44
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
    45
PAGE_TITLE = 'Beremiz Runtime Web Interface'
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
    46
3800
a5a6ee271e65 WIP python3 support for runtime
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
    47
xhtml_header = b'''<?xml version="1.0" encoding="utf-8"?>
1438
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    49
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    50
'''
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
    51
1453
f31353cac197 Fixed Nevow website startup
Edouard Tisserant
parents: 1439
diff changeset
    52
WorkingDir = None
f31353cac197 Fixed Nevow website startup
Edouard Tisserant
parents: 1439
diff changeset
    53
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    54
class ConfigurableBindings(configurable.Configurable):
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    55
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    56
    def __init__(self):
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    57
        configurable.Configurable.__init__(self, None)
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    58
        self.bindingsNames = []
2262
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    59
        self.infostringcount = 0
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    60
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    61
    def getBindingNames(self, ctx):
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    62
        return self.bindingsNames
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    63
2262
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    64
    def addInfoString(self, label, value, name=None):
2267
Edouard Tisserant
parents: 2262 2266
diff changeset
    65
        if isinstance(value, str):
2262
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    66
            def default(*k):
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    67
                return value
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    68
        else:
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    69
            def default(*k):
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    70
                return value()
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    71
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    72
        if name is None:
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    73
            name = "_infostring_" + str(self.infostringcount)
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    74
            self.infostringcount = self.infostringcount + 1
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    75
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    76
        def _bind(ctx):
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    77
            return annotate.Property(
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    78
                name,
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    79
                annotate.String(
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    80
                    label=label,
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    81
                    default=default,
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    82
                    immutable=True))
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    83
        setattr(self, 'bind_' + name, _bind)
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    84
        self.bindingsNames.append(name)
4195545e2d17 NevowServer : added addInfoString to allow extensions to declare some read-only strings to be displayed in settings. Also renamed addExtension in addSettings for clarity.
Edouard Tisserant
parents: 2260
diff changeset
    85
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
    86
    def addSettings(self, name, desc, fields, btnlabel, callback):
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    87
        def _bind(ctx):
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    88
            return annotate.MethodBinding(
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    89
                'action_' + name,
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
    90
                annotate.Method(
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
    91
                    arguments=[
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
    92
                        annotate.Argument(*field)
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
    93
                        for field in fields],
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    94
                    label=desc),
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    95
                action=btnlabel)
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    96
        setattr(self, 'bind_' + name, _bind)
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    97
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
    98
        setattr(self, 'action_' + name, callback)
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
    99
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   100
        self.bindingsNames.append(name)
2654
7575050a80c5 Add web extension: configure Modbus plugin parameters (currently only supports Modbus clients)
Mario de Sousa <msousa@fe.up.pt>
parents: 2649
diff changeset
   101
            
2260
74205edac761 Some blank lines to make bitbucket's PEP8 2.2.0 happy
Edouard Tisserant
parents: 2247
diff changeset
   102
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   103
ConfigurableSettings = ConfigurableBindings()
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   104
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   105
def newExtensionSetting(display, token):
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   106
    global extensions_settings_od
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   107
    settings = ConfigurableBindings()
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   108
    extensions_settings_od[token] = (settings, display)
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   109
    return settings
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   110
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   111
def removeExtensionSetting(token):
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   112
    global extensions_settings_od
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   113
    extensions_settings_od.pop(token)
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   114
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   115
class ISettings(annotate.TypedInterface):
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   116
    platform = annotate.String(label=_("Platform"),
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   117
                               default=platform_module.system() +
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   118
                               " " + platform_module.release(),
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   119
                               immutable=True)
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   120
2217
a603d1ba287b Added some immutable field (platform) in default runtime web setting page, for the example.
Edouard Tisserant
parents: 2214
diff changeset
   121
    # TODO version ?
a603d1ba287b Added some immutable field (platform) in default runtime web setting page, for the example.
Edouard Tisserant
parents: 2214
diff changeset
   122
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   123
    # pylint: disable=no-self-argument
2210
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
   124
    def sendLogMessage(
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   125
            ctx=annotate.Context(),
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   126
            level=annotate.Choice(LogLevels,
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   127
                                  required=True,
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   128
                                  label=_("Log message level")),
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   129
            message=annotate.String(label=_("Message text"))):
2247
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   130
        pass
921ba5658183 pylint on runtime/NevowServer.py
Edouard Tisserant
parents: 2246
diff changeset
   131
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   132
    sendLogMessage = annotate.autocallable(sendLogMessage,
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   133
                                           label=_(
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   134
                                               "Send a message to the log"),
2210
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
   135
                                           action=_("Send"))
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   136
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   137
    # pylint: disable=no-self-argument
2701
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   138
    def restartOrRepairPLC(
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   139
            ctx=annotate.Context(),
2701
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   140
            action=annotate.Choice(["Restart", "Repair"],
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   141
                                  required=True,
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   142
                                  label=_("Action"))):
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   143
        pass
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   144
2701
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   145
    restartOrRepairPLC = annotate.autocallable(restartOrRepairPLC,
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   146
                                           label=_(
2701
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   147
                                               "Restart or Repair"),
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   148
                                           action=_("Do"))
2260
74205edac761 Some blank lines to make bitbucket's PEP8 2.2.0 happy
Edouard Tisserant
parents: 2247
diff changeset
   149
3703
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   150
    # pylint: disable=no-self-argument
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   151
    def uploadFile(
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   152
            ctx=annotate.Context(),
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   153
            uploadedfile=annotate.FileUpload(required=True,
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   154
                                  label=_("File to upload"))):
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   155
        pass
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   156
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   157
    uploadFile = annotate.autocallable(uploadFile,
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   158
                                           label=_(
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   159
                                               "Upload a file to PLC working directory"),
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   160
                                           action=_("Upload"))
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   161
2219
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   162
customSettingsURLs = {
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   163
}
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   164
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   165
extensions_settings_od = collections.OrderedDict()
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   166
3800
a5a6ee271e65 WIP python3 support for runtime
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3750
diff changeset
   167
@implementer(ISettings)
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   168
class SettingsPage(rend.Page):
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   169
    # We deserve a slash
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   170
    addSlash = True
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   171
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   172
    # This makes webform_css url answer some default CSS
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   173
    child_webform_css = webform.defaultCSS
2266
ed415982a9aa NevowServer : Added minimalist css style customization and a link to go to settings page and back
dporopat <denis.poropat@smarteh.si>
parents: 2219
diff changeset
   174
    child_webinterface_css = File(paths.AbsNeighbourFile(__file__, 'webinterface.css'), 'text/css')
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   175
   
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   176
    def __getattr__(self, name):
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   177
        global extensions_settings_od
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   178
        if name.startswith('configurable_'):
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   179
            token = name[13:]
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   180
            def configurable_something(ctx):
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   181
                settings, _display = extensions_settings_od[token]
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   182
                return settings
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   183
            return configurable_something
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   184
        raise AttributeError
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   185
    
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   186
    def extensions_settings(self, context, data):
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   187
        """ Project extensions settings
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   188
        Extensions added to Configuration Tree in IDE have their setting rendered here
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   189
        """
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   190
        global extensions_settings_od
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   191
        res = []
2672
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   192
        for token in extensions_settings_od:
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   193
            _settings, display = extensions_settings_od[token]
4bc60e426dd6 Runtime extrension web settings: distinguish display string and token when calling NS.newExtensionSetting, thus allowing meaningful name to be displayed instead of an id.
Edouard Tisserant
parents: 2670
diff changeset
   194
            res += [tags.h2[display], webform.renderForms(token)] 
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   195
        return res
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   196
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   197
    docFactory = loaders.stan([tags.html[
2267
Edouard Tisserant
parents: 2262 2266
diff changeset
   198
        tags.head[
Edouard Tisserant
parents: 2262 2266
diff changeset
   199
            tags.title[_("Beremiz Runtime Settings")],
Edouard Tisserant
parents: 2262 2266
diff changeset
   200
            tags.link(rel='stylesheet',
Edouard Tisserant
parents: 2262 2266
diff changeset
   201
                      type='text/css',
Edouard Tisserant
parents: 2262 2266
diff changeset
   202
                      href=url.here.child("webform_css")),
Edouard Tisserant
parents: 2262 2266
diff changeset
   203
            tags.link(rel='stylesheet',
Edouard Tisserant
parents: 2262 2266
diff changeset
   204
                      type='text/css',
Edouard Tisserant
parents: 2262 2266
diff changeset
   205
                      href=url.here.child("webinterface_css"))
Edouard Tisserant
parents: 2262 2266
diff changeset
   206
        ],
Edouard Tisserant
parents: 2262 2266
diff changeset
   207
        tags.body[
Edouard Tisserant
parents: 2262 2266
diff changeset
   208
            tags.a(href='/')['Back'],
Edouard Tisserant
parents: 2262 2266
diff changeset
   209
            tags.h1["Runtime settings:"],
Edouard Tisserant
parents: 2262 2266
diff changeset
   210
            webform.renderForms('staticSettings'),
Edouard Tisserant
parents: 2262 2266
diff changeset
   211
            tags.h1["Extensions settings:"],
Edouard Tisserant
parents: 2262 2266
diff changeset
   212
            webform.renderForms('dynamicSettings'),
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   213
            extensions_settings
2267
Edouard Tisserant
parents: 2262 2266
diff changeset
   214
        ]]])
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   215
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   216
    def configurable_staticSettings(self, ctx):
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   217
        return configurable.TypedInterfaceConfigurable(self)
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   218
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   219
    def configurable_dynamicSettings(self, ctx):
2670
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   220
        """ Runtime Extensions settings
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   221
        Extensions loaded through Beremiz_service -e or optional runtime features render setting forms here
fd348d79a1f3 BACnet and Modbus : Simpler configuration management. NevowServer.py now allows each extension to create and delete multiple configuration forms in the setting page, deprecating delSettings and addAfter.
Edouard Tisserant
parents: 2654
diff changeset
   222
        """
2209
ee2675e4778d Now, runtime extensions should be able to add their own settings to web configuration interface.
Edouard Tisserant
parents: 2208
diff changeset
   223
        return ConfigurableSettings
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   224
2210
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
   225
    def sendLogMessage(self, level, message, **kwargs):
81949104291d Nevow based web interface now show simple Log message sending form for basic runtime, and allow extensions to add their own web settings.
Edouard Tisserant
parents: 2209
diff changeset
   226
        level = LogLevelsDict[level]
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   227
        GetPLCObjectSingleton().LogMessage(
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   228
            level, "Web form log message: " + message)
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   229
2701
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   230
    def restartOrRepairPLC(self, action, **kwargs):
f4dac054cfa3 WebInterface: better wording for wiping PLC content: "Repair"
Edouard Tisserant
parents: 2700
diff changeset
   231
        if(action == "Repair"):
2700
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   232
            GetPLCObjectSingleton().RepairPLC()
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   233
        else:
144b149cded4 runtime: added restart/reset button in web settings. Accidentaly fixed web settings logging feature.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2672
diff changeset
   234
            MainWorker.quit()
3703
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   235
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   236
    def uploadFile(self, uploadedfile, **kwargs):
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   237
        if uploadedfile is not None:
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   238
            fobj = getattr(uploadedfile, "file", None)
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   239
        if fobj is not None:
3804
ef65e5b07464 Runtime: Fix web settings file upload.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3803
diff changeset
   240
            with open(uploadedfile.filename, 'wb') as destfd:
3703
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   241
                fobj.seek(0)
4b75f1506ea1 Runtime: add arbitrary file upload to working dir in web interface
Edouard Tisserant
parents: 3440
diff changeset
   242
                shutil.copyfileobj(fobj,destfd)
2208
32dcacb67f7a Embrio of setting form, just to test
Edouard Tisserant
parents: 1919
diff changeset
   243
2219
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   244
    def locateChild(self, ctx, segments):
2246
51047284cb0e pep8 on runtime/NevowServer.py
Edouard Tisserant
parents: 2219
diff changeset
   245
        if segments[0] in customSettingsURLs:
2219
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   246
            return customSettingsURLs[segments[0]](ctx, segments)
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   247
        return super(SettingsPage, self).locateChild(ctx, segments)
73042b2d8d65 Added a way for extension to register dedicated URL under settings page URL (i.e. /settings/something)
Edouard Tisserant
parents: 2217
diff changeset
   248
2311
bef2b4b87370 Beremiz_service now binds both pyro and nevow ports to interface given with '-i' argument.
Edouard Tisserant
parents: 2267
diff changeset
   249
def RegisterWebsite(iface, port):
3803
b3394107eb8b Runtime: drop Athena. Nevow now only for settings.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3800
diff changeset
   250
    website = SettingsPage()
1438
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
   251
    site = appserver.NevowSite(website)
19ebe96b41c0 Moved twisted/nevow/athena away from Berermiz_service.py + some minor cleanup
Edouard Tisserant
parents:
diff changeset
   252
2311
bef2b4b87370 Beremiz_service now binds both pyro and nevow ports to interface given with '-i' argument.
Edouard Tisserant
parents: 2267
diff changeset
   253
    reactor.listenTCP(port, site, interface=iface)
1826
91796f408540 fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
   254
    print(_('HTTP interface port :'), port)
1439
a68cd4253259 Added stub code for runtime WAMP client. Added runtime command line switch to select WAMP url and Nevow web site port. Web port is now fixed, next port number is not tested if bind fails.
Edouard Tisserant
parents: 1438
diff changeset
   255
    return website