Tim\'s picture      Blogging Ottinger (tim)

2006-September-30

Unit testing and SupyBot

Filed under: Programming

Ahhh.. I have a supybot plugin under testing. I am still learning the ins and outs (and probably should read through all the source code to see what’s possible. The testing framework supybot-test is really more of an acceptance test framework, but it runs without you having to set up and run the whole setup. It’s quite nice in its way. It allows me to test-drive changes (which is excellent!).

The framework is based on some basic convention for file naming and directory structure. I didn’t have that structure to begin with, but I’ve added it. Now I can easily test the plugin, though I will have to make some changes to the version control setup later.

Mocking was a little different. I needed to stub out the file reading bit, because I didn’t want to waste time writing and reading files. I just wanted to know how my plugin worked with different data. I asked on the #supybot irc channel, and got pretty prompt help (though I had to explain the idea of mocking, and I think I wasn’t entirely convincing).

The purpose for my mod is to get data from the existing logfile. I wonder if the lookup plugin that exists already isn’t suitable for the purpose, but I wasn’t so much interested in using supybot as interested in writing some code in python, so I didn’t really do “due diligence” to make sure it was necessary. I suspect the lookup plugin is more complete and cooler in several ways.

The mock/stub/whatever itself is pretty unimpressive. The idea is that you can put anything you want in “mockData” and it will be returned when the plugin tries to read the log file.

    mockData = \"\"
    def mock_filereader(*args):
        return mockData[:]

hooking up the mock in the test routine is pretty easy. I used the setUp routine to find the Stewie plugin, and I simply assigned the mock reader where the method was for reading from the logfile. By the way, this is another good reason to extract out utility methods. It would be hard to do this if it weren’t a method I’d already pulled out.

    def setUp(self):
          PluginTestCase.setUp(self)
          stewie = self.irc.getCallback(\"Stewie\")
          stewie._get_logfile = mock_filereader

The plugin “Stewie” was originally written to return Stewie quotes from some animated show I don’t watch (Family Guy, I think). I ended up adding different features to it. I may end up yanking those out and using other plugins eventually. I’m thinking that my “custom” feature might be good for things like returning quotes in context from monty python skits (stored in text). Given a text file, it will return the lines surrounding a given quote. The #tfug guys want to use it to look for quotes from other members, I wonder if it isn’t more widely applicable.

Here is what a test looks like.

    def testContextHandlesShortFiles(self):
        mockData = [
            \"line1\n\",
            \"line3\n\",
            \"line9\n\",
        ]
        self.setMockData(mockData)
        result = self.getMessageText(\"context line3\")
        self.assertEquals(\"Context: 3 lines\", result)
        for expected in mockData:
            text = self.getMessageText(\"more\")
            self.assertEquals(expected.strip(), text.strip())

You can see that we give the request “context line3″ , and get back the message text “Context: 3 lines”. Then we look at the “more” message to get the text surrounding the “line3″ content (line1 and line9).

This maybe isn’t 100% transparent yet, but I’m looking at ways to make it more clear. I will be refactoring out a few different bits into explanatory functoins, and may rename some other bits. I think that ultimately it will be quite easy to write and edit plugins.

Anyway, it’s working better all the time, and I’m getting a better handle on it.

2006-September-28

No wonder people don’t like me

Filed under: Fun, Life

I found an article about becoming more likable. I didn’t figure out why I would want to, though. :-)

Work friendly

Filed under: Life

This is soooo wrong.

2006-September-27

Breadwinner History

Filed under: Music, Guitars

I’m loving the modded guitar, and I found a little interesting history of the breadwinner via a fansite.

2006-September-23

Linux Distributions

Filed under: Linux

There are a lot of them. The list at Desktop Linux isn’t all of them, it’s just an alphabetical list of some pretty good ones. There are a lto of them at linux.org’s distributions page. My preference is for those based on Debian (or Debian itself).

2006-September-22

It’s not the programming.

Filed under: Angst, Programming

It’s a frustrating time for me. Programming is pretty easy and pretty natural, but it seems like programming is less and less the job we’re doing. I tend to spend our time deep-code spelunking for some clues as to how to use things sometimes and that’s natural, but most of the time we spend in configuration and research. I was noticing that sometimes writing a 10-line program will require 20 or more lines of configuration, all of the kind that require a pretty deep knowledge of the servers and services you’re working with.

My supybot experiences continue.

It was a realization of mine (that I could have kept quiet) that I don’t really have any interest in a supybot hobby. I wanted to write some code to do some things for some people who are big fans of irc bots. I do this out of interest in them, but no real interest in chat bots. Unfortunately, there is a lot of necessary prerequisite learning about things that don’t interest me. I don’t want to be a chatbot expert. I don’t care what plugins already exist. I don’t want to run a bot. I don’t want to build more custom plugins. All I want to do is make it better for some friends who do use it.

I only want to write code, test it, and check it in. Beyond that, it is all nuisance. I fear it’s insulting to tell the supybot volunteers that fact, but I did it without really thinking. Kinda fell off my fingertips. All I want is a programmer’s quickstart so I can do my thing and get on with my life. The last thing I need right now is a hobby that requires some kind of commitment from me. I don’t want to run it from my machines, I don’t want to configure it any more than absolutely interested, and I’m not interested in the things I could potentially do with it.

But there’s no programmer’s quickstart. We can read examples, and we can read the source. There you go. If you can figure it out, that’s what you get. But it’s the python code that’s easy. The difficult stuff is in knowing the world that the code has to live in (which the the part NOT documented).

Ah, well, that’s life.

2006-September-21

All your news are belong to us

Filed under: Life

Apparently Belgium doesn’t want its news disseminated to the rest of the world. Heaven forbid Google should attract readers to the news website and increase their ad revenue. Gotta nip it! Nip it! Nip it in the bud!!!

2006-September-20

supybot first experience

Filed under: Angst, Programming

Well, i did a little work on a supybot plugin today. I didn’t plan to, but that’s how things go. My great fear was that it would take hours to figure out how the plugins work and what the server does and how to configure it. I had been putting off working in supybot for this very reason — when do I have time to invest a day or two in something that won’t pay me?

It was so. It was hard to configure, but I had a friend standing by telling me how to answer the questions I didn’t understand. Then I had no way to unit test it, and had to resort to hacking some python code and then running the server, and throwing text at it. This is partly because I did not understand the server (and really do not still). I only had it running, I don’t know how it runs. Through this horribly inefficient process I was able to make the code work for me (only after breaking the bots the first time)

I do know it’s an irc bot. It connects to a group and becomes a participant. When someone addresses it, it answers. The code for how it answers was only a little bewildering because of a wrapper. The wrapper, sadly, was named “wrap”. What do you think it did? I guess there was no way of knowing with a name like that. I find some text on the web page (since it’s not intuitive) and I find that it’s really very handy. It checks the parameter types. It has not only types, but contexts, and is very flexible. Great. But it should have a name that leads one to think that one is specifying data types for the parameter list. wrap indeed. That ticked me off partly because it was a poor choice, partly because I was already on edge from having to create a configuration file.

I don’t mind programming, but I HATE configuring things to run. I have this naive feeling that things should “just run” when you write them, and you shouldn’t have to wire them into the OS. Still, I know that it’s common and the java people like it that way. I flinch, remembering the SNA networking days of IBM, where every point-to-point conversation had to be configured into the OS by a network specialist. Those were the bad old days. I always feel out of my depth when configuring things. I guess I should just get over that. I guess we all need sysadmin skills these days.

Running it is easy enough. You have to make changes to the config file (a pain) but after you add the path to your plugin, and tell it to run your plugin, then you can run from the current directory

supybot config.conf
. That’s good enough. It’s not a quick startup, but it will connect to the configured groups and will run.

The code needed refactoring, and I did some of that. I hope it’s easier to understand now, but I didn’t have a partner. I will need to look at it later with fresh eyes. It’s hard to tell if you are the only person looking. I can suit myself and it not be good enough. A guy needs a partner.

Testing is the bigger problem. I would rather be testing *first*. “Retro-testing” never feels like a worthwhile activity. The testing is supposed to drive design and give me ongoing feedback. Testing after-the-fact is really all about proving that you really did what you did (a fact you already know, so it’s low-value) or else uncovering new bugs (hard to do by yourself) or staking down the functionality against regression. Testing first is high-value. Testing last is a posterior discomfort.

Then I find out that there is a unit test framework in supybot already! Great! I look at the docs, I write my tests… and have no idea how to run them. No matter what I type, it seems that the test file is parsed and nothing is done. Somehow I’ve failed to let the test framework know that I’d like it to run my tests. I derived from the correct class (and checked examples that came with the default plugins). I named my class starting with “test” just as it says. It just doesn’t run my tests. Apparently I don’t know how to do it from the command line.

I think maybe the problem is that it doesn’t read my config file, and so it doesn’t know where to look for my code. I think it may be assuming that I have a plugins directory, and that there is some directory tree under the plugins directory with tests and things. This is troubling, because the code isn’t mine and is already *not* in that structure at all. I got it from svn, and I know that it is running elsewhere in the world. I doubt it’s being tested in that elsewhere, since tests don’t exist. Now the question is how to get supybot to run my tests — and I’ve no clear idea.

I try

python test.py
No such luck. Parsed, and that’s it. No tests, no setup, no teardown.

I try

supybot-test test.py
No such luck again.

In the help, it looks like you’re supposed to give the name of the module to test. Interesting. Not the filename? Where does it expect to find the test? Under the current dir? Under some other dir? Is it the name in the config file — where I specify the path to the plugins — which I *dont* pass to the test program according to the man page?

Maybe I’m tired and maybe I’m always too nervous when trying new things, but shouldn’t the doc tell me how to run the tests, instead of only how to write them.

Sigh. Frameworks should be written for the impatient. How do I run a simple test? Where do I find out? Maybe the information is there, but in passing I missed it? All I know is that this is taking longer than I wanted to spend on a “fun” project. It is 11:00 pm almost, and I’m still trying to figure it out from this afternoon. It should have been an hour or so, maybe two at the outside, but I don’t know what’s up yet.

Finally, the second time in python I’ve hit something that is inobvious and requires documentation, and for which the documentation seems to be insufficient. It was bound to happen. Last time it was the http handler — and my problem was that I knew nothing at all about http. We’ll see what it is this time. I could be back here apologizing tomorrow (which is only an hour away now).

So do I have to go read the source code of the server to know how to configure it so that I can write tests so that I can make a simple plugin? Is that a reasonable expectation to have for plugin developers? Maybe so, maybe not. But either way, I can’t read the server source to find out how to run the tests. Hmmm… how IS this done?

2006-September-18

Ovation Breadwinner Details

Filed under: Music, Guitars

This is the I keep talking about. These are actual pictures of my actual guitar, not something I pulled off a web site. You can see all the wonderful blemishes and signs of mistreatment. The pictures are slightly reduced here (by tag) but if you open the image (firefox: rightclick and “show image”) you will see it a little larger. Im not going to make this too much like “flicker” or some nice layout — I’m just splashing the guitar pics on the page.

Guitar in opened case
In its “bed”. This guitar has the off-white “spackle” finish.
Guitar standing up on opened case
Standing up, you can get a better idea of the looks of it.

Mine is number E00375
bridge_detail.jpg
You can see the funky nylon bridge and the pickups here. The two toggles are visible. The distant black one is the three-position switch. The nearer steel-looking one is the coil tap. Notice that there is no front jack. Some of the later models had the plug in front, where they moved it from the edge. Mine must 1971-ish.
Battery Compartment Cover Plate
The later models had an ornate rear battery compartment plate. Mine is sleek and clean, just flat stainless steel.

Today was “our first day out” ;-) I played it in service this morning. I probably used all five settings. It is good to have this pickup combination. It’s plenty versatile and sounds wonderful through my crate tube amp. There is no buyer’s remorse in the choice of pickups. I’m very satisfied. I just wish I had more chance to play. Any inability to express myself on this instrument is a personal fault, not one of equipment.

2006-September-17

Best Presidential Address EVER

Filed under: Fun, Life


Here is the way to deliver an address… and not a bad message.

2006-September-16

Ovation Breadwinner

Filed under: Music, Guitars

Oh. My. Goodness.

The Duncan “Hot Rodded Humbucker” set is amazing. I had the techs install a coil tap on the neck position, and otherwise install it standard (in-phase) and then do a setup on the Ovation. Everything works very well, and the setup is very good — just the way I want it.

bridge_detail.jpg

I noticed that the tap switch is nickel, even though the three-way switch is black, and that bothered me a little aesthetically. I would rather they matched, but I didn’t specify and it’s probably not worth changing out either of the switches. The price for the work was so good, and the workmanship, and the guitar has other blemishes, you know? I was into this for the sound, anyway.

When it comes to sound, the pickups are nothing short of amazing. I played through a good amp at the shop (a blues junior tweed, I think) and it sounded really, really full and sweet. I was surprised at how crisp it was. I had expected a little bit of mud in the sound, and there isn’t any. There’s not even the least bit. It’s is amazingly clear and crisp and almost perfect. I was a little disappointed at the sound of the neck pickup with the tap. I guess I expected a more strat-like sound than it had. Of course, this was a first impression. I played some chords and single-note stuff in all 5 combinations (front, front tapped, both, both with front tapped, bridge only) and was pleased with the warmth and sparkle.

Then I brought it home. At home I don’t have a “good” amp. All I have is a little battery-powered toy amp (fender mini-twin). Even with a little toy amp, it sounds amazing. I took a little time to fingerpick, chord, and play some single-note riffs. In every position I found something I really, really liked. I know which settings to use to blend in with the acoustic guitars and keyboards, and which to use when I want to stand out. This guitar is sounds as good as many guitars costing several times as much. It’s an amazing change.

I need to change habits. I used to avoid the bridge pickup on all my guitars unless I was playing with some distortion and overdrive and was playing single-note leads. I never liked the muddy nasal sound I got out of my other bridge pickups, even on strats (the Squire or even the Am Std HSS). This JB is a whole different animal. It sounds really sweet and rich even if I’m fingerpicking. On bass string riffs, it is totally hot and warm and rich.

The neck pickup is an SH2 Jazz pickup. It has a wonderful rich, jazzy sound. I enjoyed the untapped pickup (all on) for a while and then toggled the tap and tried it for a while. I guess my first impression was only disappointing because I expected something different. Taken for what it really is, it does have a sound that’s between a strat’s middle pickup and an acoustic guitar. I will mostly use it when I’m wanting to blend in or when I want a pseudo-acoustic strumming sound.

I’m sold. I will start to checking out more pickups and aftermarket mods, though I think that I’m happy with the breadwinner. This guitar is done, and I have plenty of tone-rich goodness to play with for a while.

Very happy, me.

Washburn X33 - So pretty

Filed under: Music, Guitars

I have to list this one, because it is the prettiest strat-like guitar I think I’ve ever seen. I would have paid a few hundred more for this finish on my strat if it had been available. Not only did they not have one like this, they didn’t even have the transparent ‘butterscotch blonde’ that looks so great on the Telecaster. But that’s a different story. The coveted finish is like this:


Wasburn X33 Guitar

I suppose I’m going to have to meander over to the Washburn shop and check this one out. The harmony central reviews are glowing. I guess some other people think they play as nice as they look. On the other hand, it is really hard to find a review for the X33. I don’t know why not. Maybe the price doesn’t attract as many reviews. The hardware is pretty much Washburn-brand, and that isn’t the same draw as if it were brand-name. I dont have a lot of industry cred (read: none) but I would certainly like to try one out and do a review.

Washburn has a really good handle on how a guitar should look, and what parts should go into it. They have these great sculpted bodies and transparent finishes that I wish Gibson and Fender would offer. The Washburns also come standard with a lot of the features that are popular “power ups” in the aftermarket. The grover tuners, intonation system, off-the-shelf pickups (often Duncans or EMGs), etc. Even the lower-end guitars of the line are beautiful.

I have to go check some of these guitars out. If they are half what they seem to be, the prices are insultingly low. This gorgeous babe of a guitar is selling around $400, and frequently less. How is that fair? Not that I’m complaining. I could have one or maybe two sometime.

Get free blog up and running in minutes with Blogsome | Theme designs available here