All articles, tagged with “python”

Rocking Python in Netbeans

I’m a hard core vi user. You just can’t beat it for a quick file edit. (This is where my friend, Jack Lunn, would argue that Emacs is better… but I think we can agree that both are faster to crank up than most IDEs.) Recently, I’ve switched to Netbeans for Java development at work. I had been using IntelliJ and it almost drove me insane. (See my post about the Corrupted Cache.) Netbeans has been working well for me, though. (It’s no vi, but it does have features that are very useful when working with large projects.) With Netbeans 6.5, you can get Python support. I’ve been using this for a few weeks now. It’s nice to have all of my Java/Python code open in one IDE. This morning, I ran across a screencast showing some upcoming code coverage support for Python in Netbeans. This looks impressive.

DjangoCon 2008 Videos

I’ve been reading Simon Willison’s blog for quite a while now. He frequently posts interesting ideas and links. Yesterday, I noticed that he had a link to videos from DjangoCon 2008 on YouTube. So far, I’ve watched Schema Evolution and Reusable Apps. I learned a lot from both videos. I’ve only been working with Django for a few months (mostly for this blog) and I’m really enjoying it. I think it’s really cool that they’ve posted videos from the Django conference so people that couldn’t attend (the conference or a particular talk) can check them out (and learn something). Living in rural South Carolina, there are not (currently) a lot of local opportunities to exchange ideas with other python developers. I hope that more (python related) conferences follow Django’s lead and post conference videos. Great job!

Rocking Byteflow: Wordpress to Byteflow Migration

Rock the Fat Knot was recently migrated from WordPress to Byteflow. This migration also included moving the site to a Joyent Accelerator running OpenSolaris. I wanted a good way to develop and test things out locally, so I created an OpenSolaris virtual machine on my Mac using VirtualBox. I used an OpenSolaris 2008.05 disk for the install. It’s a newer build than what’s running in my Accelerator, but I’m OK with a close approximation for this work. I was more concerned with running the same Python, mod_python, Apache, and MySQL builds. I followed this guide to get OpenSolaris up and running in a virtual machine. I had difficulties getting the VM’s network connectivity working. I tried changing the VM’s network adapter to “Intel PRO/1000 MT Desktop (NAT)” and it worked. (Note: I’m using about a one year old Mac Mini. PC Net may work for others.) To get name resolution working, I had to add the entries from my mac’s /etc/resolv.conf to the /etc/resolv.conf in the VM. I wanted to be able to access my Apache test server from the Mac, so I used VirtualBox’s VBoxManage program to setup some port forwarding. I ended up mapping host ports 2222 for SSH and 4444 for http (no particular reason for choosing those ports). I called my VM “OpenSolaris2008.05”, so I ran these commands from a terminal to configure the port mapping.

VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/httpd/GuestPort" 80
VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/httpd/HostPort" 4444
VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/httpd/Protocol" TCP

VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata "OpenSolaris2008.05" \
           "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/Protocol" TCP

These commands map port 4444 on the Mac to port 80 of the OpenSolaris VM. Likewise, port 2222 on the Mac is mapped to port 22 of the VM. Now, I can test the site from Safari and Firefox on the Mac by navigating to http://localhost:4444. I can also ssh to the vm using a command like this:

ssh -oPort=2222 vmuser@localhost 

With a VM up and running, I exported my Wordpress blog data to a WordPress eXtended RSS (WRX) file. Using WXRImporter.py from Greg Heartsfield (see this thread on the byteflow-users list for usage), I imported my blog data in the WXR file into my byteflow database. To ensure that people didn’t lose my RSS feed, I added a few lines to my Apache configuration:

RewriteEngine On
#Redirect Wordpress RSS Feed to Byteflow
RewriteCond %{QUERY_STRING} ^feed=rss2$ [NC]
RewriteRule ^/$ feeds/rss/blog? [R=301,L]

