[tuxdroid-svn] r5092 - software_suite_v3/smart-core/smart-server/trunk
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-08 20:28:12
|
Author: remi
Date: 2009-07-08 22:27:56 +0200 (Wed, 08 Jul 2009)
New Revision: 5092
Modified:
software_suite_v3/smart-core/smart-server/trunk/tuxhttpserver.py
Log:
* Kill old server children processes before to start the server. (Windows)
Modified: software_suite_v3/smart-core/smart-server/trunk/tuxhttpserver.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/tuxhttpserver.py 2009-07-08 14:54:39 UTC (rev 5091)
+++ software_suite_v3/smart-core/smart-server/trunk/tuxhttpserver.py 2009-07-08 20:27:56 UTC (rev 5092)
@@ -18,6 +18,38 @@
from TDSConfiguration import *
+def killOldChildrenWin32():
+ import win32api
+ from win32com.client import GetObject
+ WMI = GetObject('winmgmts:')
+ processes = WMI.InstancesOf('Win32_Process')
+ pidToKill = []
+ for process in processes:
+ name = process.Properties_('Name').Value
+ cmdLine = process.Properties_('CommandLine').Value
+ if name == "python.exe":
+ if cmdLine.find('executables') != -1:
+ pidToKill.append(process.Properties_('ProcessId').Value)
+ continue
+ if cmdLine != None:
+ if cmdLine.lower().find('workforplugins') != -1:
+ pidToKill.append(process.Properties_('ProcessId').Value)
+ continue
+ if (cmdLine.lower().find('smart-server') != -1) and \
+ (cmdLine.lower().find('util') != -1):
+ pidToKill.append(process.Properties_('ProcessId').Value)
+ continue
+ for pid in pidToKill:
+ try:
+ handle = win32api.OpenProcess(1, False, pid)
+ win32api.TerminateProcess(handle, -1)
+ win32api.CloseHandle(handle)
+ except:
+ pass
+
+def killOldChildrenUnix():
+ pass
+
def checkServerRun():
import httplib
h = httplib.HTTP("127.0.0.1:%d" % TDS_HTTP_PORT)
@@ -34,18 +66,22 @@
return False
def killServer():
+ if os.name == "nt":
+ killOldChildrenWin32()
+ else:
+ killOldChildrenUnix()
import httplib
h = httplib.HTTP("127.0.0.1:%d" % TDS_HTTP_PORT)
try:
h.connect()
+ h.putrequest("GET", "/server/stop?")
+ h.endheaders()
+ h.getreply()
+ h.putrequest("GET", "/server/stop?")
+ h.endheaders()
+ h.getreply()
except:
return
- h.putrequest("GET", "/server/stop?")
- h.endheaders()
- h.getreply()
- h.putrequest("GET", "/server/stop?")
- h.endheaders()
- h.getreply()
def killServerAndWait():
import time
@@ -55,6 +91,10 @@
time.sleep(1.0)
def runServer():
+ if os.name == "nt":
+ killOldChildrenWin32()
+ else:
+ killOldChildrenUnix()
import TuxDroidServer
from TuxDroidServer import initializeServer
from TuxDroidServer import httpServer
|