python

Python os.system() - does it leave history (bash_history,etc.) ?

Hello, I'm using os.system() to invoke some openssl command from my ubuntu box. I specify password in line so it looks like: //python code os.system("openssl enc -aes-256-cbc ... -k password") I need to know if is possible to track this command in some shell / bash history file (as it is possible if I type this command into terminal ...

python 2.7 / exec / what is wrong?

Hello, I have this code which runs fine in Python 2.5 but not in 2.7: import sys import traceback try: from io import StringIO except: from StringIO import StringIO def CaptureExec(stmt): oldio = (sys.stdin, sys.stdout, sys.stderr) sio = StringIO() sys.stdout = sys.stderr = sio try: exec(stmt, globals()...

CVS checkout based on a file

I want to checkout a bunch of files from a CVS server. Is there a way I can pass cvs command a file name which contains files I want to checkout Is there another way of accomplishing that ? ...

Using IPython from the Python shell like `code.interact()`

Is it possible to use the IPython shell from an existing Python shell, as a shell-inside-a-shell, similarly to the built-in code.interact()? ...

Matplotlib - changing plot size within rectangular grid.

I have 4 subplots (created by using add_subplot) organised in a 2x2 rectangular grid. The two in the second row do not need to take up as much space and I wish to change it such that the top row takes up two thirds of the space and the bottom row takes up the remaining third. I've found that you can arbitrarily place subplots by creatin...

python url regexp

Hi all. I have a regexp and i want to add output of regexp to my url for exmaple url = 'blabla.com' r = re.findall(r'<p>(.*?</a>)) r output - /any_string/on/any/server/ but a dont know how to make get-request with regexp output blabla.com/any_string/on/any/server/ ...

Twisted: degrade gracefully performance in case reactor is overloaded?

Is it somehow possible to "detect" that the reactor is overloaded and start dropping connections, or refuse new connections? How can we avoid the reactor being completely overloaded and not being able to catch up? ...

Cherokee + uWSGI + Pylons

I have successfully deployed a Django app with uWSGI + Cherokee. However, I want to experiment with Pylons before I go decide on Django. So far I have followed the instructions/recommendations here: http://stackoverflow.com/questions/2217679/deploying-pylons-with-uwsgi Paster serve works without a hitch. But when I try to serve via uWS...

i need to verify a zope tree with a selenium right click

I'm testing a jtree made in zope that needs to be clicked with right_click, i know that the command for left click with selenium in python is selenium.click ,but i don't know any for right_click ,can anyone help me please. i would love to know if there is a solution in python not another languages please. ...

Django-Haystack/Whoosh - Rebuild Index Error

Python 2.5, Django 1.2.1, most recent haystack, most recent whoosh This is my first delve into Django-Haystack. I was following the "Getting Started" guide from Haystack and everything seemed to be going along fine, until I went to build the index. So, running "manage.py rebuild_index" shot this back at me: Traceback (most recent call...

Getting ready to convert from Python 2.x to 3.x

As we all know by now (I hope), Python 3 is slowly beginning to replace Python 2.x. Of course it will be many MANY years before most of the existing code is finally ported, but there are things we can do right now in our version 2.x code to make the switch easier. Obviously taking a look at what's new in 3.x will be helpful, but what ar...

Where to manually install python files

I'm having trouble with setuptools in a larger project where a python package has to be "constructed" from several debian packages (each containing a subpackage of the "main" package). Thus we decided to install the files manully instead of using "setup.py install", but we are unsure of the location to use. We first used a directory in /...

Python: how to change (last) element of tuple?

The question is a bit misleading, because a tuple is immutable. What I want is: Having a tuple a = (1, 2, 3, 4) get a tuple b that is exactly like a except for the last argument which is, say, twice the last element of a. => b == (1, 2, 3, 8) ...

Effectively using Google App Engine to send lots of emails using PHP?

I currently have a client website on the Grid server on MediaTemple that will be moved to a Virtual Private Server soon. Currently it's using some hacks to trickle his massive email sendouts using cron jobs and queuing with the database (to avoid going over the limit MediaTemple set). We can't use third party solutions (like MailChimp ...

Spurious failures in django.contrib.messages.tests when running manage.py test

I've recently added authentication (via django.contrib.auth of course) to my application, along with appropriate "signin"/"signup" links to my base.html. The problem comes when I run manage.py tests, and I get 4 failures, all from django.contrib.messages.tests: ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.co...

using Python to import a CSV (lookup table) and add GPS coordinates to another output CSV

So I have already imported one XML-ish file with 3000 elements and parsed them into a CSV for output. But I also need to import a second CSV file with 'keyword','latitude','longitude' as columns and use it to add the GPS coordinates to additional columns on the first file. Reading the python tutorial, it seems like {dictionary} is what ...

Is twisted.internet.reactor global?

For example, if one application does from twisted.internet import reactor, and another application does the same, are those reactors the same? I am asking because Deluge, an application that uses twisted, looks like it uses the reactor to connect their UI (gtk) to the rest of the application being driven by twisted (I am trying to under...

c#: which csv reader should i use?

i have a python script that i need to convert to c#. the main thing that the python does is it takes a csv file, does a bunch of calculations to it, and creates csv subsets. which csv library do you recommend that i use for this type of work? ...

What's the simplest way to subtract a month from a date in Python?

If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's the simplest way t...

A simpler i18n for Python/Django

Hi all, My question is regarding i18n in Python. From what I understand, it involves: Create a messages file per language (ONLY ONE?!). in this file, each message will be of the format English message here Message en Francais ici (yea crappy french..) then have this file compiled into another faster binary format repeat for all othe...