def iterLocations(): # Allow the user to specify the location we should search first, # by setting an environment variable. tclpath = environ.get('TCL_CONFIG') if tclpath is not None: yield tclpath if distroRoot is None or cls.isSystemLibrary(platform): if msysActive(): roots = (msysPathToNative('/mingw32'), ) else: roots = ('/usr/local', '/usr') else: roots = (distroRoot, ) for root in roots: if isdir(root): for libdir in ('lib', 'lib64', 'lib/tcl'): libpath = root + '/' + libdir if isdir(libpath): yield libpath for entry in listdir(libpath): if entry.startswith('tcl8.'): tclpath = libpath + '/' + entry if isdir(tclpath): yield tclpath
def iterLocations(): if platform == 'android': # Under Android, the tcl set-up apparently differs from # other cross-platform setups. the search algorithm to find the # directory that will contain the tclConfig.sh script and the shared libs # is not applicable to Android. Instead, immediately return the correct # subdirectories to the routine that invokes iterLocations() sdl_android_port_path = environ['SDL_ANDROID_PORT_PATH'] libpath = sdl_android_port_path + '/project/libs/armeabi' yield libpath tclpath = sdl_android_port_path + '/project/jni/tcl8.5/unix' yield tclpath else: if distroRoot is None or cls.isSystemLibrary(platform): if msysActive(): roots = (msysPathToNative('/mingw32'), ) else: roots = ('/usr/local', '/usr') else: roots = (distroRoot, ) for root in roots: if isdir(root): for libdir in ('lib', 'lib64', 'lib/tcl'): libpath = root + '/' + libdir if isdir(libpath): yield libpath for entry in listdir(libpath): if entry.startswith('tcl8.'): tclpath = libpath + '/' + entry if isdir(tclpath): yield tclpath
def captureStdout(log, commandLine): '''Run a command and capture what it writes to stdout. If the command fails or writes something to stderr, that is logged. Returns the captured string, or None if the command failed. ''' # TODO: This is a modified copy-paste from compilers._Command. commandParts = shsplit(commandLine) env = dict(environ) while commandParts: if '=' in commandParts[0]: name, value = commandParts[0].split('=', 1) del commandParts[0] env[name] = value else: break else: raise ValueError('No command specified in "%s"' % commandLine) if msysActive() and commandParts[0] != 'sh': commandParts = [msysShell(), '-c', shjoin(commandParts)] try: proc = Popen( commandParts, bufsize=-1, env=env, stdin=None, stdout=PIPE, stderr=PIPE, ) except OSError, ex: print >> log, 'Failed to execute "%s": %s' % (commandLine, ex) return None
def captureStdout(log, commandLine): '''Run a command and capture what it writes to stdout. If the command fails or writes something to stderr, that is logged. Returns the captured string, or None if the command failed. ''' # TODO: This is a modified copy-paste from compilers._Command. commandParts = shsplit(commandLine) env = dict(environ) while commandParts: if '=' in commandParts[0]: name, value = commandParts[0].split('=', 1) del commandParts[0] env[name] = value else: break else: raise ValueError( 'No command specified in "%s"' % commandLine ) if msysActive() and commandParts[0] != 'sh': commandParts = [ msysShell(), '-c', shjoin(commandParts) ] try: proc = Popen( commandParts, bufsize = -1, env = env, stdin = None, stdout = PIPE, stderr = PIPE, ) except OSError, ex: print >> log, 'Failed to execute "%s": %s' % (commandLine, ex) return None
def captureStdout(log, commandLine): '''Run a command and capture what it writes to stdout. If the command fails or writes something to stderr, that is logged. Returns the captured string, or None if the command failed. ''' # TODO: This is a modified copy-paste from compilers._Command. commandParts = shsplit(commandLine) env = dict(environ) env['LC_ALL'] = 'C.UTF-8' while commandParts: if '=' in commandParts[0]: name, value = commandParts[0].split('=', 1) del commandParts[0] env[name] = value else: break else: raise ValueError('No command specified in "%s"' % commandLine) if msysActive() and commandParts[0] != 'sh': commandParts = [msysShell(), '-c', shjoin(commandParts)] try: proc = Popen( commandParts, bufsize=-1, env=env, stdin=None, stdout=PIPE, stderr=PIPE, ) except OSError as ex: print('Failed to execute "%s": %s' % (commandLine, ex), file=log) return None stdoutdata, stderrdata = proc.communicate() if stderrdata: severity = 'warning' if proc.returncode == 0 else 'error' log.write('%s executing "%s"\n' % (severity.capitalize(), commandLine)) # pylint 0.18.0 somehow thinks stderrdata is a list, not a string. # pylint: disable-msg=E1103 stderrdata = stderrdata.decode('utf-8').replace('\r', '') log.write(stderrdata) if not stderrdata.endswith('\n'): log.write('\n') if proc.returncode == 0: return stdoutdata.decode('utf-8') else: print('Execution failed with exit code %d' % proc.returncode, file=log) return None
from msysutils import msysActive, msysPathToNative from os import environ from shlex import split as shsplit from subprocess import PIPE, STDOUT, Popen if msysActive(): def fixArgs(args): for arg in args: if arg.startswith("-I") or arg.startswith("-L"): yield arg[:2] + msysPathToNative(arg[2:]) elif arg.startswith("/"): yield msysPathToNative(arg) else: yield arg else: def fixArgs(args): return iter(args) class _Command(object): @classmethod def fromLine(cls, commandStr, flagsStr): commandParts = shsplit(commandStr) flags = shsplit(flagsStr) env = {} while commandParts:
# $Id: compilers.py 9943 2009-05-31 18:09:09Z mthuurne $ from msysutils import msysActive, msysPathToNative from os import environ from shlex import split as shsplit from subprocess import PIPE, STDOUT, Popen if msysActive(): def fixArgs(args): for arg in args: if arg.startswith('-I') or arg.startswith('-L'): yield arg[:2] + msysPathToNative(arg[2:]) elif arg.startswith('/'): yield msysPathToNative(arg) else: yield arg else: def fixArgs(args): return iter(args) class _Command(object): @classmethod def fromLine(cls, commandStr, flagsStr): commandParts = shsplit(commandStr) flags = shsplit(flagsStr) env = {} while commandParts: