Tag Archives: python

Contributing to Pagure made easy.

I don’t get as much of a chance these days to do things like patches or other technical contribution. But I had some time free the other day and used it to stick my hands directly into a cool project, Pagure (pronounced roughly “pag-yOOR,” or listen here). You may have read about Pagure in this Fedora Magazine article a few months back.

It was tremendously easy to get Pagure, fix a bug, test the fix, and contribute it back (see my pull request here). I specifically looked for “easyfix” bugs, since I knew I didn’t have a lot of time to spend to help. So I decided to work on this issue, a button showing up when it shouldn’t.

First I forked the repo in Pagure. Then I cloned my new fork, and set it up as documented in the README. In the clone, I checked out a new branch using the issue number as a name, issue839.

To track down the fix, I ran the app locally and duplicated the error. I looked at the CSS style containers for the button and some of the surrounding elements. Using that information, I did a text search on the code to find the file that was generating the button. Then I simply applied some logic to find the fix for the problem, even though I wasn’t really familiar with the code involved.

Thankfully Pagure has a test suite, so I could also check that my fix didn’t break any of the tests. Then I committed and pushed my changes, and made a pull request using the button in Pagure’s web page.

I also learned something useful. Since I forked the repo to do my fix and make a pull request, if I force-pushed changes using git to my branch from which I made the pull request, the pull request was automatically updated with the changes! This is probably expected by people who do this all the time, but since I’m new at it, I was excited.

Bugs like this are something that just about anyone with a small amount of beginning programming skill could fix. Pagure even has other bugs like this waiting for people to handle. Maybe one of them is waiting for you! 😉

Git by a bus.

David Gay pointed me to an interesting project called Git by a Bus. Git by a Bus analyzes your git repository and attempts to quantify risk of having lots of code knowledge tied up in only a few people. Git by a Bus does its analysis by going through the repo history and making an estimate of what it calls unique knowledge.

This project blog page describes the analysis and metrics used. Perhaps this is a useful way to show how Fedora is doing as a project, across repositories like our web applications and infrastructure. It might show where we need to encourage further community development and participation so we avoid the “eaten by raptors” problem.

You might recall that “eaten by raptors” is Fedora shorthand for “hit by a bus” (violent idiom) or “going to work for another company” (not always applicable to Fedora, although certainly to Red Hat as a major contributor). We try to solve this problem by spreading project knowledge and documenting our processes. That way, if someone was eaten by velociraptors, the project can keep going without too much of a disturbance. This problem is common to any team or enterprise, not just open source. But I like to think our velociraptor spin is unique.

Here’s an example output I prepared for the MirrorManager project, which we use to provide content to Fedora mirrors worldwide. This is a potential example of high risk. One developer (the inimitable and awesome Matt Domsch) has unique knowledge of this project that is at risk if velociraptors manage to track and eat him. No doubt Matt would put up a good fight, but as you probably know they are clever girls.

Thankfully, there is a MirrorManager related Fedora Activity Day happening later this year. During that time the Fedora infrastructure, release engineering, and applications teams hope to accumulate and document more MM-related knowledge. At the same time they’ll be using this knowledge to architect, plan, and further develop the next revision of MirrorManager.

If you’re a principal in an FOSS project using git for your code, you might find Git by a Bus useful.

Snake for great justice.

I took some time last night to make a couple additional fixes and changes to the irssi-libnotify project I posted about a few days ago.

Among other things, I changed the upstream VCS from Subversion to git, which ended up being pretty simple. I’m much happier keeping the code at Google when I know the entire history resides with me, too. That way, I can move the upstream elsewhere if it becomes necessary. Thankfully, git-svn makes it incredibly easy to migrate, and there’s a helpful wiki page to help with the migration.

I did find that the site docs left out an important part (to me) of the process, which is migrating the authorship information properly. This page was useful to find a quick recipe to use with the SVN log.

For some reason, though, I was still on a hacking (or more precisely, “flailing”) kick. I was happy to have made some fixes to my project, but I’m not a big fan of Perl, so I checked out the current state of irssi-python. This project, as you might expect, provides a Python scripting interface for irssi.

