comparison src/server/server.py @ 1063:4b69f69c6ffd

server: new ProgressHandler helper class, to handle progressing actions
author Goffi <goffi@goffi.org>
date Sun, 11 Mar 2018 19:30:37 +0100
parents c2037b44f84e
children d1324e43d448
comparison
equal deleted inserted replaced
1062:c80649cdadd5 1063:4b69f69c6ffd
52 import time 52 import time
53 from httplib import HTTPS_PORT 53 from httplib import HTTPS_PORT
54 import libervia 54 import libervia
55 from libervia.server import websockets 55 from libervia.server import websockets
56 from libervia.server.pages import LiberviaPage 56 from libervia.server.pages import LiberviaPage
57 from libervia.server.utils import quote 57 from libervia.server.utils import quote, ProgressHandler
58 from functools import partial 58 from functools import partial
59 59
60 try: 60 try:
61 import OpenSSL 61 import OpenSSL
62 from twisted.internet import ssl 62 from twisted.internet import ssl
1481 LiberviaPage.setMenu(self.options['menu_json']) 1481 LiberviaPage.setMenu(self.options['menu_json'])
1482 ## following signal is needed for cache handling in Libervia pages 1482 ## following signal is needed for cache handling in Libervia pages
1483 self.bridge.register_signal("psEventRaw", partial(LiberviaPage.onNodeEvent, self), "plugin") 1483 self.bridge.register_signal("psEventRaw", partial(LiberviaPage.onNodeEvent, self), "plugin")
1484 self.bridge.register_signal("messageNew", partial(LiberviaPage.onSignal, self, "messageNew")) 1484 self.bridge.register_signal("messageNew", partial(LiberviaPage.onSignal, self, "messageNew"))
1485 1485
1486 # Progress handling
1487 self.bridge.register_signal("progressStarted", partial(ProgressHandler._signal, "started"))
1488 self.bridge.register_signal("progressFinished", partial(ProgressHandler._signal, "finished"))
1489 self.bridge.register_signal("progressError", partial(ProgressHandler._signal, "error"))
1490
1491
1486 # media dirs 1492 # media dirs
1487 # FIXME: get rid of dirname and "/" in C.XXX_DIR 1493 # FIXME: get rid of dirname and "/" in C.XXX_DIR
1488 self.putChild(os.path.dirname(C.MEDIA_DIR), ProtectedFile(self.media_dir)) 1494 self.putChild(os.path.dirname(C.MEDIA_DIR), ProtectedFile(self.media_dir))
1489 self.cache_resource = web_resource.NoResource() 1495 self.cache_resource = web_resource.NoResource()
1490 self.putChild(C.CACHE_DIR, self.cache_resource) 1496 self.putChild(C.CACHE_DIR, self.cache_resource)