#๐Ÿ”’ Need help with python subprocess

36 messages ยท Page 1 of 1 (latest)

lime hedge
#

I will link the old channel, it got closed

topaz fableBOT
#

@lime hedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lime hedge
#

Problem is not knowing if something is an stdout or stderr I have to look out for

#

And it also doesnt make sense that the whole program won't give me outputs at all altho I have my print(newoutline)

rapid dove
#

Tried printing the errline as well?

lime hedge
#

Yep same result

#

the output worked when i just had

def execute(f):
    process = Popen(f, stdout=PIPE, bufsize=1, universal_newlines=True, encoding="utf8") 
    process.poll()
    print("Running Binmaster-Slayer...")
    while True:
        nextline = process.stdout.readline()
        print(nextline)
        if 'Stall detected but the heartbeat check is still active!' in nextline and process.poll() is not None:
            print("Restarting Binmaster-Slayer because of stalling...")
            process.exit()
            time.sleep(5)
            execute(f)
        elif 'Uncaught Exception:' in nextline and process.poll() is not None:
            print("Restarting Binmaster-Slayer because of Uncaught Exception Error...")
            process.exit()
            time.sleep(5)
            execute(f)
            
execute(f)
#

But it wouldn't exit and restart on the specified outputs

#

@rapid dove you have any ideas on how I could change it so it'll work?

rapid dove
#

Output worked, meaning something got printed... So just adding the pipe of stderr stops the prints?

lime hedge
#

yes it is really weird

#

But no, just Piping the stderr is not the problem

#

This code like gives outputs but doesnt restart the program

#

on the specified errors or line contents

#

Okay now its really weird

#

Its just outputting the first line

#

WTF

rapid dove
#

Tried communicate instead of readline?

lime hedge
#

No I'm not familiar with this

#

just process.communicate()?

rapid dove
#

Yea, should return a tuple. With both out and err output

lime hedge
#

Do I have to fill in args in the communicate function?

rapid dove
#

No, I'd see just what communicate() returns

lime hedge
#

These are the latest tracebacks, output is nothing

#

Just this

#

Do I have to decode it or smth?

#

Like the lines

#

prob does that automatically right since I alredy had to specify "utf8"

lime hedge
#

The program is working now but I get no outputs

#

Its really weird

topaz fableBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.