Unfortunately, the project hasn’t kept up with irssi, so it isn’t easy to build. I found a patch for 0.8.15, which applied cleanly and got most of the way there. However, I found for some reason that upstream irssi doesn’t install some of the development header files needed to build irssi-python. I created a patch and a new SRPM that will allow the project to build properly, and also put my work in a git repo with a README file that will help you build it if you’re interested.

Once you install the plugin, you can do the following to experiment so you can build your own scripts:

/load python /py exec import irssi

Have fun!

Enrichment day 4.

This week was the last enrichment class for my group of fifth graders.  As I reported in the last installment, the syllabus ended up changing a bit to adapt for the unexpected difficulty of some of the concepts.  Variables in particular were difficult, but eventually the students started to understand them pretty well.

This week built on variables to teach the concepts of conditionals and loops, using the if and while statements in Python.  It was at this point that I could tell that most of the students had really grasped the concept.  One of our exercises was to follow the logic of a simple counting/printing loop.  The kids seemed to like putting themselves in the role of the computer.

It was also at this point that the kids started to understand the power of booleans (True and False).  We tried a number of additional comparisons to understand cases where conditions evaluated to each.  The emphasis on True and False paid off in the section where we discussed conditionals and loops because we could pay more attention to the actual branching operation, as opposed to getting stuck on figuring out why the branch happened.

This week I also discovered what I think was a good way to increase the idea of collaboration in the class.  Obviously there wasn’t time to check every child’s work at every step of the way.  But I could make things easier and less pressured on the kids by rotating a “look and see” duty around the class.

Since the class was relatively small (only six kids), I could have all of them gather around one person’s console to see the results of a program or exercise.  We could even figure out what went wrong together in some cases.  Hopefully this removed a little of the pressure of having the instructor point out something that was wrong — a friend could point it out and even help fix it.

Of course, it wouldn’t be a last class without some bonus for the kids!  Thanks to the fine people at the Fedora Project, I had stickers, temporary tattoos, and buttons for the kids, which they loved.  They also got to take their Fedora Live USB keys home, which several of them had been waiting for since the first class.

Speaking of keys, I sent home an information sheet for the parents to go with the keys, so they’d understand what was on it, how to use it, and where to find more information and help.  The keys also had two complete electronic books (both CC BY-SA licensed, check them out here and here) included that are specifically aimed at teaching Python to kids, so if the kids want to go further they can.  A couple of the students demonstrated really serious aptitude, so I think chances were good the class ignited the imagination of a future computer genius!

I’ve posted the last lesson (and miscellaneous resources) in my fedorapeople space, and as with previous lessons, it’s all licensed as CC BY-SA 3.0 so it can be reused by others.  I hope you got something out of reading about the class.  I had a great time teaching it and I think the kids enjoyed it too. Thanks again to my employer, Red Hat, for lending me a few hours this month to give back to some kids in my community.

Enrichment days 2 and 3.

I’m sorry I got behind in posting about the enrichment class last week. After week 1 went so well, I thought I’d easily be able to post updates weekly, but alas, it was not to be. However, this wasn’t just because of other workload. The week 2 class actually didn’t go as quickly as the week 1 class. The lesson plan I thought would be light enough to cover in one session has actually taken up the hours for both weeks 2 and 3. I’ve posted the lesson in my Fedora People space.

It turns out that one of the most difficult things for the kids to grasp has been return values. That is, understanding that when you run a function in Python, a value is often generated as a result. Python can either do something with it, or not. This is deeply tied to understanding the usefulness (if not the concept) of variables as a way of holding on to those results for later use.

This concept is inherently difficult for fifth graders who haven’t yet been exposed to concepts of algebra or the unknown. Math and science up to this point in their education are decidedly concrete, and focus strictly on known quantities. I underestimated the difficulty of introducing the concept of an unknown, indeterminate object like a variable.

Fortunately, Python has made it simple for the kids to try smaller steps on their way to understanding this concept. Python’s particular style of input/output at the interpreter allows them to see how return values are generated. Then it becomes a matter of understanding the concept of variables, and assigning that return value to a variable. This is not as easy as it sounds for fifth-graders, but by the middle of week 3’s class light bulbs were switching on!

Regardless of the difficulty of the class, the students in general have loved the class, and are excited when they show up each day. I wish I had more time with them, but alas, the class only lasts for four weeks.

