From 5157e45805f713ef81573021bd59c01738ddfa5f Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Sat, 13 Mar 2010 11:20:27 -0800 Subject: [PATCH] Bug 543825 remove __import__ from automation.py r=ted --- build/automation.py.in | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index 6847f4109cea..319ffff80266 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -74,6 +74,13 @@ _IS_CYGWIN = False #expand _IS_DEBUG_BUILD = __IS_DEBUG_BUILD__ #expand _CRASHREPORTER = __CRASHREPORTER__ == 1 + +if _IS_WIN32: + import ctypes, ctypes.wintypes, time, msvcrt +else: + import errno + + ################# # PROFILE SETUP # ################# @@ -466,7 +473,7 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t if env == None: env = dict(os.environ) - ldLibraryPath = os.path.abspath(os.path.join(self.SCRIPT_DIR, xrePath)) + ldLibraryPath = os.path.abspath(os.path.join(SCRIPT_DIR, xrePath)) if self.UNIXISH or self.IS_MAC: envVar = "LD_LIBRARY_PATH" if self.IS_MAC: @@ -490,10 +497,6 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t return env if IS_WIN32: - ctypes = __import__('ctypes') - wintypes = __import__('ctypes.wintypes') - time = __import__('time') - msvcrt = __import__('msvcrt') PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe GetLastError = ctypes.windll.kernel32.GetLastError @@ -507,11 +510,11 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t if timeout is None: # shortcut to allow callers to pass in "None" for no timeout. return (f.readline(), False) - x = self.msvcrt.get_osfhandle(f.fileno()) - l = self.ctypes.c_long() - done = self.time.time() + timeout - while self.time.time() < done: - if self.PeekNamedPipe(x, None, 0, None, self.ctypes.byref(l), None) == 0: + x = msvcrt.get_osfhandle(f.fileno()) + l = ctypes.c_long() + done = time.time() + timeout + while time.time() < done: + if self.PeekNamedPipe(x, None, 0, None, ctypes.byref(l), None) == 0: err = self.GetLastError() if err == 38 or err == 109: # ERROR_HANDLE_EOF || ERROR_BROKEN_PIPE return ('', False) @@ -521,18 +524,18 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t # we're assuming that the output is line-buffered, # which is not unreasonable return (f.readline(), False) - self.time.sleep(0.01) + time.sleep(0.01) return ('', True) def isPidAlive(self, pid): STILL_ACTIVE = 259 PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 - pHandle = self.ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) + pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) if not pHandle: return False pExitCode = ctypes.wintypes.DWORD() - self.ctypes.windll.kernel32.GetExitCodeProcess(pHandle, self.ctypes.byref(pExitCode)) - self.ctypes.windll.kernel32.CloseHandle(pHandle) + ctypes.windll.kernel32.GetExitCodeProcess(pHandle, self.ctypes.byref(pExitCode)) + ctypes.windll.kernel32.CloseHandle(pHandle) if (pExitCode.value == STILL_ACTIVE): return True else: @@ -540,14 +543,13 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t def killPid(self, pid): PROCESS_TERMINATE = 0x0001 - pHandle = self.ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid) + pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid) if not pHandle: return - success = self.ctypes.windll.kernel32.TerminateProcess(pHandle, 1) - self.ctypes.windll.kernel32.CloseHandle(pHandle) + success = ctypes.windll.kernel32.TerminateProcess(pHandle, 1) + ctypes.windll.kernel32.CloseHandle(pHandle) else: - errno = __import__('errno') def readWithTimeout(self, f, timeout): """Try to read a line of output from the file object |f|. If no output @@ -575,7 +577,7 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t except OSError, err: # Catch the errors we might expect from os.kill/os.waitpid, # and re-raise any others - if err.errno == self.errno.ESRCH or err.errno == self.errno.ECHILD: + if err.errno == errno.ESRCH or err.errno == errno.ECHILD: return False raise @@ -761,7 +763,7 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t # Do a final check for zombie child processes. self.checkForZombies(processLog) - self.automationutils.checkForCrashes(os.path.join(profileDir, "minidumps"), symbolsPath) + automationutils.checkForCrashes(os.path.join(profileDir, "minidumps"), symbolsPath) if os.path.exists(processLog): os.unlink(processLog)