Python subprocess.STARTF_USESHOWWINDOW() Examples

The following are code examples for showing how to use subprocess.STARTF_USESHOWWINDOW(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: Radium   Author: mehulj94   File: Radiumkeylogger.py    Apache License 2.0 6 votes vote down vote up
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 
Example 2
Project: sublime-solium-gutter   Author: sey   File: solium-gutter.py    MIT License 6 votes vote down vote up
def get_output(cmd):
    if int(sublime.version()) < 3000:
      if sublime.platform() != "windows":
        # Handle Linux and OS X in Python 2.
        run = '"' + '" "'.join(cmd) + '"'
        return commands.getoutput(run)
      else:
        # Handle Windows in Python 2.
        # Prevent console window from showing.
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        return subprocess.Popen(cmd, \
          stdout=subprocess.PIPE, \
          startupinfo=startupinfo).communicate()[0]
    else:
      # Handle all OS in Python 3.
      run = '"' + '" "'.join(cmd) + '"'
      try:
        return subprocess.check_output(run, stderr=subprocess.STDOUT, shell=True, env=os.environ)
      except Exception as exception:
        print(exception.output) 
Example 3
Project: imageio-ffmpeg   Author: imageio   File: _utils.py    BSD 2-Clause "Simplified" License 6 votes vote down vote up
def _is_valid_exe(exe):
    cmd = [exe, "-version"]
    try:
        with open(os.devnull, "w") as null:
            hide_window = None
            if os.name == 'nt':
                # stops executable from flashing on Windows
                hide_window = subprocess.STARTUPINFO()
                hide_window.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            subprocess.check_call(
                cmd, stdout=null, stderr=subprocess.STDOUT,
                startupinfo=hide_window
                )
        return True
    except (OSError, ValueError, subprocess.CalledProcessError):
        return False 
Example 4
Project: imageio-ffmpeg   Author: imageio   File: _utils.py    BSD 2-Clause "Simplified" License 6 votes vote down vote up
def get_ffmpeg_version():
    """
    Get the version of the used ffmpeg executable (as a string).
    """
    exe = get_ffmpeg_exe()
    hide_window = None
    if os.name == 'nt':
        # stops executable from flashing on Windows
        hide_window = subprocess.STARTUPINFO()
        hide_window.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    line = subprocess.check_output(
        [exe, "-version"], startupinfo=hide_window
        ).split(b"\n", 1)[0]
    line = line.decode(errors="ignore").strip()
    version = line.split("version", 1)[-1].lstrip().split(" ", 1)[0].strip()
    return version 
Example 5
Project: script.mtvguide   Author: Mariusz89B   File: recordService.py    GNU General Public License v2.0 6 votes vote down vote up
def record(self, recordCommand, threadData):
        deb('RecordService record command: %s' % str(recordCommand))
        threadData['recordStartTime'] = datetime.datetime.now()
        output = ''
        si = None
        if os.name == 'nt':
            si = subprocess.STARTUPINFO()
            si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        recordEnviron = os.environ.copy()
        oldLdPath = recordEnviron.get("LD_LIBRARY_PATH", '')
        recordEnviron["LD_LIBRARY_PATH"] = os.path.join(os.path.dirname(recordCommand[0]), 'lib') + ':/lib:/usr/lib:/usr/local/lib'
        if oldLdPath != '':
            recordEnviron["LD_LIBRARY_PATH"] = recordEnviron["LD_LIBRARY_PATH"] + ":" + oldLdPath
        try:
            threadData['stopRecordTimer'] = threading.Timer(threadData['recordDuration'] + 5, self.stopRecord, [threadData])
            threadData['stopRecordTimer'].start()
            threadData['recordHandle'] = subprocess.Popen(recordCommand, shell=False, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=si, env=recordEnviron)
            output = threadData['recordHandle'].communicate()[0]
            returnCode = threadData['recordHandle'].returncode
            threadData['stopRecordTimer'].cancel()
            threadData['recordHandle'] = None
            deb('RecordService record finished, \noutput: %s, \nstatus: %d, Command: %s' % (output, returnCode, str(recordCommand)))
        except Exception, ex:
            deb('RecordService record exception: %s' % getExceptionString()) 
Example 6
Project: spied-on-u   Author: Lin8x   File: systeminfo.py    GNU General Public License v3.0 6 votes vote down vote up
def getWindows():
  
  def writeCommand(command):
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    const = ((200 - len(command)) // 2)
    linestr = "-" * const + command + "-" * const
    output = subprocess.Popen(command, startupinfo=startupinfo, stdout=subprocess.PIPE)
    logger.write(str(output.stdout.read()).replace("\\r\\n", "\r\n"))
    logger.write("\n" + linestr + "\n")

  logger = open("systeminfowin.log", 'a+')
  writeCommand("Systeminfo")
  writeCommand("ipconfig")

#######################################################
#######################################################
####################################################### 
Example 7
Project: watools   Author: wateraccounting   File: raster_conversions.py    Apache License 2.0 6 votes vote down vote up
def Run_command_window(argument):
    """
    This function runs the argument in the command window without showing cmd window

    Keyword Arguments:
    argument -- string, name of the adf file
    """
    if os.name == 'posix':
        argument = argument.replace(".exe","")
        os.system(argument)

    else:
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

        process = subprocess.Popen(argument, startupinfo=startupinfo, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
        process.wait()

    return() 
Example 8
Project: sublime-win-bak   Author: okoala   File: HTMLPrettify.py    MIT License 6 votes vote down vote up
def get_output(cmd):
    if int(sublime.version()) < 3000:
      if sublime.platform() != "windows":
        # Handle Linux and OS X in Python 2.
        run = '"' + '" "'.join(cmd) + '"'
        return commands.getoutput(run)
      else:
        # Handle Windows in Python 2.
        # Prevent console window from showing.
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        return subprocess.Popen(cmd, \
          stdout=subprocess.PIPE, \
          startupinfo=startupinfo).communicate()[0]
    else:
      # Handle all OS in Python 3.
      run = '"' + '" "'.join(cmd) + '"'
      return subprocess.check_output(run, stderr=subprocess.STDOUT, shell=True, env=os.environ) 
Example 9
Project: sublime-win-bak   Author: okoala   File: node_bridge.py    MIT License 6 votes vote down vote up
def node_bridge(data, bin, args=[]):
	env = None
	startupinfo = None
	if IS_OSX:
		# GUI apps in OS X doesn't contain .bashrc/.zshrc set paths
		env = os.environ.copy()
		env['PATH'] += ':/usr/local/bin'
	if IS_WINDOWS:
		startupinfo = subprocess.STARTUPINFO()
		startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
	try:
		p = subprocess.Popen(['node', bin] + args,
			stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
			env=env, startupinfo=startupinfo)
	except OSError:
		raise Exception('Couldn\'t find Node.js. Make sure it\'s in your $PATH by running `node -v` in your command-line.')
	stdout, stderr = p.communicate(input=data.encode('utf-8'))
	stdout = stdout.decode('utf-8')
	stderr = stderr.decode('utf-8')
	if stderr:
		raise Exception('Error: %s' % stderr)
	else:
		return stdout 
Example 10
Project: sublime-win-bak   Author: okoala   File: HTMLPrettify.py    MIT License 6 votes vote down vote up
def get_output(cmd):
    if int(sublime.version()) < 3000:
      if sublime.platform() != "windows":
        # Handle Linux and OS X in Python 2.
        run = '"' + '" "'.join(cmd) + '"'
        return commands.getoutput(run)
      else:
        # Handle Windows in Python 2.
        # Prevent console window from showing.
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        return subprocess.Popen(cmd, \
          stdout=subprocess.PIPE, \
          startupinfo=startupinfo).communicate()[0]
    else:
      # Handle all OS in Python 3.
      run = '"' + '" "'.join(cmd) + '"'
      return subprocess.check_output(run, stderr=subprocess.STDOUT, shell=True, env=os.environ) 
Example 11
Project: LaZagne   Author: AlessandroZ   File: execute_cmd.py    GNU Lesser General Public License v3.0 6 votes vote down vote up
def save_hives():
    """
    Save SAM Hives
    """
    for h in constant.hives:
        if not os.path.exists(constant.hives[h]):
            try:
                cmdline = 'reg.exe save hklm\%s %s' % (h, constant.hives[h])
                command = ['cmd.exe', '/c', cmdline]
                info = subprocess.STARTUPINFO()
                info.dwFlags = STARTF_USESHOWWINDOW
                info.wShowWindow = SW_HIDE
                p = subprocess.Popen(command, startupinfo=info, stdin=subprocess.PIPE, stderr=subprocess.STDOUT,
                                     stdout=subprocess.PIPE, universal_newlines=True)
                results, _ = p.communicate()
            except Exception as e:
                print_debug('ERROR', u'Failed to save system hives: {error}'.format(error=e))
                return False
    return True 
Example 12
Project: sublime-standard-format   Author: bcomnes   File: standard-format.py    MIT License 6 votes vote down vote up
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 
Example 13
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:apex:test:run', '-r', 'human',
                '-l', 'RunSpecifiedTests', '-n', self.class_name]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\n' + str(out, 'utf-8'))
        else:
            printErr = err
            if err is None or err == '':
                printErr = out
            printer.write('\n' + str(printErr, 'utf-8')) 
Example 14
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:apex:test:run', '-r', 'human']
        if not self.test_org is None and len(self.test_org) > 0:
            args.push('-u')
            args.push(self.input)
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\n' + str(out, 'utf-8'))
        else:
            printErr = err
            if err is None or err == '':
                printErr = out
            printer.write('\n' + str(printErr, 'utf-8')) 
Example 15
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:source:push']
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\n' + str(out, 'utf-8'))
        else:
            printErr = err
            if not err is None and not err == '':
                printErr = out
            else:
                printer.write('\nError pushing source')
            printer.write('\n' + str(printErr, 'utf-8')) 
Example 16
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:source:pull']
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\n' + str(out, 'utf-8'))
        else:
            printErr = err
            if not err is None and not err == '':
                printErr = out
            else:
                printer.write('\nError pulling source')
            printer.write('\n' + str(printErr, 'utf-8')) 
Example 17
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:org:open']
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nScratch org opened')
        else:
            printer.write('\nError opening')
            printer.write('\n' + str(err, 'utf-8')) 
Example 18
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:auth:web:login', '-d', '-s', '-a', 'DevHub']
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nDevHub authorized')
        else:
            printer.write('\nError authorizing Dev Hub:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 19
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:visualforce:component:create',
                '-n', self.page_name,'-l', self.page_label, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nVisaulforce Component created')
            file = os.path.join(self.class_dir, self.page_name + '.component')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Visualforce Component:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 20
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:visualforce:page:create',
                '-n', self.page_name,'-l', self.page_label, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nVisaulforce page created')
            file = os.path.join(self.class_dir, self.page_name + '.page')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Visualforce page:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 21
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:lightning:component:create',
                '-n', self.cmp_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nLightning Component created')
            file = os.path.join(self.class_dir, self.cmp_name, self.cmp_name + '.cmp')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Lightning Component:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 22
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:lightning:test:create',
                '-n', self.event_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nLightning Test created')
            file = os.path.join(self.class_dir, self.event_name + '.resource')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Lightning Test:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 23
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:lightning:interface:create',
                '-n', self.event_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nLightning Interface created')
            file = os.path.join(self.class_dir, self.event_name, self.event_name + '.intf')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Lightning Interface:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 24
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:lightning:event:create',
                '-n', self.event_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nLightning Event created')
            file = os.path.join(self.class_dir, self.event_name, self.event_name + '.evt')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Lightning Event:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 25
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:lightning:app:create',
                '-n', self.app_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nLightning App created')
            file = os.path.join(self.class_dir, self.app_name, self.app_name + '.app')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Lightning App:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 26
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        dx_folder = util.dxProjectFolder()
        args = ['sfdx', 'force:apex:class:create',
                '-n', self.class_name, '-d', self.class_dir]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nApex class created')
            file = os.path.join(self.class_dir, self.class_name + '.cls')
            sublime.active_window().open_file(file)
        else:
            printer.write('\nError creating Apex Class:')
            printer.write('\n' + str(err, 'utf-8')) 
Example 27
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:project:create', '-n', self.project_name,
                '-t', self.template, '-d', self.project_path]
        if self.namespace is not None and self.namespace != '':
            args.push('-s')
            args.push(self.namespace)
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT, startupinfo=startupinfo)

        p.wait()

        out,err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nProject created')
        else:
            printer.write('\nError creating project:')
            printer.write('\n' + str(out, 'UTF-8')) 
Example 28
Project: DXMate   Author: jtowers   File: dxmate.py    MIT License 6 votes vote down vote up
def run_command(self):
        args = ['sfdx', 'force:apex:execute', '-f', self.file_path]
        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                             startupinfo=startupinfo, cwd=self.dx_folder)

        p.wait()

        out, err = p.communicate()
        r = p.returncode
        if p.returncode == 0:
            printer.write('\nFinished running apex')
            printer.write('\n' + str(out, 'utf-8'))
        else:
            printErr = err
            if err is None or err == '':
                printErr = out
            printer.write('\nError running apex')
            printer.write('\n' + str(printErr, 'utf-8')) 
