[pypy-svn] r44930 - pypy/dist/dotviewer

arigo at codespeak.net arigo at codespeak.net
Wed Jul 11 14:43:58 CEST 2007


Author: arigo
Date: Wed Jul 11 14:43:58 2007
New Revision: 44930

Modified:
   pypy/dist/dotviewer/dotviewer.py
   pypy/dist/dotviewer/graphclient.py
   pypy/dist/dotviewer/graphpage.py
Log:
Small enhancements.


Modified: pypy/dist/dotviewer/dotviewer.py
==============================================================================
--- pypy/dist/dotviewer/dotviewer.py	(original)
+++ pypy/dist/dotviewer/dotviewer.py	Wed Jul 11 14:43:58 2007
@@ -9,7 +9,8 @@
 In the first form, show the graph contained in a .dot file.
 In the second form, the graph was already compiled to a .plain file.
 In the third form, listen for connexion on the given port and display
-the graphs sent by the remote side.
+the graphs sent by the remote side.  On the remote site, set the
+GRAPHSERVER environment variable to HOST:PORT.
 """
 
 import sys

Modified: pypy/dist/dotviewer/graphclient.py
==============================================================================
--- pypy/dist/dotviewer/graphclient.py	(original)
+++ pypy/dist/dotviewer/graphclient.py	Wed Jul 11 14:43:58 2007
@@ -5,16 +5,16 @@
 GRAPHSERVER = os.path.join(this_dir, 'graphserver.py')
 
 
-def display_dot_file(dotfile, wait=True):
+def display_dot_file(dotfile, wait=True, save_tmp_file=None):
     """ Display the given dot file in a subprocess.
     """
     if not os.path.exists(str(dotfile)):
         raise IOError("No such file: %s" % (dotfile,))
     import graphpage
     page = graphpage.DotFileGraphPage(str(dotfile))
-    display_page(page, wait=wait)
+    display_page(page, wait=wait, save_tmp_file=save_tmp_file)
 
-def display_page(page, wait=True):
+def display_page(page, wait=True, save_tmp_file=None):
     messages = [(msgstruct.CMSG_INIT, msgstruct.MAGIC)]
     history = [page]
     pagecache = {}
@@ -31,6 +31,10 @@
 
     def reload(graph_id):
         page = getpage(graph_id)
+        if save_tmp_file:
+            f = open(save_tmp_file, 'w')
+            f.write(page.source)
+            f.close()
         messages.extend(page_messages(page, graph_id))
         send_graph_messages(io, messages)
         del messages[:]

Modified: pypy/dist/dotviewer/graphpage.py
==============================================================================
--- pypy/dist/dotviewer/graphpage.py	(original)
+++ pypy/dist/dotviewer/graphpage.py	Wed Jul 11 14:43:58 2007
@@ -3,6 +3,8 @@
     """Base class for the client-side content of one of the 'pages'
     (one graph) sent over to and displayed by the external process.
     """
+    save_tmp_file = None
+
     def __init__(self, *args):
         self.args = args
 
@@ -26,7 +28,7 @@
         "Display a graph page."
         import graphclient, msgstruct
         try:
-            graphclient.display_page(self)
+            graphclient.display_page(self, save_tmp_file=self.save_tmp_file)
         except msgstruct.RemoteError, e:
             import sys
             print >> sys.stderr, "Exception in the graph viewer:", str(e)



More information about the Pypy-commit mailing list