background preloader

Python

Facebook Twitter

Docker

Documentation Référence. Frameworks. Modules Packages. Snippets / tips. Twitter stream, bot. Python. All Python CGI scripts on dreamhost MUST... end in ".py" (NOTE: ".cgi, .fcgi" works as well). Have #! /usr/bin/python in the very first line of the file (NOTE: #! /usr/bin/python2.x or #! /usr/bin/env python2.x will work as well). be marked as executable: chmod 755. use UNIX style newlines, not Windows [1]. If you want to view printed output from your Python code, you must print print "Content-type: text/html\n\n" as the first line of output. The current deployment situation on Dreamhost involves either using CGI, which is very slow and not really an option if you're using a framework, or FastCGI, which is a bit faster, and uses mod_fcgid. Python-specific deployment options are available. DreamHost has begun upgrading servers to Python 2.6.6 as of February 2012, but many servers are still using 2.5.2. Installing Custom Modules Since you do not have root access, installing your python modules to the default Python path will not work.

Virtualenv Building a custom version of Python . bash . #! #! Installing Python 2.6, virtualenv, and virtualenvwrapper on Dreamhost. Late last year, I set out to get some python apps running on my dreamhost account, previously I maintained this stuff on an ec2 ubuntu instance, so I could do whatever I wanted there. But ec2 is expensive and dreamhost is cheap, so I made the move. Update May 15, 2010: Thanks to Tommaso Lanza, who, has written a shell script to automate this installation, which now includes mercurial, he has also left a few notes in the comments. Use at your own risk!. Python I thought all I would need to do is compile Python and get virtualenv running, but there was a little more to it, because as soon as I compiled Python I received the following warning: This doesn’t mean it didn’t compile, but it means those modules were not compiled in. I really wanted readline, and thought it would be a good idea to have bz2.

Without documenting my errors along the way, here is how I installed Python 2.6.4 on dreamhost: First give yourself a place to install the necessary packages, and then a place to compile them. Playing With Python And Gmail. In addition to its web interface Google also provides access via IMAP. The python imaplib module defines three classes, IMAP4, IMAP4_SSL and IMAP4_stream, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in RFC 2060. The IMAP4 class implements the actual IMAP4 protocol. The connection is created and protocol version (IMAP4 or IMAP4rev1) is determined when the instance is initialized.

Getting started with Python Imaplib To start with, we will create a simple python program to login to Gmail via IMAP. IMAP4.IMAP4_SSL is a subclass derived from IMAP4 that connects over an SSL encrypted socket (to use this class you need a socket module that was compiled with SSL support). If authentication is successful the output will be: OK ['username@gmail.com authenticated (Success)'] As part of our exercise we will be writing may usefull functions. Add the below function to our pygmial.py Use: This will output your Gmail mailboxes.