当前位置: 首页>>代码示例>>Python>>正文


Python subprocess.CREATE_NEW_CONSOLE属性代码示例

本文整理汇总了Python中subprocess.CREATE_NEW_CONSOLE属性的典型用法代码示例。如果您正苦于以下问题:Python subprocess.CREATE_NEW_CONSOLE属性的具体用法?Python subprocess.CREATE_NEW_CONSOLE怎么用?Python subprocess.CREATE_NEW_CONSOLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在subprocess的用法示例。


在下文中一共展示了subprocess.CREATE_NEW_CONSOLE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [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

示例2: apply_cli_session

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def apply_cli_session(cls, creds, region):
        ''' Applies the given credentials (i.e. AccessKey, SecretAccessKey and SessionToken) to a new shell to use with aws cli.
            The credentials are used as environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_DEFAULT_REGION
            that aws cli uses.
            The region is the desired region to connect to (e.g. us-east-1).
            :param : boto3 returned credentials dict
            :param region: aws region to connect to
        '''
        # Set up environment for opening shell with credentials
        os.environ["AWS_ACCESS_KEY_ID"] = creds["AccessKeyId"]
        os.environ["AWS_SECRET_ACCESS_KEY"] = creds["SecretAccessKey"]
        os.environ["AWS_SESSION_TOKEN"] = creds["SessionToken"]
        os.environ["AWS_DEFAULT_REGION"] = region

        # Open up a new shell
        if os.name == 'nt':
            subprocess.Popen(r"cmd", creationflags=subprocess.CREATE_NEW_CONSOLE)
        else:
            os.system(os.environ['SHELL']) 
开发者ID:cyberark,项目名称:shimit,代码行数:21,代码来源:aws.py

示例3: runScript

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def runScript(cls, script, version=None, architecture=64, language=ScriptLanguage.Python, debug=False, headless=True):

		# If the script argument is a path to a file.
		if os.path.exists(script):
			with open(script, 'r') as fle:
				script = fle.read()

		scriptPath = os.path.splitext(cls.scriptPath())[0] + '.py'
		with open(scriptPath, 'w') as fle:
			fle.write(script)
	
		binary = os.path.join(cls.binariesPath(version, architecture), 'mayabatch.exe' if headless else 'maya.exe')
		args = [binary, '-console', '-verbosePython', scriptPath]
		subprocess.Popen(args, creationflags=subprocess.CREATE_NEW_CONSOLE, env=os.environ)

		# TODO: Need to figure out a way to return False if the script has failed.
		return True 
开发者ID:blurstudio,项目名称:cross3d,代码行数:19,代码来源:external.py

示例4: runScript

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def runScript(cls, script, version=None, architecture=64, language=ScriptLanguage.Python, debug=False, headless=True):

		if os.path.exists(script):
			scriptPath = script

		else:
			scriptPath = cls.scriptPath()
			with open(scriptPath, "w") as fle:
				fle.write(script)

		if language == ScriptLanguage.Python:
			scriptTemplate = os.path.join(os.path.dirname(__file__), 'templates', 'external_python_script.mstempl')

			with open(scriptTemplate) as fle:
				script = fle.read().format(scriptPath =scriptPath, debug=debug)
			
			scriptPath = os.path.splitext(cls.scriptPath())[0] + '.ms'

			with open(scriptPath, "w") as fle:
				fle.write(script)

		binary = os.path.join(cls.binariesPath(version, architecture), '3dsmax.exe')
		process = subprocess.Popen([binary, '-U', 'MAXScript', scriptPath], creationflags=subprocess.CREATE_NEW_CONSOLE, env=os.environ)

		# TODO: Need to figure out a way to return False if the script has failed.
		return True 
开发者ID:blurstudio,项目名称:cross3d,代码行数:28,代码来源:external.py

示例5: write_windows_console

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def write_windows_console(self, *args):
        retcode = subprocess.call(args,
            # use a new console to not flood the test output
            creationflags=subprocess.CREATE_NEW_CONSOLE,
            # use a shell to hide the console window (SW_HIDE)
            shell=True)
        self.assertEqual(retcode, 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_os.py

示例6: __enter__

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def __enter__(self):
        """Entering the `with` block. Runs the process."""
        if not self._kernel32.CreateProcessA(
            None,  # lpApplicationName
            self.command_str,  # lpCommandLine
            None,  # lpProcessAttributes
            None,  # lpThreadAttributes
            False,  # bInheritHandles
            subprocess.CREATE_NEW_CONSOLE,  # dwCreationFlags
            None,  # lpEnvironment
            str(PROJECT_ROOT).encode('ascii'),  # lpCurrentDirectory
            ctypes.byref(self.startup_info),  # lpStartupInfo
            ctypes.byref(self.process_info)  # lpProcessInformation
        ):
            raise ctypes.WinError()

        # Add handles added by the OS.
        self._handles.append(self.process_info.hProcess)
        self._handles.append(self.process_info.hThread)

        # Get hWnd.
        self.hwnd = 0
        for _ in range(int(5 / 0.1)):
            # Takes time for console window to initialize.
            self.hwnd = ctypes.windll.user32.FindWindowA(None, self.startup_info.lpTitle)
            if self.hwnd:
                break
            time.sleep(0.1)
        assert self.hwnd

        # Return generator that yields window size/position.
        return self._iter_pos() 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:34,代码来源:screenshot.py

示例7: spawn_local

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def spawn_local(self, idx):
        """
        This method launches processes that are needed to run on this computer
        :param idx: An index into launch_db
        """

        # get the launch entry in launch_db
        db_entry = self.launch_db[idx]

        # skip over the entry for the backplane
        # launch the process either in its own window or just launch it.
        # differentiate between windows and other os's.
        if not db_entry['command_string'] == 'backplane':
            if sys.platform.startswith('win32'):
                if db_entry['spawn'] == 'yes':
                    self.proc = Popen(db_entry['command_string'],
                                      creationflags=subprocess.CREATE_NEW_CONSOLE)
                else:
                    command_list = db_entry['command_string']
                    self.proc = Popen(command_list, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
            else:
                if db_entry['spawn'] == 'yes':
                    self.proc = Popen(['xterm', '-e', db_entry['command_string']],
                                      stdin=subprocess.PIPE, stderr=subprocess.PIPE,
                                      stdout=subprocess.PIPE)
                else:
                    command_list = db_entry['command_string'].split(' ')
                    self.proc = Popen(command_list)

            # update the entry with the launch information
            db_entry['process'] = self.proc
            db_entry['process_id'] = self.proc.pid
            print('{:35} PID = {}'.format(db_entry['command_string'], str(self.proc.pid)))

            # allow a little time for the process to startup
            try:
                time.sleep(0.5)
            except (KeyboardInterrupt, SystemExit):
                self.clean_up() 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:41,代码来源:bls.py

示例8: start_server

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def start_server(self):
        if self.android is None:
            if self.enabled and self.lang.voice is not None:
                cmd = ['espeak']
                cmd.extend(self.lang.voice)
                try:
                    # IS_WIN32 = 'win32' in str(sys.platform).lower() #maybe sys.platform is more secure
                    is_win = platform.system() == "Windows"
                    if is_win:
                        startupinfo = subprocess.STARTUPINFO()
                        startupinfo.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
                        startupinfo.wShowWindow = subprocess.SW_HIDE
                        kwargs = {}
                        kwargs['startupinfo'] = startupinfo
                        self.process = subprocess.Popen(cmd, shell=False, bufsize=0, stdin=subprocess.PIPE,
                                                        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                                                        startupinfo=startupinfo)
                    else:
                        if self.debug:
                            self.process = subprocess.Popen(cmd, shell=False, bufsize=0, stdin=subprocess.PIPE)
                        else:
                            self.process = subprocess.Popen(cmd, shell=False, bufsize=0, stdin=subprocess.PIPE,
                                                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                    self.started = True
                except:
                    self.enabled = False
                    self.started = False
                    print("eduActiv8: You may like to install eSpeak to get some extra functionality, " +
                          "however this is not required to successfully use the game.")
            else:
                self.process = None 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:33,代码来源:speaker.py

示例9: run

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def run(self):
        '''
        Spawn the process that will run the vivado process.
        '''
        cwd = os.getcwd()
        os.chdir(self.directory)
        stdout_fn = 'stdout.txt' 
        stderr_fn = 'stderr.txt' 
        command_fn = 'command.tcl' 
        if os.name == 'nt':
            commands = [config.vivado, '-log', stdout_fn, '-mode', 'batch',
                        '-source', command_fn]
            logger.debug('running vivado task in directory {}'.format(self.directory))
            logger.debug('command is {}'.format(' '.join(commands)))
            self.process = subprocess.Popen(
                commands,
                # So that process stays alive when terminal is closed
                # in Windows.
                # Commented out because doesn't seem to be working now.
                creationflags=subprocess.CREATE_NEW_CONSOLE,
            )
            logger.debug('started process')
        else:
            commands = [config.vivado, '-mode', 'batch', '-source',
                        command_fn]
            self.launch_unix_subprocess(
                commands, stdout_fn=stdout_fn, stderr_fn=stderr_fn)
        os.chdir(cwd) 
开发者ID:benreynwar,项目名称:pyvivado,代码行数:30,代码来源:vivado_task.py

示例10: update

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def update():
    '''
    Updates ExtAnalysis
    1. Create the updater child script and save it to temp directory
    2. End self process and start the child script
    '''
    print("\n[i] Creating Updater file")

    child_script = open(helper.fixpath(core.path + '/db/updater.py'), 'r')
    child_script = child_script.read()

    src = child_script.replace('<current_extanalysis_directory>', core.path.replace('\\', '\\\\'))
    src = src.replace('<github_zip_url>', core.github_zip)

    print('[i] Moving updater file to temp directory')
    temp_dir = tempfile.gettempdir()

    updater_script = helper.fixpath(temp_dir + '/update_extanalysis.py')
    f = open(updater_script, 'w+')
    f.write(src)
    f.close()

    python_loc = sys.executable

    print('[i] Starting Updater script')

    if sys.platform == 'win32':
        os.chdir(temp_dir)
        command = [python_loc, 'update_extanalysis.py']
        subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE, shell=False)
        print('[i] Killing self... Next time we meet I will be a better version of myself ;)')
        exit()
    else:
        os.chdir(temp_dir)
        command = ['x-terminal-emulator', '-e', python_loc, updater_script]
        subprocess.Popen(command, shell=False)
        print('[i] Killing self... Next time we meet I will be a better version of myself ;)')
        exit() 
开发者ID:Tuhinshubhra,项目名称:ExtAnalysis,代码行数:40,代码来源:updater.py

示例11: _fork_worker

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def _fork_worker(namespace_path, child_env, pid_file, invocation, chdir,
                 stdin_goto, stdout_goto, stderr_goto, _exit_caller, args):
    ''' Opens a fork worker, shielding the parent from cancellation via
    signal sending. Basically, thanks Windows for being a dick about
    signals.
    '''
    # Find out our PID so the daughter can tell us to exit
    my_pid = os.getpid()
    # Pack up all of the args that the child will need to use.
    # Prepend it to *args
    payload = (my_pid, pid_file, chdir, stdin_goto, stdout_goto,
               stderr_goto, _exit_caller) + args
    
    # Pack it up. We're shielded from pickling errors already because pickle is
    # needed to start the worker.
    # Write the payload to the namespace passer using the highest available
    # protocol
    with open(namespace_path, 'wb') as f:
        pickle.dump(payload, f, protocol=-1)
    
    # Invoke the invocation!
    daemon = subprocess.Popen(
        invocation,
        # This is important, because the parent _forkish is telling the child
        # to run as a daemon via env. Also note that we need to calculate this
        # in the root _daemonize1, or else we'll have a polluted environment
        # due to the '__CREATE_DAEMON__' key.
        env = child_env,
        # This is vital; without it, our process will be reaped at parent
        # exit.
        creationflags = subprocess.CREATE_NEW_CONSOLE,
    )
    # Busy wait until either the daemon exits, or it sends a signal to kill us.
    daemon.wait() 
开发者ID:Muterra,项目名称:py_daemoniker,代码行数:36,代码来源:_daemonize_windows.py

示例12: launch

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def launch(fn, prefix=config.root_dir, additional_args=None, background=False):
    info = install.is_linked(prefix, fn[:-8])
    if info is None:
        return None

    if not info.get('type') == 'app':
        raise TypeError('Not an application: %s' % fn)

    binpath, env = environment_for_conda_environment(prefix)
    # allow updating environment variables from metadata
    if 'app_env' in info:
        env.update(info['app_env'])

    # call the entry command
    args = info['app_entry'].split()
    args = [a.replace('${PREFIX}', prefix) for a in args]
    arg0 = find_executable(args[0], env['PATH'])
    if arg0 is None:
        raise Exception('Executable not found: %s' % args[0])
    args[0] = arg0

    cwd = abspath(expanduser('~'))
    if additional_args:
        args.extend(additional_args)
    if sys.platform == 'win32' and background:
        return subprocess.Popen(args, cwd=cwd, env=env, close_fds=False,
                                creationflags=subprocess.CREATE_NEW_CONSOLE)
    else:
        return subprocess.Popen(args, cwd=cwd, env=env, close_fds=False) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:31,代码来源:misc.py

示例13: execute_in_environment

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def execute_in_environment(cmd, prefix=config.root_dir, additional_args=None,
                           inherit=True):
    """Runs ``cmd`` in the specified environment.

    ``inherit`` specifies whether the child inherits stdio handles (for JSON
    output, we don't want to trample this process's stdout).
    """
    binpath, env = environment_for_conda_environment(prefix)

    if sys.platform == 'win32' and cmd == 'python':
        # python is located one directory up on Windows
        cmd = join(binpath, '..', cmd)

    args = shlex.split(cmd)
    if additional_args:
        args.extend(additional_args)

    if inherit:
        stdin, stdout, stderr = None, None, None
    else:
        stdin, stdout, stderr = subprocess.PIPE, subprocess.PIPE, subprocess.PIPE

    if sys.platform == 'win32' and not inherit:
        return subprocess.Popen(args, env=env, close_fds=False,
                                stdin=stdin, stdout=stdout, stderr=stderr,
                                creationflags=subprocess.CREATE_NEW_CONSOLE)
    else:
        return subprocess.Popen(args, env=env, close_fds=False,
                                stdin=stdin, stdout=stdout, stderr=stderr) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:31,代码来源:misc.py

示例14: DeamonHelper

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def DeamonHelper(inName, argLen, scriptName, fileHead):
	inName = os.path.join(customDownDir, inName + '.txt')
	lines = SafeReadandWriteHead(inName, fileHead)
	if len(lines):
		inf = codecs.open(inName, 'w+', 'utf-8')
		if fileHead:
			fileHead = [l.strip() + '\n' for l in fileHead]
			inf.writelines(fileHead)
		else:
			inf.write('')
		inf.close()

		while lines:
			args = GrabArgs(lines, argLen)
			lines = lines[len(args):]
			print(inName + ' command: ' + time.ctime())
			for arg in args:
				print(arg)
			# For safety
			time.sleep(0.5)
			subprocess.Popen(
				[
					'py', '-3', os.path.join(scriptDir, scriptName + '.py')
				] + args,
				creationflags = subprocess.CREATE_NEW_CONSOLE
			 ) 
开发者ID:Kilo19,项目名称:NixieVideoKit,代码行数:28,代码来源:nvkdeamon.py

示例15: _execute_tool

# 需要导入模块: import subprocess [as 别名]
# 或者: from subprocess import CREATE_NEW_CONSOLE [as 别名]
def _execute_tool(self, qaction):
        if qaction:
            _tools = self.prefs.get('tools')
            if _tools:
                for _tool in _tools:
                    if _tool and _tool['name'] and _tool['name'] != 'sep':
                        if qaction.text() == _tool['name']:
                            try:
                                import subprocess
                                subprocess.Popen(_tool['cmd'], creationflags=subprocess.CREATE_NEW_CONSOLE)
                            except:
                                pass
                            break 
开发者ID:iGio90,项目名称:Dwarf,代码行数:15,代码来源:app.py


注:本文中的subprocess.CREATE_NEW_CONSOLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。