From 661f0b848fb93a93e23c33246a9259ed42059284 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 16 Mar 2009 22:39:00 -0230 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3842 - ctypes not in python 2.5 in x64 windows. Also added code to print environment variables of interest. --- scripts/Expect.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'scripts/Expect.py') diff --git a/scripts/Expect.py b/scripts/Expect.py index 2ce0cd55b51..1b488d5d486 100755 --- a/scripts/Expect.py +++ b/scripts/Expect.py @@ -23,8 +23,13 @@ __all__ = ["Expect", "EOF", "TIMEOUT" ] win32 = (sys.platform == "win32") if win32: - # We use this to remove the reliance on win32api. - import ctypes + # We use this to remove the reliance on win32api. Unfortunately, + # python 2.5 under 64 bit versions of windows doesn't have ctypes, + # hence we have to be prepared for that module not to be present. + try: + import ctypes + except ImportError: + pass class EOF: """Raised when EOF is read from a child. @@ -445,8 +450,11 @@ class Expect (object): # # Using the ctypes module removes the reliance on the # python win32api - #win32console.GenerateConsoleCtrlEvent(win32console.CTRL_BREAK_EVENT, self.p.pid) - ctypes.windll.kernel32.GenerateConsoleCtrlEvent(1, self.p.pid) # 1 is CTRL_BREAK_EVENT + try: + #win32console.GenerateConsoleCtrlEvent(win32console.CTRL_BREAK_EVENT, self.p.pid) + ctypes.windll.kernel32.GenerateConsoleCtrlEvent(1, self.p.pid) # 1 is CTRL_BREAK_EVENT + except NameError: + pass else: os.kill(self.p.pid, signal.SIGINT) except: @@ -487,8 +495,11 @@ class Expect (object): # # Using the ctypes module removes the reliance on the # python win32api - ctypes.windll.kernel32.GenerateConsoleCtrlEvent(1, self.p.pid) # 1 is CTRL_BREAK_EVENT - #win32console.GenerateConsoleCtrlEvent(win32console.CTRL_BREAK_EVENT, self.p.pid) + try: + #win32console.GenerateConsoleCtrlEvent(win32console.CTRL_BREAK_EVENT, self.p.pid) + ctypes.windll.kernel32.GenerateConsoleCtrlEvent(1, self.p.pid) # 1 is CTRL_BREAK_EVENT + except NameError: + pass except: traceback.print_exc(file=sys.stdout) else: -- cgit v1.2.3