p3lib 1.1.58__py3-none-any.whl → 1.1.60__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
p3lib/bokeh_gui.py CHANGED
@@ -461,7 +461,7 @@ class SingleAppServer(object):
461
461
  the freedom to define your app as required."""
462
462
 
463
463
  @staticmethod
464
- def GetNextUnusedPort(basePort=1024, maxPort = 65534, bindAddress="localhost"):
464
+ def GetNextUnusedPort(basePort=1024, maxPort = 65534, bindAddress="0.0.0.0"):
465
465
  """@brief Get the first unused above the base port.
466
466
  @param basePort The port to start checking for available ports.
467
467
  @param maxPort The highest port number to check.
@@ -739,3 +739,82 @@ class GUIModel_A(SingleAppServer):
739
739
  if time() > self._lastUpdateTime+10:
740
740
  self._debug("Updating GUI: Outstanding messages = {}".format( self._plotDataQueue.qsize()) )
741
741
  self._lastUpdateTime = time()
742
+
743
+
744
+ class MultiAppServer(object):
745
+ """@brief Responsible for running a bokeh server containing a multiple apps.
746
+ The server may be started by calling either a blocking or a non
747
+ blocking method. This provides a basic parent class with
748
+ the freedom to define your app as required."""
749
+
750
+ BOKEH_ALLOW_WS_ORIGIN = 'BOKEH_ALLOW_WS_ORIGIN'
751
+
752
+ @staticmethod
753
+ def GetNextUnusedPort(basePort=1024, maxPort = 65534, bindAddress="0.0.0.0"):
754
+ """@brief A helper method to get the first unused above the base port.
755
+ @param basePort The port to start checking for available ports.
756
+ @param maxPort The highest port number to check.
757
+ @param bindAddress The address to bind to.
758
+ @return The TCP port or -1 if no port is available."""
759
+ return SingleAppServer.GetNextUnusedPort(basePort=basePort, maxPort=maxPort, bindAddress=bindAddress)
760
+
761
+ def __init__(self, address="0.0.0.0", bokehPort=0, wsOrigin="*:*"):
762
+ """@Constructor
763
+ @param address The address of the bokeh server.
764
+ @param bokehPort The TCP port to run the server on. If left at the default
765
+ of 0 then a spare TCP port will be used.
766
+ """
767
+ if bokehPort == 0:
768
+ bokehPort = MultiAppServer.GetNextUnusedPort()
769
+ self._bokehPort=bokehPort
770
+ self._address=address
771
+ os.environ[MultiAppServer.BOKEH_ALLOW_WS_ORIGIN]=wsOrigin
772
+
773
+ def getServerPort(self):
774
+ """@return The bokeh server port."""
775
+ return self._bokehPort
776
+
777
+ def _getAppDict(self, appMethodDict):
778
+ """@brief Get a dict that can be passed to the Server object to
779
+ define the apps to be served."""
780
+ appDict = {}
781
+ for key in appMethodDict:
782
+ appMethod = appMethodDict[key]
783
+ appDict[key]=Application(FunctionHandler(appMethod))
784
+ return appDict
785
+
786
+ def runBlockingBokehServer(self, appMethodDict, openBrowser=True):
787
+ """@brief Run the bokeh server. This method will only return when the server shuts down.
788
+ @param appMethodDict This dict holds references to all the apps yourwish the server
789
+ to run.
790
+ The key to each dict entry should be the last part of the URL to point to the app.
791
+ E.G '/' is the root app which is displayed when the full URL is given.
792
+ The value should be a reference to the method on this object that holds
793
+ the app code.
794
+ @param openBrowser If True then open a browser connected to the / app (default=True)."""
795
+ appDict = self._getAppDict(appMethodDict)
796
+
797
+ #As this gets run in a thread we need to start an event loop
798
+ evtLoop = asyncio.new_event_loop()
799
+ asyncio.set_event_loop(evtLoop)
800
+ self._server = Server(appDict, address=self._address, port=self._bokehPort)
801
+ self._server.start()
802
+ if openBrowser:
803
+ #Show the server in a web browser window
804
+ self._server.io_loop.add_callback(self._server.show, "/")
805
+ self._server.io_loop.start()
806
+
807
+ def runNonBlockingBokehServer(self, appMethodDict, openBrowser=True):
808
+ """@brief Run the bokeh server in a separate thread. This is useful
809
+ if the we want to load realtime data into the plot from the
810
+ main thread.
811
+ @param @param appMethodDict This dict holds references to all the apps yourwish the server
812
+ to run.
813
+ The key to each dict entry should be the last part of the URL to point to the app.
814
+ E.G '/' is the root app which is displayed when the full URL is given.
815
+ The value should be a reference to the method on this object that holds
816
+ the app code.
817
+ @param openBrowser If True then open a browser connected to the / app (default=True)"""
818
+ self._serverThread = threading.Thread(target=self.runBlockingBokehServer, args=(appMethodDict,openBrowser))
819
+ self._serverThread.setDaemon(True)
820
+ self._serverThread.start()
p3lib/database_if.py CHANGED
@@ -207,7 +207,6 @@ class DatabaseIF(object):
207
207
  cmd = "SELECT COUNT(*) as count from {};".format(tableName)