We have one more class coming up on the Monday afternoon after Thanksgiving. Based on the experience thus far, I expect we’ll spend the majority of the last class on conditionals, and understanding the if statement. Courtesy of the Fedora Project, I have some wonderful swag items to give out which I think the kids will love, like buttons, stickers, and temporary tattoos. Also I plan to give them their Live USB keys, as well as a note for their parents on what the keys contain and information on how to use them.

I will try like mad to have a blog post up sooner after next week’s class!

Enrichment day 1.

Yesterday was day 1 of the enrichment class I’m teaching at my daughter’s elementary school. The class is elementary computer programming using Python, and has a total of six students, all fifth-graders. Actually, the first class only had five, because one went home on the bus by accident instead of staying at school for the extra class.

The first day is never the best day, because there are a lot of introductory things to get out of the way. In our case, I needed to show the kids some essentials for how to open programs, write and save files, find them again, and start up the Python program. This might sound really easy to you and me, but for fifth graders one needs to adjust the expectations. Not every child is comfortable with a keyboard, for example, and I couldn’t assume that every child had ever typed a document before just because my child had.

As it turns out, we really needed every minute of class to cover our material, which made me glad I didn’t overschedule the tasks in the class. We started with some basic information about what software is and why it’s important — that without software computers are basically as dumb as a box of hair.

The kids enjoyed this explanation; I demonstrated the difference between instructions for computers and humans by having one of the students walk down to the end of the room and back. I didn’t explain to him, of course, how to get up from his chair step by step, push his chair in, turn to the left, put one foot in front of the other, etc., etc. So that made a great example for how computers have to be told everything explicitly. This made it easier, later in the class, to have the kids understand why the computer gave them an error in certain examples I set up.

I was impressed with how quickly the kids picked up the GNOME 3 interface, even though it’s somewhat different than the computers they’re probably used to.  Most of them figured out the overview and how to find applications very quickly — so I had to get them back on track once they found the games! They also had no problem moving, resizing, and closing windows.

The computers in the school lab need to be powered off at night according to school policy. It was a little tricky to show the kids how to shut down the systems, but other than that the transition was pretty smooth for most of them.

One child was uncomfortable enough at the computer that I suspect she hadn’t much experience at all. She seemed worried about doing things wrong or breaking the computer, so I tried to go a little out of my way to give her some positive feedback and tell her she was doing a good job!

We got all the way through the ending exercise, which was to let the kids fire up Python 3 and have the computer do some math problems for them. I even managed to tie into one of the kids’ current math lessons, which is on order of operations. They were really impressed the computer knew how to do their homework for them!

I’ve put the day 1 labs in my Fedora People space in case you’re interested in seeing what we covered. I would also be remiss if I failed to thank my employer, Red Hat, for giving me the flexibility to take on this extramural project.

Enrichment class.

Lately, as an extramural project I’ve been preparing an enrichment class I’ll be teaching at my kids’ elementary school in November. The class is for fifth graders, a very light introduction to software and programming concepts. The kids elect their enrichment class, which is a fantastic way to put together an audience because you know they’ll already be interested in the subject. The classes are held for one hour each Monday after school for four weeks — so there are four hours of class in total.

The first question was, would we use a language? I felt strongly the answer was yes, because I wanted the kids to have a hands-on learning experience. In addition, I believe fast feedback is very important for younger kids. It helps them feel more confident while they get comfortable with the material. So it was important to pick a language that was interpreted.

I ultimately decided on Python, not just because I’m comfortable with it and it meets the criteria, but also because it’s widely in use running things the kids have heard of (Google, Facebook, NASA), widely recognized as a good first language for learning, and is eminently readable for any of the kids who decide to pursue it further after class is over.

Of course I plan to spend a couple minutes to explain to them the awesomeness of free software, and how they can share it with others. I hope that’s a tiny nugget of learning they can take away even if they never touch Python again.

I also knew I’d need some good self-directed learning resources for kids in this age group, so they could keep going when class ends. There are at least two good books out there the kids can use if they want to continue on their own:

Both these books are available for Python 3, which is what I’ll be using for the class. I’ll be providing electronic copies of both for the kids to enjoy and learn more later.

Now, how would I make Python available for the kids? As it turns out, the school has brand-new HP desktop machines that were purchased this past year, and the resulting lab is completely homogeneous. This is fantastic because it means I have to worry a lot less about a student having a problem specific to their computer. If things work OK on one, they should be OK for all, modulo some low risk of sudden hardware problems.