This ensures that people using my old feed URL still find the latest posts. I also added this rewrite rule in my dev VM for sanity (I seemed to be getting strange name resolution problems without it):

RewriteCond %{HTTP_HOST} ^localhost$ [NC]
RewriteRule ^(.*)$ http://127.0.0.1$1 [R=301,L]

The dev VM setup has been working out very well for me. So far, I’ve not run into any issues when deploying changes out to my Accelerator. Testing things out locally, in a VM that’s pretty close to my Accelerator, is very nice. I’ve also been using VirtualBox at work to run a Windows VM. It’s shaping up to be a very nice product. It includes a nice set of command line utilities. Anyone out there got tips for developing/testing apps that are deployed on a Joyent Accelerator? I know Joyent probably wouldn’t mind selling you a development accelerator, too.

svcadm restart http

Happy 4th of July!

To celebrate Independence Day, rockthefatknot.com moved to a new home and got a new look. The site is now hosted by Joyent on a Joyent Accelerator. A while back, I posted about moving as much of my stuff to Python as possible. Now, rockthefatknot.com is running on byteflow (Byteflow is a blog engine that’s written in Python using Django.). I spent a couple of nights this past week working to migrate all of the posts over to byteflow. I got some help from the byteflow-users mailing list and used a handy script from Greg Heartsfield to migrate the data over. I setup an OpenSolaris VM in VirtualBox on my mac to handle all of the migration work. I’ll probably write up another post later with the technical details on the migration. Since the migration is complete, I’m going to celebrate!

All Things Pythonic

Several people have asked me what I’ve been doing with all my spare time now that I’ve stepped down from being a manager (I returned to a strictly engineering role)… Well, I’ve been spending more time with my wife (and our two dogs), eating dinner at a reasonable time and going to sleep at semi-reasonable times. I’ve also been spending a lot of time working with OpenSolaris (my new favorite x86 OS). ZFS and DTrace just plain rock. I’ve also been tinkering with Django. If you don’t know, Django is a dominant python framework for cranking out dominant web sites. I’ve been enjoying spending time working with it simply because it’s the exact opposite of some of the J2EE stuff I’ve been working with the past few years. I don’t need 1 or 2 GBs of RAM to edit a Django project nor do I need 4GB of RAM to run/debug it. I’ve finally decided that that all of my personal stuff is going to be done in just python. I’m going to be converting rockthefatknot.com over to Django in the coming months. I’m also going to be switching up from subversion to Mercurial (because it’s cool and also because it’s implemented in Python!)  After all, Python is the official language of The Markovian Powerhouse (Alex Markov).  Don’t worry — I’ll still be posting Fat Knots.  In fact, I’ve got a special treat coming soon:  Fat Knot Flashbacks…

JEPP

I’ve been working with JEPP this morning. A co-worker, Joe Grant, recommended it to me for cases where we have a need to run some of our Python based tools from Java. It turns out that it works pretty well and I think it may help us out with a few things at work. One thing that I was pleased to find came from this example:

dualmini:~/Work/jep-2.2 corbinbs$ cat test2.py
class Twig(Exception):
    pass

x = 1

if x == 1:
    raise Twig("I'm a pretty error message!")

dualmini:~/Work/jep-2.2 corbinbs$
dualmini:~/Work/jep-2.2 corbinbs$ java -jar jep.jar test2.py
jep.JepException: : I'm a pretty error message!
at jep.Jep.run(Native Method)
at jep.Jep.runScript(Jep.java:191)
at jep.Jep.runScript(Jep.java:167)
at jep.Run.run(Run.java:58)
at jep.Run.main(Run.java:153)
dualmini:~/Work/jep-2.2 corbinbs$

So, it looks like CPython exceptions bubble back up quite nicely. This will likely help us improve some of our error handling/reporting in cases where we’ve got Java tools/apps calling out to some of our Python tools. JEPP is definitely worthy of the “Rock The Fat Knot” stamp of approval.