Example 29
Project: VSCMT   Author: drew-wallace   File: util.py    MIT License 6 votes vote down vote up
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 
Example 30
Project: AutoPK   Author: guitanj   File: goEngin-SamePoPK(Stop update).py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, command, cwdstr):
        si = subprocess.STARTUPINFO()
        si.dwFlags = subprocess.CREATE_NEW_CONSOLE \
                     | subprocess.STARTF_USESHOWWINDOW
        si.wShowWindow = subprocess.SW_HIDE
        self.process = Popen(command, bufsize=1,stdin=PIPE, stdout=PIPE, \
                        stderr=PIPE,startupinfo=si,cwd=cwdstr)
        print('leelaz threading is started...',self.process.pid,'poll:',self.process.poll())

        #gtp辅助的运算信息,比如genmove中的过程,胜率,其他选点等都在stderr中输出
        self.stderr_queue = Queue()
        Thread(target=self.consume_stderr).start()
        #print('get stderr threading is started...',self.process.poll())
        
        #程序调用一开始就出错的话,比如命令行用错了,报错信息在stdout中输出
        #运行起来,正常的gtp输出信息在stdout中
        self.stdout_queue = Queue()
        Thread(target=self.consume_stdout).start()
        #print('get stdout threading is started...',self.process.poll())

    #读取stderr信息流,写入stderrQ 
