workhorsy / py-cpuinfo

A module for getting CPU info with pure Python
MIT License
312 stars 59 forks source link

cpuinfo is forcing open console windows if imported into a non-console execution environment #196

Open EricBLivingston opened 1 year ago

EricBLivingston commented 1 year ago

Basically, you need to change the following:

def _run_and_get_stdout(command, pipe_command=None):
    from subprocess import Popen, PIPE

    g_trace.command_header('Running command "' + ' '.join(command) + '" ...')

    # Run the command normally
    if not pipe_command:
        p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)

The Popen command should be: p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE, creationflags=subprocess.CREATE_NO_WINDOW)