[py-svn] r34227 - in py/dist/py/test: . rsession

arigo at codespeak.net arigo at codespeak.net
Sun Nov 5 12:31:14 CET 2006


Author: arigo
Date: Sun Nov  5 12:31:05 2006
New Revision: 34227

Modified:
   py/dist/py/test/cmdline.py
   py/dist/py/test/rsession/box.py
   py/dist/py/test/rsession/rsession.py
   py/dist/py/test/rsession/slave.py
Log:
(fijal, arigo)

Kill some imports and dead code.


Modified: py/dist/py/test/cmdline.py
==============================================================================
--- py/dist/py/test/cmdline.py	(original)
+++ py/dist/py/test/cmdline.py	Sun Nov  5 12:31:05 2006
@@ -4,8 +4,6 @@
 # main entry point
 #
 
-from py.__.test.rsession.rsession import AbstractSession
-
 def main(args=None):
     warn_about_missing_assertion()
     if args is None:
@@ -17,12 +15,16 @@
     session = sessionclass(config)
     
     # ok, some option checks
-    if config.option.startserver and not isinstance(session, AbstractSession):
-        print "Cannot use web server without (R|L)Session"
-        raise SystemExit, 2
-    if config.option.apigen and not isinstance(session, AbstractSession):
-        print "Cannot generate API without (R|L)Session"
-        raise SystemExit, 2
+    if config.option.startserver:
+        from py.__.test.rsession.rsession import AbstractSession
+        if not isinstance(session, AbstractSession):
+            print "Cannot use web server without (R|L)Session"
+            raise SystemExit, 2
+    if config.option.apigen:
+        from py.__.test.rsession.rsession import AbstractSession
+        if not isinstance(session, AbstractSession):
+            print "Cannot generate API without (R|L)Session"
+            raise SystemExit, 2
     if config.option.runbrowser and not config.option.startserver:
         print "Cannot point browser when not starting server"
         raise SystemExit, 2

Modified: py/dist/py/test/rsession/box.py
==============================================================================
--- py/dist/py/test/rsession/box.py	(original)
+++ py/dist/py/test/rsession/box.py	Sun Nov  5 12:31:05 2006
@@ -7,7 +7,6 @@
 import os
 import sys
 import marshal
-import thread
 
 NICE_LEVEL = 0     # XXX make it a conftest option
 
@@ -36,101 +35,6 @@
         self.exitstat = 0
         return 123
 
-class FifoBox(object):
-    def __init__(self, fun, args = [], kwargs = {}):
-        self.fun = fun
-        self.args = args
-        self.kwargs = kwargs
-    
-    def run(self):
-        dirname = tempfile.mkdtemp("pytest")
-        self.dirname = dirname
-        self.PYTESTRETVAL = os.path.join(dirname, PYTESTRETVAL)
-        self.PYTESTSTDERR = os.path.join(dirname, PYTESTSTDERR)
-        self.PYTESTSTDOUT = os.path.join(dirname, PYTESTSTDOUT)
-        os.mkfifo(self.PYTESTSTDOUT)
-        os.mkfifo(self.PYTESTSTDERR)
-        os.mkfifo(self.PYTESTRETVAL)
-        pid = os.fork()
-        if pid:
-            self.parent()
-        else:
-            try:
-                outcome = self.children()
-            except:
-                excinfo = py.code.ExceptionInfo()
-                print "Internal box error"
-                for i in excinfo.traceback:
-                    print str(i)[2:-1]
-                print excinfo
-                os._exit(1)
-            os.close(1)
-            os.close(2)
-            os._exit(0)
-        return pid
-    
-    def children(self):
-        # right now we need to call a function, but first we need to
-        # map all IO that might happen
-        # make sure sys.stdout points to file descriptor one
-        fdstdout = os.open(self.PYTESTSTDOUT, os.O_WRONLY)
-        if fdstdout != 1:
-            os.dup2(fdstdout, 1)
-        fdstderr = os.open(self.PYTESTSTDERR, os.O_WRONLY)
-        if fdstderr != 2:
-            os.dup2(fdstderr, 2)
-        sys.stdout = os.fdopen(1, "w", 0)
-        sys.stderr = os.fdopen(2, "w", 0)
-        retvalf = open(self.PYTESTRETVAL, "w")
-        if NICE_LEVEL:
-            os.nice(NICE_LEVEL)
-        retval = self.fun(*self.args, **self.kwargs)
-        retvalf.write(marshal.dumps(retval))
-        retvalf.close()
-    
-    def parent(self):
-        stdoutlock = thread.allocate_lock()
-        stdoutlock.acquire()
-        stderrlock = thread.allocate_lock()
-        stderrlock.acquire()
-
-        def readsome(name, field, lock):
-            fd = open(name, "r")
-            setattr(self, field, fd.read())
-            fd.close()
-            lock.release()
-        
-        thread.start_new_thread(readsome, (self.PYTESTSTDOUT, 'stdoutrepr', stdoutlock))
-        thread.start_new_thread(readsome, (self.PYTESTSTDERR, 'stderrrepr', stderrlock))
-        
-        retval = open(self.PYTESTRETVAL, "r")
-        pid, exitstat = os.wait()
-        self.signal = exitstat & 0x7f
-        self.exitstat = exitstat & 0xff00
-
-        if not exitstat:
-            retval_data = retval.read()
-            self.retval = marshal.loads(retval_data)
-            retval.close()
-        else:
-            self.retval = None
-        
-        stdoutlock.acquire()
-        stdoutlock.release()
-        stderrlock.acquire()
-        stderrlock.release()
-        
-        self.clear()
-        return self.stdoutrepr, self.stderrrepr
-    
-    def clear(self):
-        try:
-            os.unlink(self.PYTESTSTDOUT)
-            os.unlink(self.PYTESTSTDERR)
-            os.unlink(self.PYTESTRETVAL)
-            os.rmdir(self.dirname)
-        except OSError:
-            pass
 
 class FileBox(object):
     count = 0

Modified: py/dist/py/test/rsession/rsession.py
==============================================================================
--- py/dist/py/test/rsession/rsession.py	(original)
+++ py/dist/py/test/rsession/rsession.py	Sun Nov  5 12:31:05 2006
@@ -4,8 +4,6 @@
 
 import os
 import py
-import thread
-import threading
 import sys
 import re
 import time

Modified: py/dist/py/test/rsession/slave.py
==============================================================================
--- py/dist/py/test/rsession/slave.py	(original)
+++ py/dist/py/test/rsession/slave.py	Sun Nov  5 12:31:05 2006
@@ -56,14 +56,6 @@
         else:
             send(res)
 
-def setup_screen():
-    # We cannot easily just assume that we do have full communication
-    # channels, so we have to provide a new ones.
-    import thread
-    import os, sys
-    # the idea is simple: we create another process in which we perform
-    # read/write operations on both channels
-    
 
 def setup():
     default_options = {'nomagic':False} # XXX should come from somewhere else


More information about the py-svn mailing list