Example 31
Project: AutoPK   Author: guitanj   File: autoPK-SameTime.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, command, cwdstr):
        si = subprocess.STARTUPINFO()
        si.dwFlags = subprocess.CREATE_NEW_CONSOLE \
                     | subprocess.STARTF_USESHOWWINDOW
        si.wShowWindow = subprocess.SW_HIDE
        self.process = Popen(command, bufsize=1,stdin=PIPE, stdout=PIPE, \
                        stderr=PIPE,startupinfo=si,cwd=cwdstr)
        print('leelaz threading is started...',self.process.pid,'poll:',self.process.poll())

        #gtp辅助的运算信息,比如genmove中的过程,胜率,其他选点等都在stderr中输出
        self.stderr_queue = Queue()
        Thread(target=self.consume_stderr).start()
        #print('get stderr threading is started...',self.process.poll())
        
        #程序调用一开始就出错的话,比如命令行用错了,报错信息在stdout中输出
        #运行起来,正常的gtp输出信息在stdout中
        self.stdout_queue = Queue()
        Thread(target=self.consume_stdout).start()
        #print('get stdout threading is started...',self.process.poll())

    #读取stderr信息流,写入stderrQ 
Example 32
Project: AutoPK   Author: guitanj   File: autoPK.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, command, cwdstr):
        si = subprocess.STARTUPINFO()
        si.dwFlags = subprocess.CREATE_NEW_CONSOLE \
                     | subprocess.STARTF_USESHOWWINDOW
        si.wShowWindow = subprocess.SW_HIDE
        self.process = Popen(command, bufsize=1,stdin=PIPE, stdout=PIPE, \
                        stderr=PIPE,startupinfo=si,cwd=cwdstr)
        print('leelaz threading is started...',self.process.pid,'poll:',self.process.poll())

        #gtp辅助的运算信息,比如genmove中的过程,胜率,其他选点等都在stderr中输出
        self.stderr_queue = Queue()
        Thread(target=self.consume_stderr).start()
        #print('get stderr threading is started...',self.process.poll())
        
        #程序调用一开始就出错的话,比如命令行用错了,报错信息在stdout中输出
        #运行起来,正常的gtp输出信息在stdout中
        self.stdout_queue = Queue()
        Thread(target=self.consume_stdout).start()
        #print('get stdout threading is started...',self.process.poll())

    #读取stderr信息流,写入stderrQ 
