[pypy-svn] r18044 - in pypy/dist/pypy/translator/tool: . pygame
arigo at codespeak.net
arigo at codespeak.net
Sat Oct 1 11:43:02 CEST 2005
Author: arigo
Date: Sat Oct 1 11:42:56 2005
New Revision: 18044
Modified:
pypy/dist/pypy/translator/tool/port.py
pypy/dist/pypy/translator/tool/pygame/graphclient.py
Log:
Try to use the local 'dot' before codespeak's. I'm not 100% sure it will
catch all cases, but I think that most ways in which the buggy 'dot' can fail
will leave behind a file that GraphLayout.__init__() will fail to parse.
An idea for py.execnet too: passing marshal data over a socket can be fine if
the receiver is ready to use pypy/lib/_marshal.py to decode it (2.3/2.4
conflict).
--This line, and those below, will be ignored--
M tool/pygame/graphclient.py
M tool/port.py
Modified: pypy/dist/pypy/translator/tool/port.py
==============================================================================
--- pypy/dist/pypy/translator/tool/port.py (original)
+++ pypy/dist/pypy/translator/tool/port.py Sat Oct 1 11:42:56 2005
@@ -17,7 +17,12 @@
hdr_size = struct.calcsize("!i")
msg_size, = struct.unpack("!i", recv_all(s, hdr_size))
msg = recv_all(s, msg_size)
- return marshal.loads(msg)
+ try:
+ return marshal.loads(msg)
+ except ValueError:
+ # fall-back if Python 2.3 receives a 2.4 marshal format
+ from pypy.lib._marshal import loads
+ return loads(msg)
def send_msg(s, msg):
data = marshal.dumps(msg)
Modified: pypy/dist/pypy/translator/tool/pygame/graphclient.py
==============================================================================
--- pypy/dist/pypy/translator/tool/pygame/graphclient.py (original)
+++ pypy/dist/pypy/translator/tool/pygame/graphclient.py Sat Oct 1 11:42:56 2005
@@ -8,16 +8,15 @@
from pypy.translator.tool.pygame.drawgraph import display_async_cmd, display_async_quit
from pypy.translator.tool.graphserver import MissingPage, portutil
from pypy.tool.udir import udir
-from py.process import cmdexec
+import py
DOT_FILE = udir.join('graph.dot')
PLAIN_FILE = udir.join('graph.plain')
-import py
-def dot2plain(dotfile, plainfile):
- if 0:
- cmdexec('dot -Tplain %s>%s' % (dotfile, plainfile))
+def dot2plain(dotfile, plainfile, use_codespeak=False):
+ if not use_codespeak:
+ py.process.cmdexec('dot -Tplain %s>%s' % (dotfile, plainfile))
elif 0:
gw = py.execnet.SshGateway('codespeak.net')
channel = gw.remote_exec("""
@@ -36,27 +35,22 @@
import urllib
content = py.path.local(dotfile).read()
request = urllib.urlencode({'dot': content})
- try:
- urllib.urlretrieve('http://codespeak.net/pypy/convertdot.cgi',
- str(plainfile),
- data=request)
- except IOError:
- success = False
- else:
- plainfile = py.path.local(plainfile)
- success = (plainfile.check(file=1) and
- plainfile.read().startswith('graph '))
- if not success:
- print "NOTE: failed to use codespeak's convertdot.cgi, trying local 'dot'"
- cmdexec('dot -Tplain %s>%s' % (dotfile, plainfile))
+ urllib.urlretrieve('http://codespeak.net/pypy/convertdot.cgi',
+ str(plainfile),
+ data=request)
class ClientGraphLayout(GraphLayout):
def __init__(self, connexion, key, dot, links, **ignored):
# generate a temporary .dot file and call dot on it
DOT_FILE.write(dot)
- dot2plain(DOT_FILE, PLAIN_FILE)
- GraphLayout.__init__(self, PLAIN_FILE)
+ try:
+ dot2plain(DOT_FILE, PLAIN_FILE, use_codespeak=False)
+ GraphLayout.__init__(self, PLAIN_FILE)
+ except (py.error.Error, IOError, TypeError, ValueError):
+ # failed, try via codespeak
+ dot2plain(DOT_FILE, PLAIN_FILE, use_codespeak=True)
+ GraphLayout.__init__(self, PLAIN_FILE)
self.connexion = connexion
self.key = key
self.links.update(links)
More information about the Pypy-commit
mailing list