But this didn’t mean I can necessarily install Python on all the computers. Nor would I want the kids to go through that process; it would be a waste of time as well as frought with all sorts of chances for human error that would lessen the learning experience. Although I have full support from the school administration, that doesn’t mean I should be installing stuff on their computers’ hard disks, or putting the onus on the computer resource teacher to do it.

Obviously, what I needed was a bootable operating system that wouldn’t touch the lab systems’ hard drives. This called for a Fedora Live USB key! I decided to go with Fedora 15 since the class is coming up before the release date of Fedora 16. And thanks to the livecd-tools package, and the spin-kickstarts repository on Fedora Hosted, this was relatively easy to handle as well. With a couple quick customizations, I could provide the kids with a safe, friendly, and powerful environment in which to learn.

After creating this boffo live image, I needed to try it out at the actual lab environment. I did that this afternoon, just as school was letting out for the kids, since the lab was free. There were no problems at all — the free software X video drivers worked spectacularly, NetworkManager connected kids to the classroom network with zero fuss, and the new GNOME 3 environment was ready to use. I tried a number of lab systems and gloriously, they were all configured homogeneously as well. The systems were even set to boot from USB first; all I have to do is make the keys, and before class, just insert them and power on!

I know I shouldn’t be elated that the software works just like it should, but I still love to think about how far we’ve come from the days when Linux could only be used by tinkerers. And of course I have to give huge props to all the people who work on the kernel and plumbing, GNOME 3, and Python. Without their hard work there’s no way I could provide the class to the kids. And the best part is, the zero cost and freedom of Fedora means all the kids can keep the keys and continue learning even after class ends.

I also want to thank Máirín Duffy for the inspiration, and her thoughts as I started putting the class together. She ran an amazing Inkscape class for some young people not long ago, which you should definitely check out! Just as Máirín did, I’m going to provide all my materials under a Creative Commons license, and blogging the class progress here. I can’t promise to provide lots of photos to go along with everything (terminals make dull subjects!), but I hope it’ll be fun and maybe even interesting to read.

Presents for everyone!

Even though I’m on vacation, I had some fun catching up with some geeky Fedora work, like handling bugs and package maintenance over the last few days. It only took me a few minutes at a time to do something useful for (hopefully) many other users. Along the way I was helped by other contributors, like Kevin Fenzi, who did a package review for me, or bug reporters who tested a package update. Among the things I got done:

  • Took over maintenance of the notify-python package, and fixed a missing documentation problem
  • Produced some testing updates for the stable 2.0 branch of blogtk
  • Fixed a missing icon problem in the nautilus-open-terminal package
  • Packaged and issued push requests for the new package python-babel-BabelGladeExtractor
  • Went over my pending package reviews and pushed each one forward in some way

Some of these things had been on my “to-do” list for a few weeks, but I didn’t have time for them during busy workdays. Since my evenings and weekends have been pretty full this was a great opportunity to scratch some of these things off my list.

I also got to work more on my PulseCaster project, although I haven’t yet made the sweeping interface changes that I’d like for the next version. I also bought the pulsecaster.org domain for it, in the hopes that will spur me to work even more on it over the next few months. I fixed a couple workflow issues in the interface and was able to remove a little code with some “create on demand” dialogs rather than putting them in the Glade file.

I’m still hung up on needing some additional and more complicated Python pieces, like querying the volume level of a source or sink so I can introduce a VU-meter like control as part of the interface changes. But in the meantime, I’ve started to get much better and faster at implementing ideas in PyGTK. I’m not sure my coding style is as good as it should be, but my understanding of concepts has gotten fairly good, so I can translate PyGTK API docs into the ability to do something. I gave a couple conference speeches over the past year on PyGTK that I hoped would give other people in similar shoes — people who can write scripts but aren’t familiar with GUI programming — a primer that allows them to “cross the bridge” into exciting new territory.

