Submit jobs with numeric arguments to QSUB using Python

I want to run a python function,say my_fun(x1,x2), on different nodes of cluster with SGE (QSUB). I created a script which takes in the numeric arguments from the command line, so when running locally, I'd call it as python

How to print a statement on one line

I am unable to print an output statement in a single line from cli. The line breaks down into 3 lines. I tried printing it using print function and then tried print with a comma like print "......", and now I am using format style but none of th

Pass arguments to python functions using a subprocess

If I have a function in a file like this: def foo(): print 'foo' foo() I can call this file from another one: import subprocess['python', '']) But can if the function needs arguments: def foo(foo_var): print foo_var Can I

subprocess.Popen: Separate stdout / stderr but keeping order

How do I get the output from a command using subprocess.Popen and have separate callbacks for stdout and stderr, but ensure that those callbacks are called in the order that the lines came from the process? If I didn't care about separating out STDOU

Journaling children in a supervisor subprocess

My system is composed of a python application that is launched from supervisord. Let's call it A. A launches a subprocess B to do some of its task. Both A and B are coded in Python and use the standard logging module to output messages to the console

Print the password prompt using the Python subprocess

If I run a terminal command from Python using subprocess, how do I print the password prompt? I have a Python script that asks users to authenticate via Kerberos. My program is basically this: import subprocess def kinit(): kinit = "kinit -f" pr

Popen.communicate () launches UnicodeDecodeError

I have this code: def __executeCommand(self, command: str, input: str = None) -> str: p = sub.Popen(command, stdout=sub.PIPE, stderr=sub.PIPE, stdin=sub.PIPE, universal_newlines=True) p.stdin.write(input) output, error = p.communicate() if (len(error

How can I convert .tar to .tgz

I'm trying to compress some files with python. I'm using subprocess, the problem is that I don't know how to compress all the files. Here is what I do: comand = czf saveFolder = /home/albert/a.tgz temporal = /home/albert/test1["tar&q

Leave a bash shell started with Popen?

I can't figure out how to close a bash shell that was started via Popen. I'm on windows, and trying to automate some ssh stuff. This is much easier to do via the bash shell that comes with git, and so I'm invoking it via Popen in the following manner

How to insert the string value into the sqlite database?

The following code shows error import sqlite3 as lite import sys con = lite.connect('test.db') url= with con: cur = con.cursor() cur.execute("CREATE TABLE info(Id INT, Url_Name varchar(55))") cur.execute("INSERT INTO in

How to do a timeout using python 2.7.6?

This has probably been asked but I cannot find anything regarding a timeout when using python 2.7A simple way I've always done timeouts with 2.7 is utilizing subprocess.poll() alongside time.sleep() with a delay. Here's a very basic e

How can I kill omxplayer by Python Subprocess

I'm playing with my Raspberry Pi GPIO. I connect 4 switch to GPIO. I want to realize the function is While hold switch 1. Stop the current movie, Play M01.mp4. While hold switch 2. Stop the current movie, Play M02.mp4. ... If no switch was holded, pl

Python console and Ping text output, including \ n \ r

This question already has an answer here: Convert bytes to a string? 13 answers I dont know what is happening, but when I am printing to the console or to a text file, the newline (\n) is not functioning but rather showing in the string. Any idea how

Subprocessing pipe written in a file malfunction

Executing this in shell gets me tangible results: wget -O c1 --no-cache "" | sed "1,259d" c1 | sed "4,2002d" Doing this in Python gets me nothing:"wget -O c1 --no-cache \&q

Python - Adding a variable to

I'm trying to write a simple program in Python that takes all the music files from my Downloads folder and puts them in my Music folder. I'm using Windows, and I can move the files using the cmd prompt, but I get this error: WindowsError: [Error 2] T

Easier way to read / gunzip a big python file

So I have some fairly gigantic .gz files - we're talking 10 to 20 gb each when decompressed. I need to loop through each line of them, so I'm using the standard: import gzip f =, 'r') for line in f.readlines(): #(yadda yadda) f.

How to get a sub-process output during its operation?

I've got 2 files and, like below: #!/usr/bin/python import logging import subprocess import sys logging.basicConfig(level=logging.INFO) def forever(): cmd = [sys.executable, ''] while 1: try: print 'running new in

subprocess.Popen with a unicode path

I have a unicode filename that I would like to open. The following code: cmd = u'cmd /c "C:\\Pok\xe9mon.mp3"' cmd = cmd.encode('utf-8') subprocess.Popen(cmd) returns >>> 'C:\Pok×™mon.mp3' is not recognized as an internal or external comm

python block common subprocess ()

I am using the subprocess module to call an external program (plink.exe) to log-in to a server; but when I call communicate to read the output, it is blocking. The code is below: import subprocess process = subprocess.Popen('plink.exe [email protected]