Example 33
Project: AutoPK   Author: guitanj   File: goEngin-SameTimePK(Stop update).py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, command, cwdstr):
        si = subprocess.STARTUPINFO()
        si.dwFlags = subprocess.CREATE_NEW_CONSOLE \
                     | subprocess.STARTF_USESHOWWINDOW
        si.wShowWindow = subprocess.SW_HIDE
        self.process = Popen(command, bufsize=1,stdin=PIPE, stdout=PIPE, \
                        stderr=PIPE,startupinfo=si,cwd=cwdstr)
        print('leelaz threading is started...',self.process.pid,'poll:',self.process.poll())

        #gtp辅助的运算信息,比如genmove中的过程,胜率,其他选点等都在stderr中输出
        self.stderr_queue = Queue()
        Thread(target=self.consume_stderr).start()
        #print('get stderr threading is started...',self.process.poll())
        
        #程序调用一开始就出错的话,比如命令行用错了,报错信息在stdout中输出
        #运行起来,正常的gtp输出信息在stdout中
        self.stdout_queue = Queue()
        Thread(target=self.consume_stdout).start()
        #print('get stdout threading is started...',self.process.poll())

    #读取stderr信息流,写入stderrQ 
Example 34
Project: phpCodeBeautifier   Author: iKuiki   File: phpcb.py    Mozilla Public License 2.0 6 votes vote down vote up
def get_output(self, cmd):
        if int(sublime.version()) < 3000:
            if sublime.platform() != "windows":
                # Handle Linux and OS X in Python 2.
                run = '"' + '" "'.join(cmd) + '"'
                return commands.getoutput(run)
            else:
                # Handle Windows in Python 2.
                # Prevent console window from showing.
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                return subprocess.Popen(cmd, \
                    stdout=subprocess.PIPE, \
                    startupinfo=startupinfo).communicate()[0]
        else:
            # Handle all OS in Python 3.
            run = '"' + '" "'.join(cmd) + '"'
            print("run is:"+run)
            return subprocess.check_output(run, stderr=subprocess.STDOUT, shell=True, env=os.environ) 
