53
votes
8answers
18k views

How to get console window width in python

Is there a way in python to programmatically determine the width of the console? I mean the number of characters that fits in one line without wrapping, not the pixel width of the window. Edit ...
53
votes
6answers
7k views

Why is printing to stdout so slow? Can it be sped up?

I've always been amazed/frustrated with how long it takes to simply output to the terminal with a print statement. After some recent painfully slow logging I decided to look into it and was quite ...
47
votes
7answers
64k views

What is the simplest way to SSH using Python?

What is the absolute simplest way to SSH to a remote server from a local Python (3.0) script, supply a login/password, execute a command and print the output to the Python console? I would rather not ...
38
votes
9answers
3k views

Get the Olson TZ name for the local timezone?

How do I get the Olson timezone name (such as Australia/Sydney) corresponding to the value given by C's localtime call? This is the value overridden via TZ, by symlinking /etc/localtime, or setting a ...
36
votes
14answers
23k views

mysql_config not found when installing mysqldb python interface

I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via ...
35
votes
6answers
5k views

Python subprocess.Popen “OSError: [Errno 12] Cannot allocate memory”

Note: This question was originally asked here but the bounty time expired even though an acceptable answer was not actually found. I am re-asking this question including all details provided in the ...
30
votes
14answers
10k views

cross platform IPC

I'm looking for suggestions on possible IPC mechanisms that are: cross platform (WIN32 and Linux at least) Simple to implement in C++ as well as the most common scripting languages (perl, ruby ...
30
votes
4answers
11k views

How to terminate a python subprocess launched with shell=True

I'm launching a subprocess with the following command: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) However, when I try to kill using: p.terminate() or p.kill() The command ...
29
votes
7answers
15k views

Getting MAC Address

I need a cross platform method of determining the MAC address of a computer at run time. For windows the 'wmi' module can be used and the only method under Linux I could find was to run ifconfig and ...
29
votes
4answers
9k views

How to make a python, command-line program autocomplete arbitrary things NOT interpreter

I am aware of how to setup autocompletion of python objects in the python interpreter (on unix). Google shows many hits for explanations on how to do this. Unfortunately, there are so many ...
27
votes
8answers
23k views

Take a screenshot via a python script. [Linux]

I want to take a screenshot via a python script and unobtrusively save it. I'm only interested in the Linux solution, and should support any X based environment.
27
votes
7answers
26k views

How to make a python script run like a service or daemon in linux

I have written a python script that checks a certain e-mail address and passes new e-mails to an external program. How can I get this script to execute 24/7, such as turning it into daemon or service ...
27
votes
7answers
8k views

Cross-platform space remaining on volume using python

I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is ...
24
votes
1answer
14k views

Python script as linux service/daemon

Hallo, I'm trying to let a python script run as service (daemon) on (ubuntu) linux. On the web there exist several solutions like: http://pypi.python.org/pypi/python-daemon/ A well-behaved Unix ...
24
votes
3answers
646 views

Does anyone know an xlib function to trap a keypress event without losing the original focus?

Does anyone know an xlib function to trap a keypress event without losing the original focus? (or "to use XGrabKey() without generating Grab-style focusout"?) The XGrabKey will lose focus on key ...

1 2 3 4 5 165
15 30 50 per page