Permalink
Browse files

Merge branch 'master' into f_master

  • Loading branch information...
2 parents 03174e8 + 9c75629 commit bd0c8662ecc7bc48108d400b0bd55a6c4176cc5a @ctb committed Apr 17, 2010
View
@@ -0,0 +1,45 @@
+#! /usr/bin/env python
+import sys
+import pprint
+from pony_client import BuildCommand, TestCommand, do, send, \
+ TempDirectoryContext, SetupCommand, SvnCheckout, check, parse_cmdline
+
+options, args = parse_cmdline()
+if args:
+ print 'ignoring command line args: ', args
+
+repo_url = 'http://wwwsearch.sourceforge.net/mechanize/src/mechanize-0.1.11.tar.gz'
+
+python_exe = 'python'
+if args:
+ python_exe = args[0]
+
+name = 'mechanize'
+tags = ['mechanize']
+server_url = options.server_url
+
+if not options.force_build:
+ if not check(name, server_url, tags=tags):
+ print 'check build says no need to build; bye'
+ sys.exit(0)
+
+commands = [ SvnCheckout('mechanize', repo_url, name='checkout'),
+ BuildCommand([python_exe, 'setup.py', 'test'])
+ ]
+
+context = TempDirectoryContext()
+results = do(name, commands, context=context)
+client_info, reslist, files = results
+
+if options.report:
+ print 'result: %s; sending' % (client_info['success'],)
+ send(server_url, results, tags=tags)
+else:
+ print 'build result:'
+ pprint.pprint(client_info)
+ pprint.pprint(reslist)
+
+ print '(NOT SENDING BUILD RESULT TO SERVER)'
+
+if not client_info['success']:
+ sys.exit(-1)
@@ -14,7 +14,7 @@
repo_url = 'http://bitbucket.org/jpellerin/nose/'
tags = ['nose']
-name = 'build-nose'
+name = 'nose'
server_url = options.server_url
@@ -44,5 +44,4 @@
print '(NOT SENDING BUILD RESULT TO SERVER)'
if not client_info['success']:
- sys.exit(-1)
-
+ sys.exit(-1)
View
@@ -3,19 +3,16 @@ import sys
import pprint
from pony_client import BuildCommand, TestCommand, do, send, \
TempDirectoryContext, SetupCommand, GitClone, check, parse_cmdline, \
- PythonPackageEgg, test_python_version
+ PythonPackageEgg, get_python_version
options, _ = parse_cmdline()
python_exe = options.python_executable
-if not test_python_version(python_exe):
- print "Unable to find " + python_exe + ". Failing..."
- sys.exit(1)
-
repo_url = 'git://quixote.ca/quixote'
-tags = [python_exe] + options.tagset
+python_ver = 'python' + get_python_version(python_exe)
+tags = [python_ver] + options.tagset
name = 'quixote'
server_url = options.server_url
View
@@ -17,13 +17,16 @@
from optparse import OptionParser
import pprint
import glob
+import datetime
+import signal
pb_servers = {
- 'pb-dev' : 'http://lyorn.idyll.org/ctb/pb-dev/xmlrpc',
- 'local' : 'http://localhost:8000/xmlrpc'
+ 'pb-dev' : 'http://lyorn.idyll.org/ctb/pb-dev/',
+ 'local' : 'http://localhost:8000/'
}
pb_servers['default'] = pb_servers['pb-dev']
+
###
DEBUG_LEVEL = 5
@@ -91,7 +94,10 @@ def _replace_variables(cmd, variables_d):
cmd = variables_d[cmd[3:]]
return cmd
-def _run_command(command_list, cwd=None, variables=None, extra_kwargs={}):
+
+def _run_command(command_list, cwd=None, variables=None, extra_kwargs={},
+ verbose=False):
+
if variables:
x = []
for cmd in command_list:
@@ -222,7 +228,7 @@ def __init__(self, always_cleanup=True, dependencies=[], optional=[],
cmdlist.append('--no-site-packages')
cmdlist.append(self.tempdir)
-
+
(ret, out, err) = _run_command(cmdlist)
if ret != 0:
@@ -240,6 +246,7 @@ def __init__(self, always_cleanup=True, dependencies=[], optional=[],
def initialize(self):
Context.initialize(self)
+
log_info('changing to temp directory:', self.tempdir)
self.cwd = os.getcwd()
@@ -786,10 +793,10 @@ def _upload_file(server_url, fileobj, auth_key):
def do(name, commands, context=None, arch=None, stop_if_failure=True):
reslist = []
-
+
if context:
context.initialize()
-
+
for c in commands:
log_debug('running:', str(c))
if context:
@@ -799,7 +806,7 @@ def do(name, commands, context=None, arch=None, stop_if_failure=True):
context.end_command(c)
reslist.append(c.get_results())
-
+
if stop_if_failure and not c.success():
break
@@ -845,6 +852,8 @@ def send(server_url, x, hostname=None, tags=()):
_upload_file(server_url, fileobj, auth_key)
def check(name, server_url, tags=(), hostname=None, arch=None, reserve_time=0):
+ import socket
+
if hostname is None:
hostname = get_hostname()
@@ -854,16 +863,21 @@ def check(name, server_url, tags=(), hostname=None, arch=None, reserve_time=0):
client_info = dict(package=name, host=hostname, arch=arch, tags=tags)
server_url = get_server_url(server_url)
s = xmlrpclib.ServerProxy(server_url, allow_none=True)
- (flag, reason) = s.check_should_build(client_info, True, reserve_time)
+ try:
+ (flag, reason) = s.check_should_build(client_info, True, reserve_time)
+ except socket.error:
+ log_critical('cannot connect to pony-build server: %s' % server_url)
+ sys.exit(-1)
+
return flag
def get_server_url(server_name):
try_url = urlparse.urlparse(server_name)
if try_url[0]: # urlparse -> scheme
- server_url = server_name
+ server_url = urlparse.urljoin(server_name, 'xmlrpc')
else: # not a URL?
- server_url = pb_servers[server_name]
-
+ server_temp = pb_servers[server_name]
+ server_url = urlparse.urljoin(server_temp, 'xmlrpc')
return server_url
def get_tagsets_for_package(server, package):
@@ -888,7 +902,7 @@ def parse_cmdline(argv=[]):
help='do not clean up the temp directory')
cmdline.add_option('-s', '--server-url', dest='server_url',
- action='store', default='default',
+ action='store', default='pb-dev',
help='set pony-build server URL for reporting results')
cmdline.add_option('-v', '--verbose', dest='verbose',
@@ -936,13 +950,28 @@ def parse_cmdline(argv=[]):
###
+class PythonVersionNotFound(Exception):
+ def __init__(self, python_exe):
+ self.python_exe = python_exe
+ def __str__(self):
+ return repr(self.python_exe + " not found on system.")
+
-def test_python_version(python_exe):
- result = subprocess.Popen(python_exe + " -c \"print 'hello, world'\"", shell=True, \
- stdout=subprocess.PIPE).communicate()
- if result[0] != "hello, world\n":
- return False
- return True
+def get_python_version(python_exe='python'):
+ """
+ Return the major.minor number for the given Python executable.
+ """
+
+ cmd = python_exe + " -c \"import sys \nprint" \
+ " str(sys.version_info[0]) + '.' + str(sys.version_info[1])\""
+
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+ (stdout, stderr) = p.communicate()
+
+ if not stdout:
+ raise PythonVersionNotFound(python_exe)
+
+ return stdout.strip()
###
@@ -1,4 +1,13 @@
+import sys
import pony_client
def setup():
pony_client.set_log_level(pony_client.DEBUG_LEVEL)
+
+def test_python_version():
+ my_version = "%d.%d" % (sys.version_info[:2])
+
+ reported_version = pony_client.get_python_version(sys.executable)
+ reported_version = reported_version
+
+ assert my_version == reported_version, (my_version, reported_version)
View
@@ -11,6 +11,9 @@
help='interface to bind', default='localhost')
parser.add_option('-p', '--port', dest='port', help='port to bind',
type='int', default='5000')
+ parser.add_option('-f', '--dbfile', dest='dbfile',
+ help='database filename', type='string',
+ default=':memory:')
parser.add_option('-u', '--url', dest='url', help='public URL',
default=None)
parser.add_option('-P', '--use-pubsubhubbub', dest='use_pubsubhubbub',
@@ -22,11 +25,10 @@
(options, args) = parser.parse_args()
- dbfile=args[0]
push_server = None
if options.use_pubsubhubbub:
push_server = options.push_server
- qx_web.run(options.interface, options.port, dbfile, public_url=options.url,
+ qx_web.run(options.interface, options.port, options.dbfile, public_url=options.url,
pubsubhubbub_server=push_server)

0 comments on commit bd0c866

Please sign in to comment.