Example 35
Project: smoke-zephyr   Author: zeroSteiner   File: utilities.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def open_uri(uri):
	"""
	Open a URI in a platform intelligent way. On Windows this will use
	'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
	depending on which is available. If no suitable application can be
	found to open the URI, a RuntimeError will be raised.

	.. versionadded:: 1.3.0

	:param str uri: The URI to open.
	"""
	close_fds = True
	startupinfo = None
	proc_args = []
	if sys.platform.startswith('win'):
		proc_args.append(which('cmd.exe'))
		proc_args.append('/c')
		proc_args.append('start')
		uri = uri.replace('&', '^&')
		close_fds = False
		startupinfo = subprocess.STARTUPINFO()
		startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
		startupinfo.wShowWindow = subprocess.SW_HIDE
	elif which('gvfs-open'):
		proc_args.append(which('gvfs-open'))
	elif which('xdg-open'):
		proc_args.append(which('xdg-open'))
	else:
		raise RuntimeError('could not find suitable application to open uri')
	proc_args.append(uri)
	proc_h = subprocess.Popen(proc_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=close_fds, startupinfo=startupinfo)
	return proc_h.wait() == 0 
Example 36
Project: Repobot   Author: Desgard   File: popen_spawn.py    MIT License 5 votes vote down vote up
def __init__(self, cmd, timeout=30, maxread=2000, searchwindowsize=None,
                 logfile=None, cwd=None,  env=None, encoding=None,
                 codec_errors='strict'):
        super(PopenSpawn, self).__init__(timeout=timeout, maxread=maxread,
                searchwindowsize=searchwindowsize, logfile=logfile,
                encoding=encoding, codec_errors=codec_errors)

        kwargs = dict(bufsize=0, stdin=subprocess.PIPE,
                      stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
                      cwd=cwd, env=env)

        if sys.platform == 'win32':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            kwargs['startupinfo'] = startupinfo
            kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP

        if not isinstance(cmd, (list, tuple)):
            cmd = shlex.split(cmd)

        self.proc = subprocess.Popen(cmd, **kwargs)
        self.closed = False
        self._buf = self.string_type()

        self._read_queue = Queue()
        self._read_thread = threading.Thread(target=self._read_incoming)
        self._read_thread.setDaemon(True)
        self._read_thread.start() 
