August 2009
5 posts
2 tags
FTP in Python
In Python, to create and maintain a FTP communication, the ftplib or urllib (explained in a future post) can be used. Creating a FTP connection from ftplib import FTP try: conn = FTP('almightybuserror.com') except: print "Could not connect to almightybuserror.com." return Logging in… For anonymous log in: try: conn.login() except: print "No anonymous connections...
Aug 25th
2 tags
HTTP in Python
To create and HTTP connection we use the httplib module which provides some simple yet effective methods to create a connection and send requests to an HTTP server. The module urllib can also be used and is easier, does, however only perform GET requests (explained in a future post). Creating a connection To create a connection, the method HTTPConnection does the job. For example: import...
Aug 22nd
Scripts and Tools Repository
I recently created a github repository for my tools, it can be found here. Feel free to check it out!
Aug 13th
Aug 4th
4 tags
Snippet.Py: Getting an image resolution
Using PIL (Python Image Library) it is possible to get the width and height of a image using the property size. The following example will take an undefined number of arguments and print all the resolutions: import Image import sys def main(): argv = sys.argv[1:] if (len(argv) == 0): print "No file given!" else: for name in argv: img = Image.open(name) ...
Aug 3rd