Commandline --set-rating=N fails to update rating

Bug #568125 reported by Jasper A. Visser on 2010-04-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Exaile
Invalid
Medium
Unassigned

Bug Description

The commandline option --set-rating isn't updating the rating of the current track. Even with --debug or --eventdebug, no error is produced either.

I've tracked the bug down to two errors in xl/xldbus.py and compiled this diff to illustrate:

@@ -109,8 +109,8 @@

     for command in modify_commands:
         value = getattr(options, command)
- if value:
- iface.SetTrackAttr(command[3:].lower(), value)
+ if value:
+ iface.SetTrackAttr(command[4:].lower(), value)
             comm = True

     volume_commands = (
@@ -228,7 +228,7 @@
             Sets rating of a track
         """
         try:
- set_attr = getattr(self.exaile.player.current, 'set_' + attr)
+ set_attr = getattr(self.exaile.player.current, attr)
             set_attr(value)
         except AttributeError:
             pass

The first problem is that if command == "SetRating", then command[4:].lower() == "ating". This should obviously be "rating". ;)

The second problem is that class Track has no attribute called "rating". The setter is called "set_rating". Hence the need to prefix "set_".

I'm kind of new to this open source way of working, so I have no idea yet how to submit these changes properly. I hope posting it here suffices for now.

Yours,

Jasper

I should add that this bug applies to version 0.3.1b.

Aren Olson (reacocard) on 2010-04-21
Changed in exaile:
importance: Undecided → Medium
milestone: none → 0.3.1.2
status: New → Confirmed
Mathias Brodala (mathbr) wrote :

I cannot confirm this. --set-rating works just fine. Did you pass proper values ranging from 0 to 100?

Changed in exaile:
status: Confirmed → Incomplete

Yes, the exact command I executed is:
exaile --set-rating=4
It doesn't change the rating of the current track.

When I look at xldbus.py, line 106-114, I see this relevant part:

    modify_commands = (
           'SetRating',
           )

    for command in modify_commands:
        value = getattr(options, command)
        if value:
            iface.SetTrackAttr(command[4:].lower(), value)
            comm = True

If I place "print command[4:].lower()" right after "value = ...", it prints: "ating", not "rating". I'm no Python expert (in fact, this is the first time I look at Python code), but as far as I can tell Python strings are zero-based.

And when I look at lines 226-232 of the same file, I see:
        def SetTrackAttr(self, attr, value):
        """
            Sets rating of a track
        """
        try:
            set_attr = getattr(self.exaile.player.current, attr)
            set_attr(value)
        except AttributeError:
            pass
        except TypeError:
            pass

Hence, it's trying to obtain a handle on a function named "ating" (or "rating", if the first problem is fixed) for the class Track. It can't find that handle, and it will raise an AttributeError. If I catch this error, it tells me:
Traceback (most recent call last):
  File "/usr/local/lib/exaile/xl/xldbus.py", line 231, in SetTrackAttr
    set_attr = getattr(self.exaile.player.current, attr)
AttributeError: 'Track' object has no attribute 'rating'

In the class Track, I do find a method called "set_rating", which seems to be the intended target.

Mathias Brodala (mathbr) wrote :

A value of 4 is way to low to notice. Since the default rating steps are 5 stars, you won’t see anything with just 4%. Or did you call --get-rating afterwards?

And where exactly are you taking your code from? Neither trunk nor 0.3.1.x has code like the one mentioned by you:
http://bazaar.launchpad.net/~exaile-devel/exaile/0.3.1.x/annotate/head%3A/xl/xldbus.py#L104

Ah, my bad. This must be the remnants of some 0.3.2 build I installed a few months ago, when I couldn't get 0.3.1 to behave well. It reports the version as 0.3.1b and I do have the main branch installed as well, hence the confusion.

Sorry.

Mathias Brodala (mathbr) wrote :

Closing then.

Changed in exaile:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers