Python subprocess.mswindows() Examples
The following are 13 code examples for showing how to use subprocess.mswindows(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
subprocess
, or try the search function
.
Example 1
Project: cobra Author: WhaleShark-Team File: log.py License: MIT License | 6 votes |
def stdout_encode(data): try: data = data or "" # Reference: http://bugs.python.org/issue1602 if mswindows: output = data.encode(sys.stdout.encoding, "replace") if '?' in output and '?' not in data: warn = "cannot properly display Unicode characters " warn += "inside Windows OS command prompt " warn += "(http://bugs.python.org/issue1602). All " warn += "unhandled occurances will result in " warn += "replacement with '?' character. Please, find " warn += "proper character representation inside " warn += "corresponding output files. " single_time_warn_message(warn) ret = output else: ret = data.encode(sys.stdout.encoding) except Exception as e: ret = data.encode(UNICODE_ENCODING) if isinstance(data, unicode) else data return ret
Example 2
Project: NoobSec-Toolkit Author: krintoxi File: beep.py License: GNU General Public License v2.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 3
Project: NoobSec-Toolkit Author: krintoxi File: beep.py License: GNU General Public License v2.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 4
Project: NoobSec-Toolkit Author: krintoxi File: beep.py License: GNU General Public License v2.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 5
Project: NoobSec-Toolkit Author: krintoxi File: beep.py License: GNU General Public License v2.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 6
Project: tsusen Author: stamparm File: common.py License: MIT License | 5 votes |
def check_sudo(): retval = None if not subprocess.mswindows: if getattr(os, "geteuid"): retval = os.geteuid() == 0 else: import ctypes retval = ctypes.windll.shell32.IsUserAnAdmin() return retval
Example 7
Project: ipnoise Author: stamparm File: common.py License: MIT License | 5 votes |
def check_sudo(): retval = None if not subprocess.mswindows: if getattr(os, "geteuid"): retval = os.geteuid() == 0 else: import ctypes retval = ctypes.windll.shell32.IsUserAnAdmin() return retval
Example 8
Project: POC-EXP Author: ym2011 File: beep.py License: GNU General Public License v3.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 9
Project: EasY_HaCk Author: sabri-zaki File: wafdetectify.py License: Apache License 2.0 | 5 votes |
def colorize(message): if not subprocess.mswindows and sys.stdout.isatty(): message = re.sub(r"\[(.)\]", lambda match: "[%s%s\033[00;49m]" % (LEVEL_COLORS[match.group(1)], match.group(1)), message) message = message.replace("@sqlmap", "\033[00;96m@sqlmap\033[00;49m") message = message.replace(NAME, "\033[00;93m%s\033[00;49m" % NAME) return message
Example 10
Project: EasY_HaCk Author: sabri-zaki File: beep.py License: Apache License 2.0 | 5 votes |
def beep(): try: if subprocess.mswindows: _win_wav_play(BEEP_WAV_FILENAME) elif sys.platform == "darwin": _mac_beep() elif sys.platform == "linux2": _linux_wav_play(BEEP_WAV_FILENAME) else: _speaker_beep() except: _speaker_beep()
Example 11
Project: learning-python Author: Akagi201 File: xosVer.py License: MIT License | 4 votes |
def main(): print (r" ") print (r" \ \ / / ") print (r"__ _____ __\ \ / /__ _ __ ") print (r"\ \/ / _ \/ __\ \/ / _ \ '__|") print (r" > < (_) \__ \\ / __/ | ") print (r"/_/\_\___/|___/ \/ \___|_| ") print (r" ") IS_WIN = subprocess.mswindows _ = os.path.normpath(sys.argv[0]) usage = "%s%s <options>" % ("python" if not IS_WIN else "", \ "\"%s\"" % _ if " " in _ else _) print ("Version: {0}".format(__version__)) parser = OptionParser(usage=usage) try: parser.add_option("--hh", dest="help", action="store_true", help="Show help message and exit") parser.add_option("-i", dest="ip", help="Single IP scan mode (eg:192.168.1.11)") parser.add_option("-p", dest="ips", help="Batch IP scan mode (eg:192.168.1.10/20)") parser.add_option("-o", dest="output", help="Save results to a file", default = False) parser.add_option("--timeout", dest="timeout", type="int", help="Seconds to wait before timeout connection " "(default 2)", default = 2) args = [] for arg in sys.argv: args.append(arg) (args, _) = parser.parse_args(args) if not any((args.ip, args.ips)): errMsg = "use -h for help" parser.error(errMsg) for i in xrange(len(sys.argv)): try: if sys.argv[i] == '-i': reip = re.compile(r'(?<![\.\d])(?:\d{1,3}\.){3}\d{1,3}(?![\.\d])') for ip in reip.findall(args.ip):ip xosVer(ip, args.timeout, args.output) elif sys.argv[i] == '-p': reip = re.compile(r'(?<![\.\d])(?:\d{1,3}\.){3}\d{1,3}(?![\.\d])/\d{1,3}') for ip in reip.findall(args.ips):ip ip = ip.split('/') exIp = ip[0][:ip[0].rfind('.') + 1] sIp = int(ip[0][ip[0].rfind('.') + 1:], 10) eIp = int(ip[1], 10) + 1 for i in xrange(sIp, eIp): xosVer(exIp + str(i), args.timeout, args.output) except Exception, e: print ("\r\noption %s invalid value: %s" % (sys.argv[i], sys.argv[i + 1])) print ("\r\nuse -h for help") except (OptionError,TypeError), e: parser.error(e)
Example 12
Project: tsusen Author: stamparm File: settings.py License: MIT License | 4 votes |
def read_config(config_file): global config if not os.path.isfile(config_file): exit("[!] missing configuration file '%s'" % config_file) config.clear() try: array = None content = open(config_file, "rb").read() for line in content.split("\n"): line = re.sub(r"#.+", "", line) if not line.strip(): continue if line.count(' ') == 0: array = line.upper() config[array] = [] continue if array and line.startswith(' '): config[array].append(line.strip()) continue else: array = None try: name, value = line.strip().split(' ', 1) except ValueError: name = line.strip() value = "" finally: name = name.upper() value = value.strip("'\"") if name.startswith("USE_"): value = value.lower() in ("1", "true") elif value.isdigit(): value = int(value) else: for match in re.finditer(r"\$([A-Z0-9_]+)", value): if match.group(1) in globals(): value = value.replace(match.group(0), globals()[match.group(1)]) else: value = value.replace(match.group(0), os.environ.get(match.group(1), match.group(0))) if subprocess.mswindows and "://" not in value: value = value.replace("/", "\\") config[name] = value except (IOError, OSError): pass for option in ("MONITOR_INTERFACE",): if not option in config: exit("[!] missing mandatory option '%s' in configuration file '%s'" % (option, config_file))
Example 13
Project: ipnoise Author: stamparm File: settings.py License: MIT License | 4 votes |
def read_config(config_file): global config if not os.path.isfile(config_file): exit("[!] missing configuration file '%s'" % config_file) config.clear() try: array = None content = open(config_file, "rb").read() for line in content.split("\n"): line = re.sub(r"#.+", "", line) if not line.strip(): continue if line.count(' ') == 0: array = line.upper() config[array] = [] continue if array and line.startswith(' '): config[array].append(line.strip()) continue else: array = None try: name, value = line.strip().split(' ', 1) except ValueError: name = line.strip() value = "" finally: name = name.upper() value = value.strip("'\"") if name.startswith("USE_"): value = value.lower() in ("1", "true") elif value.isdigit(): value = int(value) else: for match in re.finditer(r"\$([A-Z0-9_]+)", value): if match.group(1) in globals(): value = value.replace(match.group(0), globals()[match.group(1)]) else: value = value.replace(match.group(0), os.environ.get(match.group(1), match.group(0))) if subprocess.mswindows and "://" not in value: value = value.replace("/", "\\") config[name] = value except (IOError, OSError): pass for option in ("MONITOR_INTERFACE",): if not option in config: exit("[!] missing mandatory option '%s' in configuration file '%s'" % (option, config_file))