python

werkzeug mapping urls to views (via endpoint)

Starting using werkzeug, i try to map urls (from a file urls.py) to views (from a folder views and then in different files to manage differents kinds of view), my folder organisation looks like that : myapp/ - - - application.py - - - urls.py - - - views/ - - - - - - __init__.py - - - - - - common.py - - - - - - places.py - - - - - -...

Point Django at different Python version

Django application requires a later version of Python. I just installed it to 2.5 (from 2.4) and now when I do a python at the command line, it says 2.5.2. Having said that, Django still says Python Version: 2.4.3. How do I correct this? I've rebooted / restarted / redeployed to no avail. ...

Check whether a connection exists to a remote host using paramiko

I m using single object of paramiko.SSHClient() for executing a command on a remote machine. so i m using ssh.exec_command(cmd) But if the connection to remote host is lost, ssh.exec_command hangs up. Is there a way to check for connection existence before ssh.exec_command()???? ...

When I send a post request in python...how do I...

Have a "check"? For example... I would have a dictionary with the parameters to sent to the POST. params = {'text':'how are you?', 'subject':'hi'} then I would have opener.open('theurl',urllib.urlencode(params)) The question is...those parameters work well with text-boxes, since I just put the value in there. How about radio but...

Python: Get list of all classes within current module

I've seen plenty of examples of people extracting all of the classes from a module, usually something like: # foo.py class Foo: pass # test.py import inspect import foo for name, obj in inspect.getmembers(foo): if inspect.isclass(obj): print obj Awesome. But I can't find out how to get all of the classes from the cu...

python and Oracle

I would like to be able to connect to Oracle 10.1.0.2.0 (which is installed on different machine) via python. My comp is running on Ubuntu 9.04 Jaunty with Python 2.6 installed. I have downloaded and unpacked instantclient-basic-linux32-10.1.0.5-20060511.zip , set LD_LIBRARY_PATH and ORACLE_HOME to point to the directory where I unpack...

ssh client using python socket

how can i write ssh client using python socket? Subhan ...

Python SSH paramiko probelm - ssh from inside of ssh session

import paramiko client = paramiko.SSHClient() client.load_system_host_keys() ip = '192.168.100.6' client.connect(ip, username='root', password='mima') i, o, e = client.exec_command('apt-get install sl -y --force-yes') print o.read(), e.read() client.close() i used this example.. it is working fine but i want after login server1 to log...

Accessing a Python traceback from the C API

I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, it is sufficient to ext...

Python, thread and gobject

I am writing a program by a framework using pygtk. The main program doing the following things: Create a watchdog thread to monitor some resource Create a client to receive data from socket call gobject.Mainloop() but it seems after my program enter the Mainloop, the watchdog thread also won't run. My workaround is to use gobject.t...

import array in python

hi all, how can I import an array to python (numpy) from a file and that way the file must be written. For example, a matrix to and from that file type (extention). thanks for any response ...

Python and BeautifulSoup, not finding 'a'

Hey, Here's a piece of HTML code (from delicious): <h4> <a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Links with Anonymous Referers &amp; Anti-Bot Protection</a> <span class="saverem"> <em class="bookmark-actions"> <strong><a class="inlinesave action" href="/save?url=http%3A%2F%2Fimfy.us%2F&amp;tit...

How to import a file by its full path using C api?

Hello PyObject* PyImport_ImportModule( const char *name) How to specify a full file path instead and a module name? Like PyImport_SomeFunction(const char *path_to_script, const char *name) Thanks, Elias ...

Trouble Upgrading Python / Django on CentOS

As you can see by reading my other thread today here, I'm having some troubles upgrading Python. At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an application that requires 2.5 which has resulted in me installing that and getting into a whole load of mess. My original assumption...

Correct place to put extra startup code in django?

I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support. I'd rather our team be faced with a fatal error that they have to fix, rather than be able to ignore it. ...

Problem installing Shoutpy + Boost.python on opensolaris

Hi all, Im trying to install shoutpy on opensolaris 2009.6. It relies on boost.python. i've installed the boost_devel libraries from blastwave and linked /opt/csw/include/boost to /usr/include/boost . But when I try to easy_install shoutpy I get the following output munderwo@opensolaris-test1:/usr/include$ pfexec easy_install shoutpy S...

Microprocessor to RS-232 realtime plot using PySerial/Matplotlib?

Greetings! I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit http://openeeg.sourceforge.net) The analogue output is amplified and processed via an ADC (in an ATmega8 microcontroller) and is converted ...

Is there something like for i in range(length) in PHP?

In python we have: for i in range(length) What about in PHP? ...

os x python 2.6 bus error

i am getting weird python bus error when building a web app. http://pastie.org/714569 i am using python 2.6 from mac ports in osx snowleopart 10.6.2. i have done python_select and stuff. how to figure out what is going on? thanks ...

recursive function for a django model instance

i want to make message view show all other messages that led up to that message. the original message will not have a response_to value and should terminate the recursion. is there a better way to do this? (i'm looking at memory over speed, because a thread shouldn't typically be more than 10 - 20 messages long). def get_thread(msg,msg_...