subprocess

How to detect when subprocess asks for input in Windows

南笙酒味 提交于 2021-02-18 10:35:28
问题 I have a subprocess that either quits with a returncode, or asks something and waits for user input. I would like to detect when the process asks the question and quit immediately. The fact that the process asks the question or not is enough for me to decide the state of the system. The problem is that I cannot read the question because the child process probably does not flush standard output. So I cannot rely on parsing subprocess.Popen().stdout : when trying to read it, well, it blocks

How to use sockets in Python and subprocess?

最后都变了- 提交于 2021-02-17 03:55:05
问题 /* Hey, this script is purely for fun, not anything illegal, besides its easy to stop and detect. Further on if I were to use it for illegal activities, why would I post it here? */ My problem is that I am not able to execute cmd commands from the client. I am not sure why although I have a hint that it is to do with some kind of socket error. When I try to execute the command it just does nothing no matter how long I wait. It's nothing wrong with the client as I have tested it out with a

How to use sockets in Python and subprocess?

帅比萌擦擦* 提交于 2021-02-17 03:54:35
问题 /* Hey, this script is purely for fun, not anything illegal, besides its easy to stop and detect. Further on if I were to use it for illegal activities, why would I post it here? */ My problem is that I am not able to execute cmd commands from the client. I am not sure why although I have a hint that it is to do with some kind of socket error. When I try to execute the command it just does nothing no matter how long I wait. It's nothing wrong with the client as I have tested it out with a

subprocess not creating output file of ffmpeg command

痞子三分冷 提交于 2021-02-17 02:18:28
问题 I am trying to run an ffmpeg command that records my screen and creates an .mp4 file of the recording in python. The command works when I run it in my shell, but is not working when I am running it in a Python script using subprocess. The issue is that when running it with subprocess, the output.mp4 file is not created. Here is the command: timeout 10 ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec aac -strict experimental output.mp4 Here is

subprocess not creating output file of ffmpeg command

只愿长相守 提交于 2021-02-17 02:18:21
问题 I am trying to run an ffmpeg command that records my screen and creates an .mp4 file of the recording in python. The command works when I run it in my shell, but is not working when I am running it in a Python script using subprocess. The issue is that when running it with subprocess, the output.mp4 file is not created. Here is the command: timeout 10 ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -i pulse -acodec aac -strict experimental output.mp4 Here is

How to run python subprocess with real-time output?

荒凉一梦 提交于 2021-02-11 18:19:23
问题 When I run a shell command in Python it does not show the output until the command is finished. the script that I run takes a few hours to finish and I'd like to see the progress while it is running. How can I have python run it and show the outputs in real-time? 回答1: Use the following function to run your code. In this example, I want to run an R script with two arguments. You can replace cmd with any other shell command. from subprocess import Popen, PIPE def run(command): process = Popen

How to run python subprocess with real-time output?

荒凉一梦 提交于 2021-02-11 18:18:20
问题 When I run a shell command in Python it does not show the output until the command is finished. the script that I run takes a few hours to finish and I'd like to see the progress while it is running. How can I have python run it and show the outputs in real-time? 回答1: Use the following function to run your code. In this example, I want to run an R script with two arguments. You can replace cmd with any other shell command. from subprocess import Popen, PIPE def run(command): process = Popen

How to preserve colors when capturing output from Git commands?

谁说胖子不能爱 提交于 2021-02-11 17:41:53
问题 I have a custom Git command implemented in Python that uses methods from the subprocess module to call git . I've noted that, depending on the method used, the output may or may not be colored, e.g.: import subprocess subprocess.run('git push origin --delete foobar', shell=True) print() print(subprocess.run('git push origin --delete foobar', shell=True, capture_output=True, encoding='utf-8').stderr, end='') Output: How to preserve colors in the captured output (both stdout and stderr)? 回答1:

How to preserve colors when capturing output from Git commands?

泪湿孤枕 提交于 2021-02-11 17:41:23
问题 I have a custom Git command implemented in Python that uses methods from the subprocess module to call git . I've noted that, depending on the method used, the output may or may not be colored, e.g.: import subprocess subprocess.run('git push origin --delete foobar', shell=True) print() print(subprocess.run('git push origin --delete foobar', shell=True, capture_output=True, encoding='utf-8').stderr, end='') Output: How to preserve colors in the captured output (both stdout and stderr)? 回答1:

Pyinstaller issue with subprocess.check_output

落爺英雄遲暮 提交于 2021-02-11 08:11:13
问题 When I have subprocess.check_output function in mycode and I generate an .exe file using pyinstaller with python pyinstaller.py --noconsole -F myprogram.py process stop to work, otherwise every thing is ok! Do you know any solution with pyinstaller or replace subprocess library with some thing else? 来源: https://stackoverflow.com/questions/18613642/pyinstaller-issue-with-subprocess-check-output