subprocess

poll method of subprocess.popen returning None for long process

谁说胖子不能爱 提交于 2020-06-24 12:24:05
问题 I am executing curl command through subprocess. This curl command starts video processing at another server, and waits for the response. Once the process is done, the remote server returns json object. I am checking the status of the subprocess using poll() value, which is None - process not completed, 0- process completed successfully and 1- for error. I am getting the correct response if the processing takes around 30 mins/or less on remote server, but if the processing is taking more time,

ssh not recognized as a command when executed from python using subprocess?

為{幸葍}努か 提交于 2020-06-15 04:26:26
问题 This is my code - import subprocess import sys HOST="xyz3511.uhc.com" # Ports are handled in ~/.ssh/config since we use OpenSSH COMMAND="uptime" ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = ssh.stdout.readlines() if result == []: error = ssh.stderr.readlines() print (sys.stderr, "ERROR: %s" % error) else: print (result) and this is the error I'm getting- ERROR: [b"'ssh' is not recognized as an internal or external

How to call an ncurses based application using subprocess module in PyCharm IDE?

只愿长相守 提交于 2020-06-12 04:58:05
问题 I would like to launch an ncurses based application from python using subprocess module. The ncurses based application is TABARI, an event extraction system. The result of event extraction is saved to a file. I would like to launch it from a python script, wait for it to terminate and then read the results file. A code sample is shown bellow: import subprocess proc = subprocess.Popen('TABARI -a ' + file, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) print proc.communicate() The

Python subprocess, realtime print with COLORS and save stdout

∥☆過路亽.° 提交于 2020-05-29 08:57:48
问题 Printing the output of a subprocess while saving the result is not a new problem, and has been answered many times before e.g.: https://stackoverflow.com/a/28319191/5506400 This does not work for me because I am trying to maintain the shell colours printed. E.g. when one goes systemctl status application , its prints running in green. The above-mentioned methods all rely on reading a line one by one from subprocess, but it seems to me by them the colour information is stripped off and lost. I

Python subprocess, realtime print with COLORS and save stdout

醉酒当歌 提交于 2020-05-29 08:57:35
问题 Printing the output of a subprocess while saving the result is not a new problem, and has been answered many times before e.g.: https://stackoverflow.com/a/28319191/5506400 This does not work for me because I am trying to maintain the shell colours printed. E.g. when one goes systemctl status application , its prints running in green. The above-mentioned methods all rely on reading a line one by one from subprocess, but it seems to me by them the colour information is stripped off and lost. I

Python subprocess, realtime print with COLORS and save stdout

自闭症网瘾萝莉.ら 提交于 2020-05-29 08:56:50
问题 Printing the output of a subprocess while saving the result is not a new problem, and has been answered many times before e.g.: https://stackoverflow.com/a/28319191/5506400 This does not work for me because I am trying to maintain the shell colours printed. E.g. when one goes systemctl status application , its prints running in green. The above-mentioned methods all rely on reading a line one by one from subprocess, but it seems to me by them the colour information is stripped off and lost. I

Continuous communication between parent and child subprocess in Python (Windows)?

懵懂的女人 提交于 2020-05-29 06:54:30
问题 I have this script: import subprocess p = subprocess.Popen(["myProgram.exe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) while True: out, _ = p.communicate(input().encode()) print(out.decode()) which works fine until the second input where I get: ValueError: Cannot send input after starting communication Is there a way to have multiple messages sent between the parent and child process in Windows ? [EDIT] I don't have access to the source code of myProgram.exe It is an interactive command

Getting stdout from console

醉酒当歌 提交于 2020-05-17 05:55:48
问题 I'm trying to make a python script that would clone(ISO image) one usb stick to another using dd if=/dev/sda of=/dev/sdb Here's my problem: I want to create progress bar showing what is done. I tried: Looking at storage space at second usb stick, but this doesn't work beacause ISO image scans also unused space By adding status=progress to dd command I can get progress in terminal but I can't figure how to access stdout from python. I tried subprocess.Popen,run(stdout = PIPE) with and without

running TCL through python by subprocess, but not giving any output

主宰稳场 提交于 2020-05-16 09:49:41
问题 I am trying to run my tcl script through python subprocess as follow: import subprocess >>> subprocess.Popen(["tclsh", "tcltest.tcl"]) <subprocess.Popen object at 0x0000000001DD4DD8> >>> subprocess.Popen(["tclsh", "tcltest.tcl"], shell=True ) <subprocess.Popen object at 0x0000000002B34550> I don't know if it is working or not, since I don't see any anything from it! my tcl script also has some packages from my company that causes errors when I use Tkinter, Tk, and eval, import Tkinter import

running TCL through python by subprocess, but not giving any output

Deadly 提交于 2020-05-16 09:48:30
问题 I am trying to run my tcl script through python subprocess as follow: import subprocess >>> subprocess.Popen(["tclsh", "tcltest.tcl"]) <subprocess.Popen object at 0x0000000001DD4DD8> >>> subprocess.Popen(["tclsh", "tcltest.tcl"], shell=True ) <subprocess.Popen object at 0x0000000002B34550> I don't know if it is working or not, since I don't see any anything from it! my tcl script also has some packages from my company that causes errors when I use Tkinter, Tk, and eval, import Tkinter import