Kaydet (Commit) 06c65790 authored tarafından Facundo Batista's avatar Facundo Batista

Fixed the way that the .pem files are looked for, and changed

how to kill the process in win32 to use the _handle attribute.
üst a0da5c7b
...@@ -8,7 +8,6 @@ import errno ...@@ -8,7 +8,6 @@ import errno
import threading import threading
import subprocess import subprocess
import time import time
import ctypes
import os import os
import urllib import urllib
...@@ -128,18 +127,14 @@ class OpenSSLServer(threading.Thread): ...@@ -128,18 +127,14 @@ class OpenSSLServer(threading.Thread):
threading.Thread.__init__(self) threading.Thread.__init__(self)
def _external(self): def _external(self):
if os.access("ssl_cert.pem", os.F_OK): # let's find the .pem files
cert_file = "ssl_cert.pem" curdir = os.path.dirname(__file__) or os.curdir
elif os.access("./Lib/test/ssl_cert.pem", os.F_OK): cert_file = os.path.join(curdir, "ssl_cert.pem")
cert_file = "./Lib/test/ssl_cert.pem" if not os.access(cert_file, os.F_OK):
else: raise ValueError("No cert file found! (tried %r)" % cert_file)
raise ValueError("No cert file found!") key_file = os.path.join(curdir, "ssl_key.pem")
if os.access("ssl_key.pem", os.F_OK): if not os.access(key_file, os.F_OK):
key_file = "ssl_key.pem" raise ValueError("No key file found! (tried %r)" % key_file)
elif os.access("./Lib/test/ssl_key.pem", os.F_OK):
key_file = "./Lib/test/ssl_key.pem"
else:
raise ValueError("No cert file found!")
try: try:
cmd = "openssl s_server -cert %s -key %s -quiet" % (cert_file, key_file) cmd = "openssl s_server -cert %s -key %s -quiet" % (cert_file, key_file)
...@@ -172,9 +167,7 @@ class OpenSSLServer(threading.Thread): ...@@ -172,9 +167,7 @@ class OpenSSLServer(threading.Thread):
if not self.s: if not self.s:
return return
if sys.platform == "win32": if sys.platform == "win32":
handle = ctypes.windll.kernel32.OpenProcess(1, False, self.s.pid) subprocess.TerminateProcess(int(self.s._handle), -1)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.CloseHandle(handle)
else: else:
os.kill(self.s.pid, 15) os.kill(self.s.pid, 15)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment