[pypy-svn] r41430 - in pypy/build/buildtool: . bin

guido at codespeak.net guido at codespeak.net
Mon Mar 26 22:38:14 CEST 2007


Author: guido
Date: Mon Mar 26 22:38:08 2007
New Revision: 41430

Added:
   pypy/build/buildtool/bin/removebuild.py   (contents, props changed)
Modified:
   pypy/build/buildtool/bin/buildserver.py
   pypy/build/buildtool/buildserver.py
Log:
Fixed another path problem (in remote buildserver code), added script to remove
builds (both from queue and disk), made that temp dirs are removed after a
compilation.


Modified: pypy/build/buildtool/bin/buildserver.py
==============================================================================
--- pypy/build/buildtool/bin/buildserver.py	(original)
+++ pypy/build/buildtool/bin/buildserver.py	Mon Mar 26 22:38:08 2007
@@ -4,6 +4,7 @@
 import py
 from py.execnet import PopenGateway
 from buildtool import outputbuffer
+from buildtool import config
 
 def compile(wc, compileinfo, buildpath):
     code = """\
@@ -13,8 +14,9 @@
 
         # interpolating the path
         pypath = %r
+        buildtoolpath = %r
 
-        sys.path = [pypath] + sys.path
+        sys.path = [pypath] + sys.path + buildtoolpath
         os.chdir(pypath)
 
         # interpolating config
@@ -76,8 +78,8 @@
     """
     gw = PopenGateway()
     interpolated = py.code.Source(outputbuffer,
-                                  code % (str(wc), compileinfo,
-                                  str(buildpath)))
+                                  code % (str(wc), config.path,
+                                  compileinfo, str(buildpath)))
     channel = gw.remote_exec(interpolated)
     try:
         upath = channel.receive()

Added: pypy/build/buildtool/bin/removebuild.py
==============================================================================
--- (empty file)
+++ pypy/build/buildtool/bin/removebuild.py	Mon Mar 26 22:38:08 2007
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+
+import autopath
+from buildtool import execnetconference
+from py.execnet import PopenGateway, SshGateway
+
+code = """
+    import sys
+    sys.path += %r
+
+    id = %r
+    
+    try:
+        from buildtool import metaserver_instance
+        ret = None
+        for lname in ('waiting', 'queued'):
+            l = getattr(metaserver_instance, '_%%s' %% (lname,))
+            found = False
+            for req in l:
+                if req.id() == id:
+                    l.remove(req)
+                    ret = 'removed item from %%s' %% (lname,)
+                    found = True
+                    break
+            if found:
+                break
+        else:
+            for builder in metaserver_instance._builders:
+                if builder.busy_on and builder.busy_on.id() == id:
+                    ret = ('cannot remove running compilations, please wait '
+                           'until it\\'s done')
+                    break
+            else:
+                for bp in metaserver_instance._done:
+                    if bp.request.id() == id:
+                        metaserver_instance._done.remove(bp)
+                        bp.remove()
+                        ret = 'removed item and data from done builds'
+                        break
+                else:
+                    ret = 'no such build'
+        channel.send(ret)
+    finally:
+        channel.close()
+"""
+def removebuild(id, gw, port, path):
+    conference = execnetconference.conference(gw, port, False)
+    channel = conference.remote_exec(code % (path, id))
+    return channel.receive()
+
+if __name__ == '__main__':
+    import sys
+    from buildtool import config
+    if len(sys.argv) != 2:
+        print 'usage: %s <id>' % (sys.argv[0],)
+        print '(where <id> is the id of a build on the build server)'
+        sys.exit(1)
+    if config.server in ['localhost', '127.0.0.1']:
+        gw = PopenGateway()
+    else:
+        gw = SshGateway(config.server)
+    print removebuild(sys.argv[1], gw, config.port, config.path)

Modified: pypy/build/buildtool/buildserver.py
==============================================================================
--- pypy/build/buildtool/buildserver.py	(original)
+++ pypy/build/buildtool/buildserver.py	Mon Mar 26 22:38:08 2007
@@ -220,24 +220,29 @@
             svnwc.checkout(request.svnurl)
             svnwc.update(request.normalized_rev)
 
+            upath = None
             try:
-                print 'starting compilation'
-                upath, log = compilefunc(svnwc, request.compileinfo,
-                                         temp)
-            except (SystemExit, KeyboardInterrupt):
-                print 'quitting...'
-                break
+                try:
+                    print 'starting compilation'
+                    upath, log = compilefunc(svnwc, request.compileinfo,
+                                             temp)
+                except (SystemExit, KeyboardInterrupt):
+                    print 'quitting...'
+                    break
 
-            if upath:
-                # send over zip data, end with a None
-                print 'compilation successful, sending to server'
-                wrapper = ChannelWrapper(channel)
-                zip_dir(py.path.local(upath), wrapper)
-                wrapper.close()
-            else:
-                print 'compilation failed, notifying server'
-                # just send the None
-                channel.send(None)
+                if upath:
+                    # send over zip data, end with a None
+                    print 'compilation successful, sending to server'
+                    wrapper = ChannelWrapper(channel)
+                    zip_dir(py.path.local(upath), wrapper)
+                    wrapper.close()
+                else:
+                    print 'compilation failed, notifying server'
+                    # just send the None
+                    channel.send(None)
+            finally:
+                if upath:
+                    upath.remove()
             
             # send over logs
             print 'sending log'



More information about the Pypy-commit mailing list