Intercepting stdout of a subprocess while it is running

If this is my subprocess: import time, sys for i in range(200): sys.stdout.write( 'reading %i\n'%i ) time.sleep(.02) And this is the script controlling and modifying the output of the...

Convert bytes to a string

I'm using this code to get standard output from an external program: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] The communicate() method...

Getting realtime output using subprocess

I am trying to write a wrapper script for a command line program (svnadmin verify) that will display a nice progress indicator for the operation. This requires me to be able to see each line of...

How can I specify working directory for popen

Is there a way to specify the running directory of command in Python's subprocess.Popen()? For example: Popen('c:\mytool\tool.exe', workingdir='d:\test\local') My Python script is located in...

How to run multiple commands in one process using Popen?

I want to open a process and run two commands in the same process. I have : cmd1 = 'source /usr/local/../..' cmd2 = 'ls -l' final = Popen(cmd2, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT,...

How to pipe binary data into numpy arrays without tmp storage?

There are several similar questions but none of them answers this simple question directly: How can i catch a commands output and stream that content into numpy arrays without creating a temporary...

Interactive input/output using Python

I have a program that interacts with the user (acts like a shell), and I want to run it using the Python subprocess module interactively. That means, I want the possibility to write to standard...

Python: subprocess.popen: read each line of output

I'm having trouble reading my subprocess output by line. The subprocess simply greps the contents of a file against another file. The output, which should be a two column file, prints to stdout...

subprocess.Popen Argument list is too long

I use proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ...

After starting process, how to get parent's PID in the child?

In Python, I start a new process via Popen(), which works fine. Now in the child process I want to find the parent's process ID. What is the best way to achieve this, maybe I can pass the PID via...

OSError: [WinError 193] %1 is not a valid Win32 application

I am trying to call a Python file "hello.py" from within the python interpreter with subprocess. But I am unable to resolve this error. [Python 3.4.1]. import subprocess ...

Python subprocess.stdout.readline() hang

I try simple code using subprocess on python, while calling process.stdout.readline() it will hang on it. How to solve this problem? While trying fcntl for nonblock in the output I got blank...

PyQt: Force popup window to be at the front

I have a simple popup about window in my application. It has a button "Ok" which closes the about window. I want to make that window exitable only via the "Ok" button so you wouldn't be able to...

c++ system() raises ENOMEM

This question is a M(not)WE of this question. I wrote a code that reproduces the error: #include <cstdlib> #include <iostream> #include <vector> int *watch_errno = __errno_location(); int...

How to run a background process and do *not* wait?

My goal is simple: kick off rsync and DO NOT WAIT. Python 2.7.9 on Debian Sample code: rsync_cmd = "/usr/bin/rsync -a -e 'ssh -i /home/myuser/.ssh/id_rsa' {0}@{1}:'{2}' {3}".format(remote_user,...

pg_dump & pg_restore password using python module subprocess

Problem: Use the PSQL pg_dump and pg_restore in a Python script and using the subprocess module. Background: I am using the following python 2.7 script from the localhost (i.e. Ubuntu 14.04.5 LTS)...

Why can't the Python command "subprocess.Popen" find the jar file to run?

I'm trying to run code from this repo: https://github.com/tylin/coco-caption, specifically from https://github.com/tylin/coco-caption/blob/master/pycocoevalcap/tokenizer/ptbtokenizer.py, line...

Getting 'OSError: [Errno 2] No such file or directory' on popen when trying to run mypy

Hello stack overflow users, I'm having a great deal of difficulty trying to get mypy to work correctly with Popen. Essentially I'm writing a test suite that utilizes mypy but cannot seem to get...

Python subprocess.Popen() not running command

I'm trying to use subprocess.Popen() to run a command in my script. The code is: output = Popen(["hrun DAR_MeasLogDump " + log_file_name], stdout=subprocess.PIPE, stderr = subprocess.PIPE,...

Python pickle error when using multiprocessing inside class method

In the class foo in foomodule.py below, I am getting an error in the run_with_multiprocessing method. The method breaks up the number of records in self._data into chunks and calls somefunc()...

Getting real time output from iperf3 using python's subprocess

This is a follow-on to: https://stackoverflow.com/questions/803265/getting-realtime-output-using-subprocess I'm trying to use subprocess to capture output from iperf3 in real time (using python...

Kernel Error using Julia on Jupyter Notebook

Hi so I'm quite new with using Julia and Notebook. When I first downloaded Julia, everything worked great, but then suddenly the kernel said it was dead and I couldn't get it to work again...

Get a List of Child Processes from Parent Process in C and C++ (Cross-Platform, No Command Line)

How to get a list of child processes id's from a given parent process id in a cross-platform manner in C and C++ without using command line? I provided an answer myself below which covers Win32,...

I am getting this error while converting .m4a files to .mp3

I am getting this error while runnthe script as shown TEST.py from pydub import AudioSegment wav_audio = AudioSegment.from_file("Broken Summer.m4a", format="m4a") wav_audio.export("audio1.mp3",...

How to efficiently run multiple Pytorch Processes / Models at once ? Traceback: The paging file is too small for this operation to complete

Background I have a very small network which I want to test with different random seeds. The network barely uses 1% of my GPUs compute power so i could in theory run 50 processes at once to try...

Flutter and linux

I want to create a flutter plugin for Linux. I don't know very well C++ but I want to try. Is it a good idea to create shell command in C++ ? For example if I need Bluetooth devices and I do auto...

Can't send bluetooth from Kivy App on Android

I put together a Kivy App that gets the coordinates from a user touch and sends them over bluetooth to an arduino I am following the steps on how to handle bluetooth on android listed in the link...

Ansible cannot pickle 'module' object

Running the playbook with $ ansible-playbook test-playbook.yml Getting error response ERROR! Unexpected Exception, this is probably a bug: cannot pickle 'module' object Also have tried shell:...

AttributeError: Can't pickle local object 'pre_datasets.<locals>.<lambda>' when implementing Pytorch framework

I was trying to implement a pytorch framework on CNN. I'm sure the code is right because it's from a tutorial and it works when I ran it on Jupyter Notebook on GoogleDrive. But when I tried to...

Increase in python scripts execution time when using ProcessPoolExecutor

I am observing increase in execution time of python script when I trigger parallel instances of it using process pool executor on a 56 core machine. The script abc.py imports a heavy python...