Example 37
Project: flight-lab   Author: google   File: windows.py    Apache License 2.0 5 votes vote down vote up
def _launch_app(self):
    args = [self._bin_path] + self._arguments
    self.logger.debug('[App - {0}] Executing "{1}"...'.format(
        self._name, ' '.join(args)))

    self.emit('starting', self)

    proc = None
    info = subprocess.STARTUPINFO()
    if self._start_minimized:
      info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
      info.wShowWindow = _SW_MINIMIZE

    try:
      proc = subprocess.Popen(
          args,
          cwd=self._working_dir,
          creationflags=subprocess.CREATE_NEW_CONSOLE,
          close_fds=True,
          startupinfo=info)
    except Exception as e:
      self.logger.debug('[App - {0}] Failed to launch. {1}'.format(
          self._name, e))
      return None

    self.emit('started', self)
    return proc 
Example 38
Project: ncm2   Author: ncm2   File: ncm2.py    MIT License 5 votes vote down vote up
def __init__(self, *args, **keys):
            if 'startupinfo' not in keys:
                si = subprocess.STARTUPINFO()
                si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                keys['startupinfo'] = si
            cls.__init__(self, *args, **keys) 
Example 39
Project: Pancas   Author: Sup3Roque   File: nhlcom.py    GNU General Public License v2.0 5 votes vote down vote up
def run(self, url, selectGame ,side):

        if selectGame == None or side == None:
            return control.resolve(int(sys.argv[1]), True, control.item(path=url))

        command = ['java','-jar',jarFile,selectGame,side]

        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

        self.process = subprocess.Popen(command,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            startupinfo=startupinfo)

        if os.name == 'posix':
            success = False
            success, output = FuckNeulionClient.request_proxy_hack(selectGame,side)

        control.sleep(1000)

        control.resolve(int(sys.argv[1]), True, control.item(path=url))

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            control.sleep(1000)
        while self.isPlayingVideo():
            control.sleep(1000)
        control.sleep(5000) 
Example 40
Project: Pancas   Author: Sup3Roque   File: nhlcom.py    GNU General Public License v2.0 5 votes vote down vote up
def run(self, url, selectGame ,side):

        if selectGame == None or side == None:
            return control.resolve(int(sys.argv[1]), True, control.item(path=url))

        command = ['java','-jar',jarFile,selectGame,side]

        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

        self.process = subprocess.Popen(command,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            startupinfo=startupinfo)

        if os.name == 'posix':
            success = False
            success, output = FuckNeulionClient.request_proxy_hack(selectGame,side)

        control.sleep(1000)

        control.resolve(int(sys.argv[1]), True, control.item(path=url))

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            control.sleep(1000)
        while self.isPlayingVideo():
            control.sleep(1000)
        control.sleep(5000) 
