當前位置: 首頁>>代碼示例>>Python>>正文


Python subprocess.STARTUPINFO屬性代碼示例

本文整理匯總了Python中subprocess.STARTUPINFO屬性的典型用法代碼示例。如果您正苦於以下問題:Python subprocess.STARTUPINFO屬性的具體用法?Python subprocess.STARTUPINFO怎麽用?Python subprocess.STARTUPINFO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在subprocess的用法示例。


在下文中一共展示了subprocess.STARTUPINFO屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute_command

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def execute_command(command, working_dir=None):
    startupinfo = None
    # hide console window on windows
    if os.name == 'nt':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    output = None
    try:
        output = subprocess.check_output(
            command,
            cwd=working_dir,
            startupinfo=startupinfo
        )
    except (subprocess.CalledProcessError, AttributeError):
        # Git will return an error when the given directory
        # is not a repository, which means that we can ignore this error
        pass
    else:
        output = str(output, encoding="utf-8").strip()

    return output 
開發者ID:sascha-wolf,項目名稱:sublime-GitConflictResolver,代碼行數:24,代碼來源:util.py

示例2: subprocess_args

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def subprocess_args(include_stdout=True):
    if hasattr(subprocess, 'STARTUPINFO'):
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        env = os.environ
    else:
        si = None
        env = None

    if include_stdout:
        ret = {'stdout': subprocess.PIPE}
    else:
        ret = {}

    ret.update({'stdin': subprocess.PIPE,
                'stderr': subprocess.PIPE,
                'startupinfo': si,
                'env': env })
    return ret 
開發者ID:Cryptolens,項目名稱:cryptolens-python,代碼行數:21,代碼來源:internal.py

示例3: subprocess_args

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def subprocess_args(include_stdout=True):
    if hasattr(subprocess, 'STARTUPINFO'):
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        env = os.environ
    else:
        si = None
        env = None

    if include_stdout:
        ret = {'stdout:': subprocess.PIPE}
    else:
        ret = {}

    ret.update({'stdin': subprocess.PIPE,
                'stderr': subprocess.PIPE,
                'startupinfo': si,
                'env': env })
    return ret

#Function to get the Process ID 
開發者ID:mehulj94,項目名稱:Radium,代碼行數:23,代碼來源:Radiumkeylogger.py

示例4: get_process

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def get_process(cmd):
    """Get a command process."""

    if sys.platform.startswith('win'):
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        process = subprocess.Popen(
            cmd,
            startupinfo=startupinfo,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            stdin=subprocess.PIPE,
            shell=False
        )
    else:
        process = subprocess.Popen(
            cmd,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            stdin=subprocess.PIPE,
            shell=False
        )
    return process 
開發者ID:facelessuser,項目名稱:pyspelling,代碼行數:25,代碼來源:__init__.py

示例5: _popen_kwargs

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def _popen_kwargs(prevent_sigint=False):
    startupinfo = None
    preexec_fn = None
    creationflags = 0
    if sys.platform.startswith("win"):
        # Stops executable from flashing on Windows (see #22)
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    if prevent_sigint:
        # Prevent propagation of sigint (see #4)
        # https://stackoverflow.com/questions/5045771
        if sys.platform.startswith("win"):
            creationflags = 0x00000200
        else:
            preexec_fn = os.setpgrp  # the _pre_exec does not seem to work
    return {
        "startupinfo": startupinfo,
        "creationflags": creationflags,
        "preexec_fn": preexec_fn,
    } 
開發者ID:imageio,項目名稱:imageio-ffmpeg,代碼行數:22,代碼來源:_utils.py

示例6: command_version

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def command_version(command):
    """
    Uses subprocess to format a given string.
    """

    startupinfo = None

    if platform == "windows":
        # Prevent cmd.exe window from popping up
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= (
            subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
        )
        startupinfo.wShowWindow = subprocess.SW_HIDE

    std = subprocess.Popen(
        [command, "--version"],
        env=calculate_env(),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        startupinfo=startupinfo
    )
    out, err = std.communicate()
    return out.decode("utf-8").replace("\r", ""), err 
開發者ID:bcomnes,項目名稱:sublime-standard-format,代碼行數:27,代碼來源:standard-format.py

