Archive for April, 2008

Ubuntu Hardy - Nautilus not starting due to bonobo activation server

I was looking forward to the release of Hardy as I upgraded my main computer much before the official release which meant couple of problems which I described in one of my previous posts. Most of the issues were resolved in couple of days but about two weeks ago I started having a problem with starting graphical interface due to the Nautilus not being able to register to the bonobo activation server, the same for panel. The environment was still usable but I had to start each time in the Gnome Failsafe mode. I assumed it must to be a pre-release bug or something. I know, I was passive and should have investigated that straight away. But using beta versions of software very often means that there are small issuettes here and there, which is natural, I think, and we agree for that the minute we start that version. I waited patiently for the fix checking everyday, pulling updated packages. It didn’t come. Finally the official release came as well but didn’t solve my problem neither.

As it turned out the problem laid somewhere else. I installed recently Mono 1.9 to try if the Web21c SDK can be executed on that. After uninstalling the software by running the ./uninstall script from the Mono home folder everything works smooooothly again!

Lesson: don’t assume.

Popularity: 36% [?]

Comments (1)

Fizz Bang python coding challenge

Very late, I know, but finally I sat down to the Python focus group homework which T4 started to run recently. The first challenge was:

Write a program that processes a list of numbers from 1 to 100. For each number, if the number is a multiple of 3, print “FIZZ”; if the number is a multiple of 5, print “BANG”; otherwise, print the number.

You are *NOT* allowed to use any *IF/ELSE* statements in your code. You can use the list-accessing ternary operator hack, but whilst I’ll accept your homework if you do, you’ll miss out on the prize (alcoholic), which goes to the most concise code (not including whitespace).

I started with implementation which uses IF statements just to get a feel for the problem and then I moved to a solution using datastructures, starting with the dictionary where key mapped to a function. Something like:

dict = {
    1: f x: x,
    2: f x: x,
    3: f x: 'FIZZ',
    4: f x: x,
    5: f x: 'BANG',
    6: f x: 'FIZZ',
    7: f x: x,
    8: f x: x,
    9: f x: 'FIZZ',
    10: f x: 'BANG'
}

Each key would map to a function which returns a correct value for that index. Then for a given index we could print the value as follows:

print dict[n](n)

It works for numbers from 1 to 10 only but as first cut that’s ok. You can see straight away that mapping to function is not really needed. Simple values in an array would be enough. Now we have to only make it more robust and use modulo on the value. After some time of struggling I got to this outcome (which is very similar to Kerry’s and Nigel’s solutions):

for n in range(1, 101):
    print ['FIZZ','',''][n%3] + ['BANG','','','',''][n%5] or n

There is already a second challenge waiting.

Popularity: 22% [?]

Comments

Selenium and the Permission denied to get property Location.href problem

SeleniumI came across a strange behaviour of Selenium and wanted to share my pain with someone really. But first couple of words of introduction. I use Selenium in my current webapp project which I am working on. The application uses quite a lot of javascript (Dojo framework mostly) which can be tested using D.O.H. framework but the Selenium is giving us the final sanity checks, acts as integration test framework and may be used by product owner in an agile environment to drive acceptance on user stories via automated acceptance tests.

Selenium is an excellent package. I really love it. Just to mention integration with various browsers, Selenium IDE, support for integration with build (Selenese ant task) and really easy way of creating and storing the tests as HTML. It is a framework which cannot be ignored by anyone working on webinterfaces.

There is previously mentioned selenese ant task which helps with integration of the Selenium tests and an ant build. You can grab the jar from the Selenium RC distribution.

However as most of the things around us it is not a perfect software. Anyone had the famous “Permission denied to get property Location.href”? Cross domain scripting issues?
In my case I figure out two reasons for above problem and I wanted to share it:

Problem 1:

Let’s look at the following selenium command:

  • open
  • http://host/some/url

Looks good, doesn’t it? So it might work, but it can as well break on another box with the “Permission denied to get property” and some other scary warnings. The solution in this case was simply to remove the host definition from url leaving just:

  • open
  • /some/url

Problem 2:

One of the pages I was testing had redirection in case of the authorization violation. So esentially after single HTTP request the browser was receiving single response with redirection and then performed another request to the URL defined in the redirection. Selenium couldn’t handle that correctly. But again, it wasn’t deterministic, it could work on one box but fail on another. Timing issues etc. Hate that. Neither of the combinations worked in consistent way: openAndWait, open + pause.

The solution in this case required change in the webapp to remove usage of the redirection (which I believe was an ugly way of dealing with the problem anyway).

Hope it will help someone with similar issues. If you know another tricks or something to avoid when using Selenium please contact me or leave a comment here.

Popularity: 94% [?]

Comments (5)

Close
E-mail It