OpenShift and MacOSX

If I wanted the least amount of trouble I would probably use OpenShift on a Fedora laptop or a RHEL6 server.

Since I always give myself a challenge, I decided to use MacOSX to work with OpenShift. Not that it is a bad idea but it gives additional challenges I did not expect. There is always something positive about these challenges. When the basic things don’t work you have to learn about them and how everything is setup. It is always the best setup to learn. Certainly a quick success on that aspect.

Installing the rhc tools to create a domain and app on openshift requires that you have XCode installed. Only $5 to get the app from the Mac App Store but I did not know that it was installing an installer. Once I learned that I needed to install from the installation I was golden to get something done. So I had a relatively empty application from the WSGI template setup on my MacBook Air.

It is great to code on the laptop but sometimes I prefer to use the iMac with the bigger screen and more comfortable setup. I tried to simply do a git pull to get the repo but it would always fail on me. After getting some help from the OpenShift Express Forums I learned that I needed to copy the files from .ssh that were created with the rhc tools. The config and libra_* files were copied and my git pull worked as it should.

Basic things but it is great when it works and that you have learned where things are.

Now I have this great idea that I should try to put Spring Python in OpenShift Express. Looking for more learning, I guess.

Advertisements

Learning Python

Learning Python is a lot more fun than I anticipated.

I think that the fun comes from a no expectation mentality and that everything I do with python is currently simple and helps greatly to automate some boring tasks.

I am not sure that I can complain about the fact that from one version to an other the changes are sometimes drastic and being able to understand and find the differences is sometimes more work that I would like. This issues comes from the fact that RHEL5 has Python 2.4 and that my other platforms have Python 2.7.

Today I was trying to understand how to pass a datetime to a xmlrpc server and some functionality was introduced in 2.5 (allow_datetime). It took me 20-30 minutes to understand why it was not working on RHEL5.

As any good learning I am making many errors in small scripts so I hopefully avoid when the real apps come around.

Date and Time calculation simplified with Python

When looking at java garbage collection logs you only get logs with a time stamp in seconds from the start of the JVM. After a few days of running the JVM it is difficult to remember when it started and when is the event your are looking at from. I was looking for a quick way to calculate the time. Python has some nice facilities built-in to help with that task. Here is what I do from the command line to figure out the last time it was started:

[bash]$ python
>>> from datetime import datetime
>>> from datetime import timedelta
>>> datetime(2009,2,9,10,48) – timedelta(seconds=159565)
datetime.datetime(2009, 2, 7, 14, 28, 35)

The datetime object is initialized with the date I want. In this case it was February 9, 2009 at 10:48. The timedelta object is initialized with a number of seconds but it could be days or min.

Very quick and convenient.