示例7: __init__

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def __init__(self, url, dest, progress_bar=False):
        self.url = url
        self.dest = dest
        self.hash_type = None
        self.hash_value = None
        self.process = None
        self.secret = ''.join(format(ord(x), 'x') for x in os.urandom(10))
        self.gid = 'DEADC0D9BEEFFACE'

        self.status = None
        self.failed = False
        self.failure = None

        self.ariaStatus = {}
        self.gid = None
        if platform.system()=='Darwin':
            self.aria_stdout = None
            self.startupinfo = None
        else:
            self.aria_stdout = None
            self.startupinfo = subprocess.STARTUPINFO()
            self.startupinfo.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
            self.startupinfo.wShowWindow = subprocess.SW_HIDE 
開發者ID:KanoComputing,項目名稱:kano-burners,代碼行數:25,代碼來源:aria2_downloader.py

示例8: _popen_kwargs

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def _popen_kwargs(prevent_sigint=False):
    startupinfo = None
    preexec_fn = None
    creationflags = 0
    if sys.platform.startswith("win"):
        # Stops executable from flashing on Windows (see imageio/imageio-ffmpeg#22)
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    if prevent_sigint:
        # Prevent propagation of sigint (see imageio/imageio-ffmpeg#4)
        # https://stackoverflow.com/questions/5045771
        if sys.platform.startswith("win"):
            creationflags = 0x00000200
        else:
            preexec_fn = os.setpgrp  # the _pre_exec does not seem to work
    return {
        "startupinfo": startupinfo,
        "creationflags": creationflags,
        "preexec_fn": preexec_fn,
    } 
開發者ID:openatx,項目名稱:adbutils,代碼行數:22,代碼來源:_utils.py

示例9: run_cli

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def run_cli(script_name, **parameters):
    """Run the CLI in a subprocess without showing windows"""
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    command = [get_python_exe(), '-u', '-m', 'cea.interfaces.cli.cli', script_name]
    for parameter_name, parameter_value in parameters.items():
        parameter_name = parameter_name.replace('_', '-')
        command.append('--' + parameter_name)
        command.append(str(parameter_value))
    print('Executing: ' + ' '.join(command))
    process = subprocess.Popen(command, startupinfo=startupinfo, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                               cwd=tempfile.gettempdir())
    while True:
        next_line = process.stdout.readline()
        if next_line == '' and process.poll() is not None:
            break
        print(next_line.rstrip())
    stdout, stderr = process.communicate()
    print(stdout)
    print(stderr)
    if process.returncode != 0:
        raise Exception('Tool did not run successfully') 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:25,代碼來源:ghhelper.py

示例10: __init__

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def __init__(self, command: List[str], cwd: Optional[str]):
		# taken from Default/exec.py
		# Hide the console window on Windows
		startupinfo = None
		if os.name == "nt":
			startupinfo = subprocess.STARTUPINFO() #type: ignore
			startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW #type: ignore

		super().__init__(command,
			stdout=subprocess.PIPE,
			stderr=subprocess.PIPE,
			stdin=subprocess.PIPE,
			shell=False,
			bufsize=0,
			startupinfo=startupinfo,
			cwd = cwd)

		self.closed = False 
開發者ID:daveleroy,項目名稱:sublime_debugger,代碼行數:20,代碼來源:transports.py

示例11: _runEngineProcess

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def _runEngineProcess(self, command_list) -> Optional[subprocess.Popen]:
        """Start the (external) backend process."""

        kwargs = {} #type: Dict[str, Any]
        if sys.platform == "win32":
            su = subprocess.STARTUPINFO()
            su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            su.wShowWindow = subprocess.SW_HIDE
            kwargs["startupinfo"] = su
            kwargs["creationflags"] = 0x00004000  # BELOW_NORMAL_PRIORITY_CLASS
        try:
            # STDIN needs to be None because we provide no input, but communicate via a local socket instead. The NUL device sometimes doesn't exist on some computers.
            # STDOUT and STDERR need to be pipes because we'd like to log the output on those channels into the application log.
            return subprocess.Popen(command_list, stdin = None, stdout = subprocess.PIPE, stderr = subprocess.PIPE, **kwargs)
        except PermissionError:
            Logger.log("e", "Couldn't start back-end: No permission to execute process.")
        except FileNotFoundError:
            Logger.logException("e", "Unable to find backend executable: %s", command_list[0])
        except BlockingIOError:
            Logger.log("e", "Couldn't start back-end: Resource is temporarily unavailable")
        except OSError as e:
            Logger.log("e", "Couldn't start back-end: Operating system is blocking it (antivirus?): {err}".format(err = str(e)))
        return None 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:25,代碼來源:Backend.py