Example 41
Project: honeybee   Author: ladybug-tools   File: pyrad_proc.py    GNU General Public License v3.0 5 votes vote down vote up
def __configure_subprocess(self):
        '''Prevent subprocess module failure in frozen scripts on Windows.
           Prevent console windows from popping up when not console based.
           Make sure we use the version-specific string types.
        '''
        # On Windows, sys.stdxxx may not be available when:
        # - built as *.exe with "pyinstaller --noconsole"
        # - invoked via CreateProcess() and stream not redirected
        try:
            sys.__stdin__.fileno()
            self._stdin = sys.stdin
        except BaseException:
            self._stdin = PIPE
        try:
            sys.__stdout__.fileno()
            self._stdout = sys.stdout
        except BaseException:
            self._stdout = PIPE
        try:
            sys.__stderr__.fileno()
            self._stderr = sys.stderr
        # keep subprocesses from opening their own console.
        except BaseException:
            self._stderr = PIPE
        if hasattr(subprocess, 'STARTUPINFO'):
            si = subprocess.STARTUPINFO()
            si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            self._pipeargs = {'startupinfo': si}
        else:
            self._pipeargs = {}
        # type names vary between Py2.7 and 3.x
        self._strtypes = (type(b''), type(u'')) 
Example 42
Project: Dolphin-Updater   Author: nbear3   File: data_control.py    GNU General Public License v3.0 5 votes vote down vote up
def _call_proc(*proc_args):
    starti = subprocess.STARTUPINFO()
    starti.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    subprocess.call(proc_args, startupinfo=starti,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.STDOUT,
                    stdin=subprocess.PIPE) 
Example 43
Project: NiujiaoDebugger   Author: MrSrc   File: test_subprocess.py    GNU General Public License v3.0 5 votes vote down vote up
def test_startupinfo(self):
        # startupinfo argument
        # We uses hardcoded constants, because we do not want to
        # depend on win32all.
        STARTF_USESHOWWINDOW = 1
        SW_MAXIMIZE = 3
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags = STARTF_USESHOWWINDOW
        startupinfo.wShowWindow = SW_MAXIMIZE
        # Since Python is a console process, it won't be affected
        # by wShowWindow, but the argument should be silently
        # ignored
        subprocess.call([sys.executable, "-c", "import sys; sys.exit(0)"],
                        startupinfo=startupinfo) 
Example 44
Project: NiujiaoDebugger   Author: MrSrc   File: test_subprocess.py    GNU General Public License v3.0 5 votes vote down vote up
def test_startupinfo_copy(self):
        # bpo-34044: Popen must not modify input STARTUPINFO structure
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
        startupinfo.wShowWindow = subprocess.SW_HIDE

        # Call Popen() twice with the same startupinfo object to make sure
        # that it's not modified
        for _ in range(2):
            cmd = [sys.executable, "-c", "pass"]
            with open(os.devnull, 'w') as null:
                proc = subprocess.Popen(cmd,
                                        stdout=null,
                                        stderr=subprocess.STDOUT,
                                        startupinfo=startupinfo)
                with proc:
                    proc.communicate()
                self.assertEqual(proc.returncode, 0)

            self.assertEqual(startupinfo.dwFlags,
                             subprocess.STARTF_USESHOWWINDOW)
            self.assertIsNone(startupinfo.hStdInput)
            self.assertIsNone(startupinfo.hStdOutput)
            self.assertIsNone(startupinfo.hStdError)
            self.assertEqual(startupinfo.wShowWindow, subprocess.SW_HIDE)
            self.assertEqual(startupinfo.lpAttributeList, {"handle_list": []}) 
