subprocess

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

回眸只為那壹抹淺笑 提交于 2020-05-16 09:46:06
问题 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

Python subprocess module: How to reopen PIPE?

空扰寡人 提交于 2020-05-16 02:22:31
问题 I have a piece of code that needs to run node js. In order to write to the file for node js to recieve the command, I use the following code: def execute(comm): file_number = proc.stdin.fileno() file = open(file_number, "w+") file.write(comm) file.close() execute("""console.log("hi");""") execute("""console.log("bye");""") However, when I run execute a second time, I get the following error: OSError: [WinError 6] The handle is invalid What does this error mean and how do I fix it? Here is the

Python subprocess module: How to reopen PIPE?

橙三吉。 提交于 2020-05-16 02:21:55
问题 I have a piece of code that needs to run node js. In order to write to the file for node js to recieve the command, I use the following code: def execute(comm): file_number = proc.stdin.fileno() file = open(file_number, "w+") file.write(comm) file.close() execute("""console.log("hi");""") execute("""console.log("bye");""") However, when I run execute a second time, I get the following error: OSError: [WinError 6] The handle is invalid What does this error mean and how do I fix it? Here is the

Python subprocess module: How to reopen PIPE?

不问归期 提交于 2020-05-16 02:21:26
问题 I have a piece of code that needs to run node js. In order to write to the file for node js to recieve the command, I use the following code: def execute(comm): file_number = proc.stdin.fileno() file = open(file_number, "w+") file.write(comm) file.close() execute("""console.log("hi");""") execute("""console.log("bye");""") However, when I run execute a second time, I get the following error: OSError: [WinError 6] The handle is invalid What does this error mean and how do I fix it? Here is the

Multithreaded Perl script leads to broken pipe if called as a Python subprocess

浪尽此生 提交于 2020-05-15 09:36:10
问题 I am calling a Perl script from Python 3.7.3, with subprocess. The Perl script that is called is this one: https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/tokenizer.perl And the code I am using to call it is: import sys import os import subprocess import threading def copy_out(source, dest): for line in source: dest.write(line) num_threads=4 args = ["perl", "tokenizer.perl", "-l", "en", "-threads", str(num_threads) ] with open(os.devnull, "wb") as devnull: tokenizer =

Proper way of re-using and closing a subprocess object

笑着哭i 提交于 2020-05-13 05:06:39
问题 I have the following code in a loop: while true: # Define shell_command p1 = Popen(shell_command, shell=shell_type, stdout=PIPE, stderr=PIPE, preexec_fn=os.setsid) result = p1.stdout.read(); # Define condition if condition: break; where shell_command is something like ls (it just prints stuff). I have read in different places that I can close/terminate/exit a Popen object in a variety of ways, e.g. : p1.stdout.close() p1.stdin.close() p1.terminate p1.kill My question is: What is the proper

python subprocess.Popen hanging

纵然是瞬间 提交于 2020-05-12 12:05:08
问题 child = subprocess.Popen(command, shell=True, env=environment, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, ) subout = "" with child.stdout: for line in iter(child.stdout.readline, b''): subout += line logging.info(subout) rc = child.wait() some times (intermittently) this hangs forever. not sure if it hangs on iter(child.stdout.readline) or child.wait() i ps -ef for the process it Popens and that process no longer exists my guess is that it has do with bufsize

Wait for song played outside of python to finish

℡╲_俬逩灬. 提交于 2020-04-30 07:28:47
问题 I am trying to wait for a song to finish to play the next song. I am running python 3.4 on windows but am trying to be able to use it on Linux ( raspberry pi ). I have used the command subprocess.call([PLAYER, SONG]) to open the mp3 file. It plays in vlc and then stops. I know that I have not incorporated anything for the program to tell python when its finished. That's where you guys come in. I want to find a command that will wait until the song has finished and when the song is finished,

Wait for song played outside of python to finish

一世执手 提交于 2020-04-30 07:24:43
问题 I am trying to wait for a song to finish to play the next song. I am running python 3.4 on windows but am trying to be able to use it on Linux ( raspberry pi ). I have used the command subprocess.call([PLAYER, SONG]) to open the mp3 file. It plays in vlc and then stops. I know that I have not incorporated anything for the program to tell python when its finished. That's where you guys come in. I want to find a command that will wait until the song has finished and when the song is finished,

Running console window in background for GUI using tkinter on Windows 10

泪湿孤枕 提交于 2020-04-30 06:37:27
问题 So I have this GUI that I made with tkinter and everything works well. What it does is connects to servers and sends commands for both Linux or Windows. I went ahead and used pyinstaller to create a windowed GUI without console and when I try to uses a specific function for sending Windows commands it will fail. If I create the GUI with a console that pops up before the GUI, it works like a charm. What I'm trying to figure out is how to get my GUI to work with the console being invisible to