I have been spending the past couple of weeks wondering about what I would write about next. As a manager, I don’t get a lot of time to dig into the deep technical issues like I used to, and I miss that. So I had some spare time on my hands, and I wanted to do something different that would help me learn something, and also be useful. I am picking up Python, so I figured that something useful in Python would be good.
As always, the code in this post is derived from examples from Jazz.net as well as the blog posts I mention. The usage of code from that example source code is governed by this license. Therefore this code is governed by this license, which basically means you can use it for internal usage, but not sell it. Remember that this code comes with the usual lack of promise or guarantee. I did all of this against a v4.0.2. RTC instance. So read on, and feel free to try this out for yourself.
The Problem and the Approach
One of my big issues as a manager is getting the story of my team across to our stakeholders. I have widgets which show the state of our significant stories and epics, but my stakeholders are not all technical types, and sometimes they need something a bit more graphic. The presentation needs to have some color, and some interesting graphics. I didn’t want to fool around with BIRT, because I might have some custom calculations, and some custom icons that I want to use. I also don’t want to have to upgrade the report when my tools get upgraded. So I thought that I could create a Python script that would use OSLC to get the information that I need. I can then take this information, and create a small HTML page with the information and links that I want to show. Using the new External Content widget (see my earlier post on Management by Results), I can then display this content on a dashboard. If I set up a cron job on my machine to run every six hours, I will not put an undue burden on the Jazz infrastructure, and I will give my stakeholders a nice dashboard view of what they want to see.
So this solves my reporting issue, allows me to learn Python, allows me to get deeper into OSLC, and should meet the needs of my stakeholders. Time to get to work!
Figuring it Out
So since I am a Python newbie, I decided to do what I always do when starting with something new. Do a web search for using Python with OSLC, and try to borrow as much code as possible from others who may have done this before. Why reinvent the wheel? I did see some good blogs on using Python and OSLC with RQM, easy authenticating with Python, as well as some OSLC with Python posts on the Jazz forums.
My First Sample Program
The blog posts were a good place to start, since everything begins with authentication. So the first thing I did was to download and install the requests library by Kenneth Reitz that was mentioned in the easy authentication with Python blog post. Since I am running Ubuntu, I just needed to make sure that I had the Python pip module installed. I then downloaded the requests library, Then I did a quick “sudo pip install requests”, and BLAM, the whole thing was all set. My Python environment was set, now to try a quick sample program.
So I just want to get into the repository, authenticate, and see if I can get ONE single resource out of the repository. No luck. I keep having authentication issues. So the next thing that I go and look at is the first blog that I listed, using Python and OSLC with RQM, and use the JazzClient class defined there. I really like how simple it makes the main program read. Still no luck. As I look through the responses that I am getting back, I notice that I am hitting https://jazzserver:9443/ccm, and when I go and look at the Jazz repository the base URI is https://jazzserver:9443/rtc. Looks like I have been hitting the wrong spot!! Once I change that to the correct address, and add a second storage of the appropriate cokkies as described in a Jazz forum post, everything begins to work.
Now most of this code is “borrowed” from the blogs that I referenced earlier, but you can find the code out on JazzHub. You can find my project on JazzHub, under the title “Python Jazz Client“. Check out the HelloWorld.py and JazzClient.py files. You can use them, but you will need to change the user, password and base URI in the main module. Your base URI will probably look like “https://mycompany.com:9445/ccm”.
This Python Jazz Client project on JazzHub is interesting, as it is the first real “development” that I have ever done on JazzHub. I made it a public project, so if you are interested in this type of work, or you have suggestions for expanding this JazzClient class, please join the project and pitch in. I can honestly use all of the help that I can get.
So there it is, a bunch of Python code that helped me get more comfortable with Python, utilized OSLC, and gets through authentication and can pull information on individual work items. It was so easy that even a slow-witted manager like me was able to do it. Next I will begin to build on these basic capabilities, to pull specific information from work items, and then use this to create some simple HTML presentations of the data.