[Erp5-report] r45210 gabriel - /erp5/trunk/utils/cloudooo/cloudooo/handler/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Apr 8 01:23:25 CEST 2011


Author: gabriel
Date: Fri Apr  8 01:23:25 2011
New Revision: 45210

URL: http://svn.erp5.org?rev=45210&view=rev
Log:
add function to stop a paster process that is listening on port. The goal of this function is clean the processes who are breaking the buildbot

Modified:
    erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py?rev=45210&r1=45209&r2=45210&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py [utf8] Fri Apr  8 01:23:25 2011
@@ -8,12 +8,13 @@ from subprocess import Popen
 from ConfigParser import ConfigParser
 from argparse import ArgumentParser
 from os import chdir, path, environ, curdir, remove
-from psutil import Process
+import psutil
+from cloudooo.handler.ooo.utils.utils import socketStatus
 from signal import SIGQUIT
 
 
 def wait_use_port(pid, timeout_limit=30):
-  process = Process(pid)
+  process = psutil.Process(pid)
   for n in range(timeout_limit):
     if len(process.get_connections()) > 0:
       return True
@@ -21,6 +22,22 @@ def wait_use_port(pid, timeout_limit=30)
   return False
 
 
+def stopDaemonProcess(port):
+  """
+    Temporary Function to stop the paster daemon. The goals is to stop the
+    server that is running forever using the port.
+  """
+  for process in psutil.process_iter():
+    if process.name == "paster" and "paster serve" in " ".join(process.cmdline):
+      try:
+        connection_list = process.get_connections()
+        for connection in connection_list:
+          if connection.status == "LISTEN" and connection.local_address[1] == port:
+            process.send_signal(SIGQUIT)
+      except psutil.error.AccessDenied, e:
+        pass
+
+
 def exit(msg):
   sys.stderr.write(msg)
   sys.exit(0)
@@ -77,6 +94,10 @@ def run(handler_name):
   if DAEMON:
     log_file = '%s/cloudooo_test.log' % config.get('app:main',
                                                    'working_path')
+    hostname = config.get("server:main", "host")
+    port = int(config.get("server:main", "port"))
+    if socketStatus(hostname, port):
+      stopDaemonProcess(port)
     if path.exists(log_file):
       remove(log_file)
     command = [paster_path, 'serve', '--log-file', log_file,



More information about the Erp5-report mailing list