runtime/NevowServer.py
changeset 1784 64beb9e9c749
parent 1782 5b6ad7a7fd9d
child 1826 91796f408540
--- a/runtime/NevowServer.py	Mon Aug 21 20:17:19 2017 +0000
+++ b/runtime/NevowServer.py	Mon Aug 21 23:22:58 2017 +0300
@@ -36,6 +36,7 @@
 
 WorkingDir = None
 
+
 class PLCHMI(athena.LiveElement):
 
     initialised = False
@@ -46,21 +47,24 @@
     def HMIinitialisation(self):
         self.HMIinitialised(None)
 
+
 class DefaultPLCStartedHMI(PLCHMI):
     docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
                                             tags.h1["PLC IS NOW STARTED"],
                                             ])
 
+
 class PLCStoppedHMI(PLCHMI):
     docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
                                             tags.h1["PLC IS STOPPED"],
                                             ])
 
+
 class MainPage(athena.LiveElement):
     jsClass = u"WebInterface.PLC"
     docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
                                                     tags.div(id='content')[
-                                                    tags.div(render = tags.directive('PLCElement')),
+                                                        tags.div(render=tags.directive('PLCElement')),
                                                     ]])
 
     def __init__(self, *a, **kw):
@@ -85,7 +89,7 @@
 
     def HMIexec(self, function, *args, **kwargs):
         if self.HMI is not None:
-            getattr(self.HMI, function, lambda:None)(*args, **kwargs)
+            getattr(self.HMI, function, lambda: None)(*args, **kwargs)
     athena.expose(HMIexec)
 
     def resetHMI(self):
@@ -110,15 +114,16 @@
         for child in self.liveFragmentChildren[:]:
             child.detach()
 
+
 class WebInterface(athena.LivePage):
 
     docFactory = loaders.stan([tags.raw(xhtml_header),
-                                tags.html(xmlns="http://www.w3.org/1999/xhtml")[
-                                    tags.head(render=tags.directive('liveglue')),
-                                    tags.body[
-                                        tags.div[
-                                                tags.div( render = tags.directive( "MainPage" ))
-                                                ]]]])
+                               tags.html(xmlns="http://www.w3.org/1999/xhtml")[
+                                   tags.head(render=tags.directive('liveglue')),
+                                   tags.body[
+                                       tags.div[
+                                           tags.div(render=tags.directive("MainPage"))
+                                       ]]]])
     MainPage = MainPage()
     PLCHMI = PLCHMI
 
@@ -170,8 +175,9 @@
 
     def disconnected(self, reason):
         self.MainPage.resetHMI()
-        #print reason
-        #print "We will be called back when the client disconnects"
+        # print reason
+        # print "We will be called back when the client disconnects"
+
 
 def RegisterWebsite(port):
     website = WebInterface()
@@ -182,6 +188,7 @@
     print _("HTTP interface port :"), port
     return website
 
+
 class statuslistener:
     def __init__(self, site):
         self.oldstate = None
@@ -191,8 +198,10 @@
         if state != self.oldstate:
             action = {'Started': self.site.PLCStarted,
                       'Stopped': self.site.PLCStopped}.get(state, None)
-            if action is not None: action ()
+            if action is not None:
+                action()
             self.oldstate = state
 
+
 def website_statuslistener_factory(site):
     return statuslistener(site).listen