Lest my family oriented friends think I’ve been shirking my domestic obligations, or failing to use my PTO to rest and rejuvenate, I also did a lot of relaxing personal and family things over the last few days. Some of these things were responsibilities even if they were fun, or a nice change from work or geeky stuff. The funny thing is, most days since I went on PTO I’ve been getting up at about 7:00 or 7:30am so as not to waste the whole morning. For me that’s at least somewhat a luxury, since I normally get up at 6:00am for work. Here’s some of the things that extra time allowed me to get done, even if I threw in an hour or two of work on geek stuff each day:

  • Attended piano recitals for both my kids
  • Went to the elementary school chorus performance for my daughter and the super-fun singalong that followed
  • Volunteered at the school library by shelving books with my wife
  • Handled the remainder of the Christmas shopping
  • Did some “Santa errands” like going to the skate rink to get some sweet, fast bearings installed on one of my daughter’s Christmas presents (new quad skates)
  • Went grocery shopping so my wife could be at the school to help as a classroom volunteer
  • Had a new door to our deck installed — a more energy efficient slider with low-E glass and integral blinds (OK, this mostly consisted of checking progress and signing paperwork)
  • Played some games with my kids

I also got to do some completely selfish leisure stuff, like trying the new Sam Adams Infinium (I give it a 90 on the beverage scale), playing our new piano and some guitar, and hanging out with our dog Dixie — the world’s greatest pound puppy!

Speaking of pound puppies, a quick step up onto the soapbox here: If you are looking for a pet this holiday season, or whenever, please adopt one from a local shelter. I’ll write more about this in another post later, but I wanted to throw that plug in here in case you’re one of the numerous people who might get a pet during or after the holidays.

We did a little share of unhappiness thrown into vacation, though. First, my ’00 Accord ended up needing a new transmission, which is going to be rather expensive. However, we’re very fortunate to be able to handle it without any real financial discomfort. Not everyone these days is as lucky, so I try not to take that for granted. My brilliant and dedicated colleagues and coworkers at Red Hat have made that sort of security possible, and I’m very thankful for all their hard work! This vacation time in part allows me to hit the ground running in 2011, so I can continue to do likewise by them. 🙂

The other disappointment is that my mom took ill yesterday, and is feeling really crummy today. That means she and her hubby won’t be coming to Christmas Eve dinner this year as they usually do. Eleya has put together a really scrumptious menu for us, and certainly we’ll still enjoy it, but it’s too bad it’ll just be us, with no company to share it with. But then again, we’re really fortunate to have each other and a bountiful meal to celebrate the holiday — and tomorrow we get to visit my sister where we’ll see the rest of the family.

Anyway, that’s a big update on all my doings of late. Wherever you are, and however you choose to celebrate the season, I hope you have a fantastic time and that you get to spend it with friends and loved ones.

SWIG, Python, and PulseAudio.

OK, we seriously need someone who knows SWIG to put together PulseAudio bindings for Python. I’ve worked on some ctypes style wrappers, and they are not only not fun, but I suspect that I am Doing It Wrong, or in a non-Pythonic way. And I know that Lennart Poettering, the chief PulseAudio author, writes his code in a very consistent manner, which if I understand correctly makes a potential SWIG wielder’s job much easier.

It’s about time we exposed the power of PulseAudio to a new generation of Python folks (and got them to quit using python-alsaaudio when it’s really unnecessary and sometimes non-optimal).

Fedora Talk activity day.

For a while now, I’ve been working on plans for a FAD to work on our Fedora Talk VoIP system. There are a couple gaps I’d really like to fill, such as the ability to record, publish, and/or stream calls. These features would make the system much more capable of high transparency. They’d also contribute to an archival history that might help future contributors in the same way as other types of conference and meeting proceedings.

For example, it would be really cool if we could use the Talk server to record our sessions at FUDCon, which could be streamed and/or downloaded later by any community member. The only thing we’d need to do is to run a microphone into any laptop running a VoIP softphone on Fedora Talk, set the record level, and voila.

The raison d’être for any Fedora Activity Day is to gather a small number of interested contributors to a central location to work on short-term, focused goals that advance some part of the Fedora Project. (These are very different from the Fedora Users and Developers Conferences (FUDCons), which are much larger gatherings that serve many needs.) I’ve been to a couple of FADs this year already, including one for Documentation in Clemson, SC, and another for the development cycle in Raleigh, NC. So, in keeping with the slow sojourn up the East Coast, I am working on one that will be held in my hometown of Fredericksburg, VA.

It might be nice to add one more person with some Python and Infrastructure skills to our merry band, especially if they know something about streaming media. If you’re interested, drop me a line and put your name on the wiki page.