def notebook_widget(delay=0.5, **kwargs): """ Poll the queues and update a html table. """ from IPython.core.display import HTML, Javascript, display # Connect to the server and retrieve status. conn = client.form_client_connection(**kwargs) display(HTML(TABLE)) while True: try: # Retrieve the data for each queue. data = client.simple_job_query(conn) # Reduce the information and update the table. display(Javascript(JS.format(*[len(x) for x in data.values()]))) # Poll every half second. time.sleep(delay) except (KeyboardInterrupt, SystemExit): return
def gui_watcher(): """ Polls job information to update a tree view. """ # Connect to the server and retrieve status. conn = client.form_client_connection() job_data = client.simple_job_query(conn) # Form a callback for tree updates. update_callback = partial(client.simple_job_query, conn) app = QtGui.QApplication(sys.argv) # Form a model and view. data = tree_from_jobs(job_data) model = NamesModel(data) view = TreeModelView(update_callback) view.setModel(model) view.setWindowTitle("IPcluster status") view.show() sys.exit(app.exec_())