[pypy-svn] r30696 - in pypy/dist/pypy/tool/build: . bin test
guido at codespeak.net
guido at codespeak.net
Fri Jul 28 16:55:04 CEST 2006
Author: guido
Date: Fri Jul 28 16:54:49 2006
New Revision: 30696
Added:
pypy/dist/pypy/tool/build/systemoption.py
Modified:
pypy/dist/pypy/tool/build/bin/client
pypy/dist/pypy/tool/build/bin/server
pypy/dist/pypy/tool/build/bin/startcompile
pypy/dist/pypy/tool/build/client.py
pypy/dist/pypy/tool/build/config.py
pypy/dist/pypy/tool/build/server.py
pypy/dist/pypy/tool/build/test/test_server.py
Log:
Added system options from config, improved error reporting, added first bit
(temporary, should use pypy.config later I think) of cmdline option generation,
made that if the server is 'localhost' or '127.0.0.1' PopenGateway is used
instead of SshGateway (for testing purposes).
Modified: pypy/dist/pypy/tool/build/bin/client
==============================================================================
--- pypy/dist/pypy/tool/build/bin/client (original)
+++ pypy/dist/pypy/tool/build/bin/client Fri Jul 28 16:54:49 2006
@@ -7,36 +7,125 @@
import random
from pypy.tool.build import config
+# example compile_config
+{
+ 'translating': False,
+ 'objspace': {
+ 'std': {
+ 'withstrslice': False,
+ 'withstrdict': False,
+ 'withstrjoin': False,
+ 'oldstyle': False,
+ 'withprebuiltint': False,
+ 'prebuiltintto': 100,
+ 'prebuiltintfrom': -5,
+ 'withsmallint': False
+ },
+ 'name': 'std',
+ 'usemodules': {
+ '_sre': True,
+ 'errno': True,
+ '__builtin__': False,
+ 'crypt': False,
+ 'gc': True,
+ 'recparser': True,
+ 'rctime': False,
+ 'array': True,
+ 'select': False,
+ 'mmap': False,
+ '_socket': False,
+ 'time2': False,
+ '_stackless': False,
+ '_pickle_support': True,
+ '_random': False,
+ 'math': True,
+ 'fcntl': False,
+ '_ssl': False,
+ 'wraptest': False,
+ '_codecs': True,
+ 'symbol': True,
+ 'sys': True,
+ 'readline': False,
+ 'unicodedata': True,
+ 'thread': False,
+ '_weakref': True,
+ '_md5': False,
+ 'Numeric': False,
+ 'posix': False,
+ 'time': False,
+ 'marshal': True,
+ '_demo': False
+ },
+ 'geninterp': True,
+ 'parser': 'pypy',
+ 'uselibfile': False,
+ 'nofaking': False,
+ 'compiler': 'ast'
+ }
+}
+
+def info_to_options(info):
+ """temporary solution (until translate.py uses the config stuff) for
+ converting the compile_info dict to pypy translate options
+ """
+ opts = []
+
+ d = info[0]
+ opts.append('-b %s' % (info[0].get('backend', 'C'),))
+
+ d = info[1]
+ opts.append('-O %s' % (d['objspace']['name'],))
+ opts.append('--usemodules=%s' %
+ (','.join([k for k, v in
+ d['objspace']['usemodules'].items() if v]),))
+
+ return opts
+
if __name__ == '__main__':
- from py.execnet import SshGateway
+ from py.execnet import SshGateway, PopenGateway
from pypy.tool.build.client import init
- gw = SshGateway(config.server)
+
+ if config.server in ['localhost', '127.0.0.1']:
+ gw = PopenGateway()
+ else:
+ gw = SshGateway(config.server)
channel = init(gw, config.system_config, path=config.path,
port=config.port)
print channel.receive() # welcome message
try:
- while 1:
- data = channel.receive()
- if not isinstance(data, tuple): # needs more checks here
- raise ValueError(
- 'received wrong unexpected data of type %s' % (type(data),)
- )
- info = data
- # XXX we should compile here, using data dict for info
- print 'compilation requested for info %r, now faking that' % (info,)
- import time; time.sleep(10)
-
- # write the zip to the server in chunks to server
- # XXX we're still faking this
- zipfp = (path.packagedir / 'test/test.zip').open()
- while True:
- chunk = zipfp.read(BUFSIZE)
- if not chunk:
- break
- channel.send(chunk)
- channel.send(None) # tell the server we're done
- print 'done with compilation, waiting for next'
+ try:
+ while 1:
+ data = channel.receive()
+ if isinstance(data, str):
+ print data
+ continue
+ if not isinstance(data, tuple): # needs more checks here
+ raise ValueError(
+ 'received wrong unexpected data of type %s' % (
+ type(data),)
+ )
+ info = data
+ # XXX we should compile here, using data dict for info
+ print 'compilation requested for info %r, now faking that' % (
+ info,)
+ options = info_to_options(info)
+ print 'options:', options
+
+ import time; time.sleep(10)
+
+ # write the zip to the server in chunks to server
+ # XXX we're still faking this
+ zipfp = (path.packagedir / 'test/test.zip').open()
+ while True:
+ chunk = zipfp.read(BUFSIZE)
+ if not chunk:
+ break
+ channel.send(chunk)
+ channel.send(None) # tell the server we're done
+ print 'done with compilation, waiting for next'
+ except EOFError:
+ sys.exit()
finally:
channel.close()
gw.exit()
Modified: pypy/dist/pypy/tool/build/bin/server
==============================================================================
--- pypy/dist/pypy/tool/build/bin/server (original)
+++ pypy/dist/pypy/tool/build/bin/server Fri Jul 28 16:54:49 2006
@@ -6,10 +6,13 @@
from py.execnet import SshGateway
if __name__ == '__main__':
- from py.execnet import SshGateway
+ from py.execnet import SshGateway, PopenGateway
from pypy.tool.build.server import init
- gw = SshGateway(config.server)
+ if config.server in ['localhost', '127.0.0.1']:
+ gw = PopenGateway()
+ else:
+ gw = SshGateway(config.server)
channel = init(gw, port=config.port, path=config.path,
projectname=config.projectname,
buildpath=str(config.buildpath),
@@ -20,7 +23,8 @@
try:
while 1:
data = channel.receive()
- assert isinstance(data, str)
+ if not isinstance(data, str):
+ print 'received non-string "%s", ignoring' % (repr(data)[:10],)
print data
finally:
channel.close()
Modified: pypy/dist/pypy/tool/build/bin/startcompile
==============================================================================
--- pypy/dist/pypy/tool/build/bin/startcompile (original)
+++ pypy/dist/pypy/tool/build/bin/startcompile Fri Jul 28 16:54:49 2006
@@ -34,9 +34,18 @@
import sys
sys.path += %r
- from pypy.tool.build import ppbserver
- channel.send(ppbserver.compile(%r, (%r, %r)))
- channel.close()
+ try:
+ from pypy.tool.build import ppbserver
+ ret = ppbserver.compile(%r, (%r, %r))
+ channel.send(ret)
+ channel.close()
+ except:
+ import sys, traceback
+ exc, e, tb = sys.exc_info()
+ channel.send(str(exc) + ' - ' + str(e))
+ for line in traceback.format_tb(tb):
+ channel.send(line[:-1])
+ del tb
"""
def init(gw, sysinfo, compileinfo, path, email, port=12321):
from pypy.tool.build import execnetconference
@@ -47,7 +56,7 @@
return channel
if __name__ == '__main__':
- from py.execnet import SshGateway
+ from py.execnet import SshGateway, PopenGateway
from pypy.tool.build.server import config_to_dict
optparser, options, args = parse_options(config)
@@ -59,16 +68,30 @@
for k, v in sysinfo.items():
print '%s: %r' % (k, v)
print
+ for k, v in compileinfo.items():
+ print '%s: %r' % (k, v)
+ print
- gw = SshGateway(config.server)
+ if config.server in ['localhost', '127.0.0.1']:
+ gw = PopenGateway()
+ else:
+ gw = SshGateway(config.server)
channel = init(gw, sysinfo, compileinfo, config.path, args[0],
port=config.port)
- ispath, data = channel.receive()
- if ispath:
- print ('a suitable result is already available, you can find it '
- 'at "%s"' % (data,))
- else:
+ data = channel.receive()
+ if type(data) == str:
print data
- print 'you will be mailed once it\'s ready'
+ for line in channel:
+ print line
+ elif type(data) != tuple:
+ raise ValueError, 'invalid data returned: %r' % (data,)
+ else:
+ ispath, data = data
+ if ispath:
+ print ('a suitable result is already available, you can find it '
+ 'at "%s"' % (data,))
+ else:
+ print data
+ print 'you will be mailed once it\'s ready'
channel.close()
gw.exit()
Modified: pypy/dist/pypy/tool/build/client.py
==============================================================================
--- pypy/dist/pypy/tool/build/client.py (original)
+++ pypy/dist/pypy/tool/build/client.py Fri Jul 28 16:54:49 2006
@@ -61,8 +61,16 @@
from pypy.tool.build.client import PPBClient
try:
- client = PPBClient(channel, %r, %r)
- client.sit_and_wait()
+ try:
+ client = PPBClient(channel, %r, %r)
+ client.sit_and_wait()
+ except:
+ import sys, traceback
+ exc, e, tb = sys.exc_info()
+ channel.send(str(exc) + ' - ' + str(e))
+ for line in traceback.format_tb(tb):
+ channel.send(line[:-1])
+ del tb
finally:
channel.close()
"""
Modified: pypy/dist/pypy/tool/build/config.py
==============================================================================
--- pypy/dist/pypy/tool/build/config.py (original)
+++ pypy/dist/pypy/tool/build/config.py Fri Jul 28 16:54:49 2006
@@ -1,9 +1,11 @@
import py
+packageparent = py.magic.autopath().dirpath().dirpath().dirpath().dirpath()
+
# general settings, used by both server and client
-server = 'johnnydebris.net'
+server = 'localhost'
port = 12321
-path = ['/home/johnny/temp/pypy-dist']
+path = [str(packageparent)]
# configuration of options for client and startcompile
from pypy.config.config import Config, to_optparse
@@ -21,7 +23,7 @@
# settings for the server
projectname = 'pypy'
-buildpath = '/home/johnny/temp/pypy-dist/pypy/tool/build/builds'
+buildpath = packageparent.join('/pypy/tool/build/builds')
mailhost = '127.0.0.1'
mailport = 25
mailfrom = 'johnny at johnnydebris.net'
Modified: pypy/dist/pypy/tool/build/server.py
==============================================================================
--- pypy/dist/pypy/tool/build/server.py (original)
+++ pypy/dist/pypy/tool/build/server.py Fri Jul 28 16:54:49 2006
@@ -14,10 +14,10 @@
if not k in d2:
return False
d2v = d2[k]
- if isinstance(v, dict):
+ if isinstance(v, dict) and isinstance(d2v, dict):
if not issubdict(v, d2v):
return False
- elif isinstance(v, list):
+ elif isinstance(v, list) and isinstance(d2v, list):
if not set(v).issubset(set(d2v)):
return False
elif v != d2v:
@@ -191,8 +191,9 @@
"""
path = self._requeststorage.request(requester_email, info)
if path is not None:
+ pathstr = str(path)
self._channel.send('already a build for this info available')
- return (True, path)
+ return (True, pathstr)
for client in self._clients:
if client.busy_on == info:
self._channel.send('build for %r currently in progress' %
@@ -326,9 +327,11 @@
server.serve_forever()
except:
- import sys
+ import sys, traceback
exc, e, tb = sys.exc_info()
channel.send(str(exc) + ' - ' + str(e))
+ for line in traceback.format_tb(tb):
+ channel.send(line[:1])
del tb
finally:
channel.close()
Added: pypy/dist/pypy/tool/build/systemoption.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/tool/build/systemoption.py Fri Jul 28 16:54:49 2006
@@ -0,0 +1,11 @@
+import py
+from pypy.config.config import OptionDescription, BoolOption, IntOption
+from pypy.config.config import ChoiceOption, to_optparse, Config
+
+import sys
+system_optiondescription = OptionDescription('system', [
+ ChoiceOption('maxint', 'maximum int value in bytes (32/64)', ['32', '64'],
+ sys.maxint, '-i --maxint'),
+ ChoiceOption('byteorder', 'endianness, byte order (little/big)',
+ sys.byteorder, ['little', 'big'], '-b --byteorder'),
+])
Modified: pypy/dist/pypy/tool/build/test/test_server.py
==============================================================================
--- pypy/dist/pypy/tool/build/test/test_server.py (original)
+++ pypy/dist/pypy/tool/build/test/test_server.py Fri Jul 28 16:54:49 2006
@@ -76,8 +76,8 @@
svr.compilation_done((info, None), bp)
ret = svr.compile('test at domain.com', (info, None))
assert ret[0]
- assert isinstance(ret[1], BuildPath)
- assert ret[1] == bp
+ assert isinstance(ret[1], str)
+ assert BuildPath(ret[1]) == bp
assert svr._channel.receive().find('compilation done for') > -1
for i in range(2):
assert svr._channel.receive().find('going to send email to') > -1
More information about the Pypy-commit
mailing list