Example 45
Project: package_coverage   Author: codexns   File: package_coverage.py    MIT License 5 votes vote down vote up
def git_commit_info(package_dir):
    """
    Get the git SHA1 hash, commit date and summary for the current git commit

    :param package_dir:
        A unicode string of the filesystem path to the folder containing the
        package

    :return:
        A tuple containing:
        [0] A unicode string of the short commit hash
        [1] A datetime.datetime object of the commit date
        [2] A unicode string of the commit message summary
    """

    startupinfo = None
    if sys.platform == 'win32':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    _, env = shellenv.get_env(for_subprocess=True)
    proc = subprocess.Popen(
        ['git', 'log', '-n', '1', "--pretty=format:%h %at %s", 'HEAD'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        env=env,
        cwd=package_dir,
        startupinfo=startupinfo
    )
    stdout, stderr = proc.communicate()
    if stderr:
        raise OSError(stderr.decode('utf-8').strip())
    parts = stdout.decode('utf-8').strip().split(' ', 2)
    return (parts[0], datetime.utcfromtimestamp(int(parts[1])), parts[2]) 
Example 46
Project: package_coverage   Author: codexns   File: package_coverage.py    MIT License 5 votes vote down vote up
def is_git_clean(package_dir):
    """
    Detects if the git repository is currently all committed

    :param package_dir:
        A unicode string of the filesystem path to the folder containing the
        package

    :return:
        A boolean - if the repository is clean
    """

    startupinfo = None
    if sys.platform == 'win32':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    _, env = shellenv.get_env(for_subprocess=True)
    proc = subprocess.Popen(
        ['git', 'status', '--porcelain'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        env=env,
        cwd=package_dir,
        startupinfo=startupinfo
    )
    stdout, stderr = proc.communicate()
    if stderr:
        raise OSError(stderr.decode('utf-8').strip())
    return len(stdout.decode('utf-8').strip()) == 0 
Example 47
Project: D-VAE   Author: muhanzhang   File: windows.py    MIT License 5 votes vote down vote up
def subprocess_Popen(command, **params):
    """
    Utility function to work around windows behavior that open windows.

    :see: call_subprocess_Popen and output_subprocess_Popen
    """
    startupinfo = None
    if os.name == 'nt':
        startupinfo = subprocess.STARTUPINFO()
        try:
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        except AttributeError:
            startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW

        # Anaconda for Windows does not always provide .exe files
        # in the PATH, they also have .bat files that call the corresponding
        # executable. For instance, "g++.bat" is in the PATH, not "g++.exe"
        # Unless "shell=True", "g++.bat" is not executed when trying to
        # execute "g++" without extensions.
        # (Executing "g++.bat" explicitly would also work.)
        params['shell'] = True

    # Using the dummy file descriptors below is a workaround for a
    # crash experienced in an unusual Python 2.4.4 Windows environment
    # with the default None values.
    stdin = None
    if "stdin" not in params:
        stdin = open(os.devnull)
        params['stdin'] = stdin.fileno()

    try:
        proc = subprocess.Popen(command, startupinfo=startupinfo, **params)
    finally:
        if stdin is not None:
            del stdin
    return proc 
Example 48
Project: sublime-win-bak   Author: okoala   File: Babel.py    MIT License 5 votes vote down vote up
def node_bridge(data, bin, args=[]):
	env = None
	startupinfo = None
	if os_name == 'osx':
		# GUI apps in OS X doesn't contain .bashrc/.zshrc set paths
		env = os.environ.copy()
		env['PATH'] += ':/usr/local/bin'
	elif os_name == 'windows':
		startupinfo = subprocess.STARTUPINFO()
		startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
	try:
		p = subprocess.Popen(
			['node', bin] + args,
			stdout=subprocess.PIPE,
			stdin=subprocess.PIPE,
			stderr=subprocess.PIPE,
			env=env,
			startupinfo=startupinfo
		)
	except OSError:
		raise Exception('Error: Couldn\'t find "node" in "%s"' % env['PATH'])
	stdout, stderr = p.communicate(input=data.encode('utf-8'))
	stdout = stdout.decode('utf-8')
	stderr = stderr.decode('utf-8')
	if stderr:
		raise Exception('Error: %s' % stderr)
	else:
		return stdout 
Example 49
Project: Grok-backdoor   Author: deepzec   File: server.py    GNU General Public License v3.0 5 votes vote down vote up
def launchTunnelWithoutConsole(command, port):
    """Launches 'command' windowless and waits until finished"""
#    startupinfo = subprocess.STARTUPINFO()
#    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#    startupinfo.wShowWindow = subprocess.SW_HIDE
#    subprocess.Popen([command, 'tcp', port], startupinfo=startupinfo)
    if ostype == 'windows':
        os.popen2('START /B '+command+' tcp '+port)

    else:
        os.popen2(command+' tcp '+port + ' &') 
Example 50
Project: sublime-standard-format   Author: bcomnes   File: standard-format.py    MIT License 5 votes vote down vote up
def standard_format(string, 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,
        env=calculate_env(),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        startupinfo=startupinfo
    )

    std.stdin.write(bytes(string, 'UTF-8'))
    out, err = std.communicate()
    print(err)
    return out.decode("utf-8"), None