def _save_pdf(self, plotter): with self._pdf_lock: figure = plotter.redraw() if plotter.id in self._pdf_units_served: from veles.portable import show_file self._pdf_trigger = False self._pdf_pages.close() self._pdf_pages = None self._pdf_units_served.clear() self._pdf_unit_chains.clear() self.info("Finished writing PDF %s", self._pdf_file_name) show_file(self._pdf_file_name) self._pdf_file_name = None if self.backend != "pdf": return if self._pdf_pages is None: now = datetime.datetime.now() out_dir = os.path.join(root.common.dirs.cache, "plots") try: os.makedirs(out_dir, mode=0o775) except OSError: pass self._pdf_file_name = os.path.join( root.common.dirs.cache, "plots/veles_%s.pdf" % (now.strftime('%Y-%m-%d_%H:%M:%S'))) self.debug("Saving figures to %s...", self._pdf_file_name) import matplotlib.backends.backend_pdf as backend_pdf self._pdf_pages = backend_pdf.PdfPages(self._pdf_file_name) self._pdf_units_served.add(plotter.id) if getattr(plotter, "clear_plot", False): self._pdf_unit_chains.add(plotter.name) elif (plotter.name not in self._pdf_unit_chains or getattr(plotter, "redraw_plot", False)): self._pdf_pages.savefig(figure)
def _visualize_workflow(self): _, file_name = self.workflow.generate_graph(with_data_links=True, background='white') from veles.portable import show_file show_file(file_name) import signal self.launcher.graphics_client.send_signal(signal.SIGUSR2) from twisted.internet import reactor reactor.callWhenRunning(self._run_workflow_plotters) reactor.callWhenRunning(print_, "Press Ctrl-C when you are done...") reactor.run()
def __html__(): """ Opens VELES html documentation in the default web browser and builds it, if it does not exist. """ import os from veles.config import root from veles.portable import show_file if not os.path.exists(root.common.dirs.help): print("\"%s\" does not exist, unable to open the docs" % root.common.dirs.help) return page = os.path.join(root.common.dirs.help, "index.html") if not os.path.exists(page): from runpy import run_path print("Building the documentation...") run_path(os.path.join(__root__, "docs/generate_docs.py")) if os.path.exists(page): show_file(page)
def open_browser(): from veles.portable import show_file show_file("http://localhost:%d" % port)