Archive for Python

5

May

Test post-wordpresslib

Below was a test post by the wordpresslib library, a series of classes and methods written in python to manipulate posts on a Wordpress blog. To drop a hint, this is my next project I plan to work on =) I hope to get a simple blogging tool written in PyObjC over the summer.

Python is the best programming language in the earth !

14

Aug

The ultimate Cellphone Utility

As the last post states, I finally splurged and bought a Katana II. But then there came a problem. Could I get the pictures off this phone without paying for a monthly cost by Sprint? Viola! There is a solution!

BitPim is an application that takes CDMA based phone’s information and saves it on your computer in an ordered view. You can access your PhoneBook, multiple media options, your cell’s Calendar, Todos, your SMS messages, Call History, and view your phone’s filesystem. It is THE FREE, open source utility for your cell! Bitpim supports transferring information to and from your phone, and provides an easy way to access information from your computer. It supports Mac, Windows, and Linux, because its written in Python and its interface is written in WxPython, the Python library to access the wxWidgets C++ library. If your not picky on Cocoa based applications, this is the choice for you!

14

Jul

FinkCommander: not dead.. yet.

The problem with the current FinkCommander is that I’m trying to interface a Perl program (fink) with python. The only way to do this properly is to call the perl command a bunch and hope that it doesn’t cause your processor usage to spike like no tommorrow. So, the best and most logical thing is to rewrite FinkCommander with CamelBones. This way, I can interact directly with fink’s classes and display them with a cocoa window! The other problem is, I don’t know perl all that well, but then again, I didn’t know pyobjc/objc that well either.

16

Jun

Python Exceptions

Programming is by far, a journey. Not like the shoe store, but an actual journey. When working on a new version of PyLauncher, 2.0, I came across a problem. How can I create my own custom NSRunAlertPanel when an error, or exception in Python, has occurred? Behold! There is a solution!

One of the best parts about exceptions are that you can declare what you want to Python to do for each exception that could happen. Let’s look at an example:

#!/usr/local/bin/python2.4
import ofs
import sys
from AppKit import *

I tried to import a module that wasn’t there, and got an error like this:

Traceback (most recent call last):
  File "
“, line 1, in -toplevel-
    import ofs
ImportError: No module named ofs

Whoops! Now, to make this look better or make it easier on people who are novices, you can control what to do if Python encounters this exception:

try:
	import ofs
except ImportError:
	print "Module ofs not found"

Viola! Now, here’s what I wrote to incorporate a custom NSRunAlertPanel if an exception occured:

from AppKit import *
from Foundation import *

try:
	return app(x).launch()
except:
	NSRunAlertPanel("Title of Window", "Message", "Default Button", "Other buttons, can be None if you want", "other stuff or None")