def main(argv): try: from signal import signal, SIGHUP, SIGINT, SIG_IGN signal(SIGHUP, SIG_IGN) signal(SIGINT, SIG_IGN) except ImportError: # presumably we're on Windows: nothing to do pass try: # this should work on posix systems and Windows with Python >= 2.6 subprocess.Popen(argv, close_fds=True) except ValueError: try: # Python versions before 2.6 don't allow close_fds=True on Windows import pywintypes import win32process try: from nws.util import msc_argv2str, which except ImportError: # nws-python isn't installed, but we just need nwsutil.py from nwsutil import msc_argv2str, which if not os.path.isabs(argv[0]): argv[0] = which(argv[0])[0] commandLine = msc_argv2str(argv) processSecurityAttributes = None threadSecurityAttributes = None fInheritHandles = 0 creationFlags = win32process.CREATE_NO_WINDOW environment = None currentDirectory = None startupInfo = win32process.STARTUPINFO() procHandle, threadHandle, procId, threadId = win32process.CreateProcess( argv[0], commandLine, processSecurityAttributes, threadSecurityAttributes, fInheritHandles, creationFlags, environment, currentDirectory, startupInfo, ) except ImportError: # presumably we're on Windows using Python < 2.6 # we'll inherit handles, but this is better than nothing subprocess.Popen(argv)
def _getRProg(): # try to find it using PATH first m = which(_RNAME) if m: return m[0] # try to find it using the latest version of R installed on this machine rdirs = glob.glob(_RVERSIONPATTERN) rdirs.sort() rdirs.reverse() # latest version of R first rprogs = [os.path.join(d, 'bin', _RNAME) for d in rdirs] for rprog in rprogs: if os.path.exists(rprog): return rprog else: return None
def _getPythonProg(): m = which(_PYTHONNAME) if m: return m[0] return _DEFAULTINTERP