208
208
  retList = self.executeSQL(cmd)
209
209
  if len(retList) > 0:
210
- print()
211
210
  count = retList[0]['count']
212
211
  return count
213
212
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.58
3
+ Version: 1.1.60
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  Home-page: https://github.com/pjaos/p3lib
6
6
  Author: Paul Austen
@@ -1,8 +1,8 @@
1
1
  p3lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- p3lib/bokeh_gui.py,sha256=IOHZHiWvrF4V1lKS5D8PgsjTx-HQKNhSdp1FjonyqW8,34863
2
+ p3lib/bokeh_gui.py,sha256=8KhIGv6GrbbzOLm97hXSSKymDaR0ambg0-1ZSFgD0G4,38903
3
3
  p3lib/boot_manager.py,sha256=Gx7A8gdRHnpvk1sh5k4lixJQSCxA4TKCe-qGmJYWtyI,12650
4
4
  p3lib/conduit.py,sha256=jPkjdtyCx2I6SFqcEo8y2g7rgnZ-jNY7oCuYIETzT5Q,6046
5
- p3lib/database_if.py,sha256=Py-Y5FKgDVnqEV7Xd87_L2MLLpOqSXUFsmI1lba6P8Y,11917
5
+ p3lib/database_if.py,sha256=mgTdSeCTQs1V10E7KuyK3xRkdaU3RXrqYpMQvosrA_M,11897
6
6
  p3lib/helper.py,sha256=-B63_ncfchMwXrvyVcnj9sxwGnMJ3ASmLmpoYa4tBmM,11862
7
7
  p3lib/json_networking.py,sha256=6u4s1SmypjTYPnSxHP712OgQ3ZJaxOqIkgHQ1J7Qews,9738
8
8
  p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
@@ -11,8 +11,8 @@ p3lib/netplotly.py,sha256=PMDx-w1jtRVW6Od5u_kuKbBxNpTS_Y88mMF60puMxLM,9363
11
11
  p3lib/pconfig.py,sha256=_ri9w3aauHXZp8u2YLYHBVroFR_iCqaTCwj_MRa3rHo,30153
12
12
  p3lib/ssh.py,sha256=YE1ddgiEt9EeBM8evuxCV8Gnj4jz1Sv52vEKidvjrJA,38369
13
13
  p3lib/uio.py,sha256=S3yrPADLJeXOJeBXC4RBA47Ef3BIldLzDBItQoj1agA,20911
14
- p3lib-1.1.58.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
15
- p3lib-1.1.58.dist-info/METADATA,sha256=c53RuK4oFgIx-v_iin3_OvHjlyh9hkGY5AxxqwLFWYA,924
16
- p3lib-1.1.58.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
17
- p3lib-1.1.58.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
18
- p3lib-1.1.58.dist-info/RECORD,,
14
+ p3lib-1.1.60.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
15
+ p3lib-1.1.60.dist-info/METADATA,sha256=T670NYVhGo0a_bR4Kp1H52TvArcrxEHrSQ99jx_Q7Ig,924
16
+ p3lib-1.1.60.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
17
+ p3lib-1.1.60.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
18
+ p3lib-1.1.60.dist-info/RECORD,,
File without changes