示例12: __init__

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def __init__(self, shell_cmd):
		if not shell_cmd:
			raise ValueError("shell_cmd is required")

		if shell_cmd and not isinstance(shell_cmd, str):
			raise ValueError("shell_cmd must be a string")

		self.killed = False

		# Hide the console window on Windows
		startupinfo = None
		if os.name == "nt":
			startupinfo = subprocess.STARTUPINFO()
			#startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

	   
		print (shell_cmd)
		if sys.platform == "win32":
			# Use shell=True on Windows, so shell_cmd is passed through with the correct escaping
			self.proc = subprocess.Popen(shell_cmd, startupinfo=startupinfo, shell=True)
		elif shell_cmd and sys.platform == "darwin":
			# Use a login shell on OSX, otherwise the users expected env vars won't be setup
			self.proc = subprocess.Popen(["/bin/bash", "-l", "-c", shell_cmd], startupinfo=startupinfo, shell=False)

		self.proc.wait() 
開發者ID:vamitul,項目名稱:RunInIndesign,代碼行數:27,代碼來源:runInIndesign.py

示例13: run

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def run(self):
        if self.type is "ffmpeg":
            self.cmds.insert(0, ffmpeg_path)
        else:
            self.cmds.insert(0, ffprobe_path)

        qgsu.showUserAndLogMessage("", "starting Splitter on thread:" + str(threading.current_thread().ident), onlyLog=True)
        qgsu.showUserAndLogMessage("", "with args:" + ' '.join(self.cmds), onlyLog=True)

        # Hide shell windows that pops up on windows.
        if windows:
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            startupinfo.wShowWindow = subprocess.SW_HIDE

        self.p = subprocess.Popen(self.cmds, startupinfo=startupinfo, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE)
        # Dont us _spawn here as it will DeadLock, and the splitter won't work
        #self.p = _spawn(self.cmds)
        self.nbsr = NonBlockingStreamReader(self.p)
        self.nbsr._t.join()
        qgsu.showUserAndLogMessage("", "Splitter thread ended.", onlyLog=True) 
開發者ID:All4Gis,項目名稱:QGISFMV,代碼行數:23,代碼來源:QgsFmvUtils.py

示例14: run

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def run(cmd):
    if sys.platform == 'win32':
      startupinfo = subprocess.STARTUPINFO()
      startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    else:
      startupinfo = None
    p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo)
    #logtext.insert(END, "Cmd>")
    #for s in cmd:
    #    logtext.insert(END, " " + s)
    #logtext.insert(END, "\r\n")
    stdout = ''
    while True:
        line = str(p.stdout.readline(), encoding='UTF-8')
        stdout += line
        #logtext.insert(END, line)
        #logtext.yview(END)
        curstat = p.poll()
        if ((line == '') and (curstat != None)):
            break
    return stdout 
開發者ID:bkerler,項目名稱:MR,代碼行數:23,代碼來源:fs_whatsapp.py

示例15: get_provider

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import STARTUPINFO [as 別名]
def get_provider(vmrun_exe):
    """
    identifies the right hosttype for vmrun command (ws | fusion | player)
    """

    if sys.platform == 'darwin':
        return 'fusion'

    for provider in ['ws', 'player', 'fusion']:
        try:
            startupinfo = None
            if os.name == "nt":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
            proc = subprocess.Popen([vmrun_exe, '-T', provider, 'list'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
        except OSError:
            pass

        stdoutdata, stderrdata = map(b2s, proc.communicate())
        if proc.returncode == 0:
            return provider 
開發者ID:mechboxes,項目名稱:mech,代碼行數:23,代碼來源:vmrun.py


注:本文中的subprocess.STARTUPINFO屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。