Python win32pipe.popen() Examples
The following are 30
code examples of win32pipe.popen().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32pipe
, or try the search function
.
Example #1
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2') or \ (sys.platform.startswith('java') and os._name == 'nt'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #2
Source File: platform.py From pmatic with GNU General Public License v2.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #3
Source File: platform.py From PokemonGo-DesktopMap with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #4
Source File: platform.py From oss-ftp with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #5
Source File: platform.py From unity-python with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #6
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #7
Source File: platform.py From Computable with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #8
Source File: platform.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #9
Source File: platform.py From canape with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #10
Source File: platform.py From BinderFilter with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #11
Source File: platform.py From medicare-demo with Apache License 2.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> /dev/null' % option) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #12
Source File: platform.py From ironpython2 with Apache License 2.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #13
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2') or \ (sys.platform.startswith('java') and os._name == 'nt'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #14
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2') or \ (sys.platform.startswith('java') and os._name == 'nt'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #15
Source File: platform.py From meddle with MIT License | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #16
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def _syscmd_uname(option,default=''): """ Interface to the system's uname command. """ if sys.platform in ('dos','win32','win16','os2') or \ (sys.platform.startswith('java') and os._name == 'nt'): # XXX Others too ? return default try: f = os.popen('uname %s 2> %s' % (option, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output
Example #17
Source File: platform.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode
Example #18
Source File: platform.py From canape with GNU General Public License v3.0 | 5 votes |
def _syscmd_file(target,default=''): """ Interface to the system's file command. The function uses the -b option of the file command to have it ommit the filename in its output and if possible the -L option to have the command follow symlinks. It returns default in case the command should fail. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default target = _follow_symlinks(target).replace('"', '\\"') try: f = os.popen('file "%s" 2> %s' % (target, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output ### Information about the used architecture # Default values for architecture; non-empty strings override the # defaults given as parameters
Example #19
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def _syscmd_ver(system='', release='', version='', supported_platforms=('win32','win16','dos','os2')): """ Tries to figure out the OS version used and returns a tuple (system,release,version). It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system,release,version # Try some common cmd strings for cmd in ('ver','command /c ver','cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise os.error,'command failed' # XXX How can I suppress shell errors from being written # to stderr ? except os.error,why: #print 'Command %s failed: %s' % (cmd,why) continue except IOError,why: #print 'Command %s failed: %s' % (cmd,why) continue
Example #20
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def popen(cmd, mode='r', bufsize=None): """ Portable popen() interface. """ # Find a working popen implementation preferring win32pipe.popen # over os.popen over _popen popen = None if os.environ.get('OS','') == 'Windows_NT': # On NT win32pipe should work; on Win9x it hangs due to bugs # in the MS C lib (see MS KnowledgeBase article Q150956) try: import win32pipe except ImportError: pass else: popen = win32pipe.popen if popen is None: if hasattr(os,'popen'): popen = os.popen # Check whether it works... it doesn't in GUI programs # on Windows platforms if sys.platform == 'win32': # XXX Others too ? try: popen('') except os.error: popen = _popen else: popen = _popen if bufsize is None: return popen(cmd,mode) else: return popen(cmd,mode,bufsize)
Example #21
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode
Example #22
Source File: platform.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode
Example #23
Source File: platform.py From unity-python with MIT License | 5 votes |
def _syscmd_ver(system='', release='', version='', supported_platforms=('win32','win16','dos','os2')): """ Tries to figure out the OS version used and returns a tuple (system,release,version). It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system,release,version # Try some common cmd strings for cmd in ('ver','command /c ver','cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise os.error,'command failed' # XXX How can I suppress shell errors from being written # to stderr ? except os.error,why: #print 'Command %s failed: %s' % (cmd,why) continue except IOError,why: #print 'Command %s failed: %s' % (cmd,why) continue
Example #24
Source File: platform.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def popen(cmd, mode='r', bufsize=None): """ Portable popen() interface. """ # Find a working popen implementation preferring win32pipe.popen # over os.popen over _popen popen = None if os.environ.get('OS','') == 'Windows_NT': # On NT win32pipe should work; on Win9x it hangs due to bugs # in the MS C lib (see MS KnowledgeBase article Q150956) try: import win32pipe except ImportError: pass else: popen = win32pipe.popen if popen is None: if hasattr(os,'popen'): popen = os.popen # Check whether it works... it doesn't in GUI programs # on Windows platforms if sys.platform == 'win32': # XXX Others too ? try: popen('') except os.error: popen = _popen else: popen = _popen if bufsize is None: return popen(cmd,mode) else: return popen(cmd,mode,bufsize)
Example #25
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode
Example #26
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def _syscmd_file(target,default=''): """ Interface to the system's file command. The function uses the -b option of the file command to have it ommit the filename in its output and if possible the -L option to have the command follow symlinks. It returns default in case the command should fail. """ if sys.platform in ('dos','win32','win16','os2'): # XXX Others too ? return default target = _follow_symlinks(target).replace('"', '\\"') try: f = os.popen('file "%s" 2> %s' % (target, DEV_NULL)) except (AttributeError,os.error): return default output = string.strip(f.read()) rc = f.close() if not output or rc: return default else: return output ### Information about the used architecture # Default values for architecture; non-empty strings override the # defaults given as parameters
Example #27
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': raise ValueError,'popen()-emulation only supports read mode' import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) self.pipe = open(tmpfile,'rb') self.bufsize = bufsize self.mode = mode
Example #28
Source File: platform.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def _syscmd_ver(system='', release='', version='', supported_platforms=('win32','win16','dos','os2')): """ Tries to figure out the OS version used and returns a tuple (system,release,version). It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system,release,version # Try some common cmd strings for cmd in ('ver','command /c ver','cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise os.error,'command failed' # XXX How can I suppress shell errors from being written # to stderr ? except os.error,why: #print 'Command %s failed: %s' % (cmd,why) continue except IOError,why: #print 'Command %s failed: %s' % (cmd,why) continue
Example #29
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def _syscmd_ver(system='', release='', version='', supported_platforms=('win32','win16','dos','os2')): """ Tries to figure out the OS version used and returns a tuple (system,release,version). It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? In case this fails, the given parameters are used as defaults. """ if sys.platform not in supported_platforms: return system,release,version # Try some common cmd strings for cmd in ('ver','command /c ver','cmd /c ver'): try: pipe = popen(cmd) info = pipe.read() if pipe.close(): raise os.error,'command failed' # XXX How can I suppress shell errors from being written # to stderr ? except os.error,why: #print 'Command %s failed: %s' % (cmd,why) continue except IOError,why: #print 'Command %s failed: %s' % (cmd,why) continue
Example #30
Source File: platform.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def popen(cmd, mode='r', bufsize=None): """ Portable popen() interface. """ # Find a working popen implementation preferring win32pipe.popen # over os.popen over _popen popen = None if os.environ.get('OS','') == 'Windows_NT': # On NT win32pipe should work; on Win9x it hangs due to bugs # in the MS C lib (see MS KnowledgeBase article Q150956) try: import win32pipe except ImportError: pass else: popen = win32pipe.popen if popen is None: if hasattr(os,'popen'): popen = os.popen # Check whether it works... it doesn't in GUI programs # on Windows platforms if sys.platform == 'win32': # XXX Others too ? try: popen('') except os.error: popen = _popen else: popen = _popen if bufsize is None: return popen(cmd,mode) else: return popen(cmd,mode,bufsize)