Cannot run in Karmic

Asked by Mattia Cozzi

I'm trying to run gm-notify.py in Karmic, from terminal I get this:

mattia@mattia-laptop:~$ python /usr/bin/gm-notify.py
Traceback (most recent call last):
  File "/usr/bin/gm-notify.py", line 261, in <module>
    cm = CheckMail()
  File "/usr/bin/gm-notify.py", line 109, in __init__
    self.addIndicator("dummy")
  File "/usr/bin/gm-notify.py", line 212, in addIndicator
    new_indicator = indicate.IndicatorMessage()

And nothing runs. How can I fix it?

Question information

Language:
English Edit question
Status:
Solved
For:
GMail Notifier Edit question
Assignee:
No assignee Edit question
Solved by:
Jesse London
Solved:
Last query:
Last reply:
Revision history for this message
Michael Axiak (mike-axiak) said :
#1

Here's a fix:

--- gm-notify.py 2009-11-13 12:09:27.000000000 -0500
+++ gm-notify.py.old 2009-11-13 12:09:02.000000000 -0500
@@ -189,7 +189,7 @@
         increased by one. The indicator is stored in a class-list to keep the reference.
         If you delete this the indicator will be removed from the applet, too'''

- new_indicator = getattr(indicate, 'IndicatorMessage', 'Indicator')()
+ new_indicator = indicate.IndicatorMessage()
         new_indicator.set_property("subtype", "mail")
         new_indicator.set_property("sender", msg)
         new_indicator.show()

Revision history for this message
Michael Axiak (mike-axiak) said :
#2

Whoops... wrong way. Basically, it checks to see if IndicatorMessage is there. If not, use indicate.Indictor. This works in both Jaunty and Karmic.

Cheers,
Mike

--- gm-notify.py.old 2009-11-13 12:09:02.000000000 -0500
+++ gm-notify.py 2009-11-13 12:09:27.000000000 -0500
@@ -189,7 +189,7 @@
         increased by one. The indicator is stored in a class-list to keep the reference.
         If you delete this the indicator will be removed from the applet, too'''

- new_indicator = indicate.IndicatorMessage()
+ new_indicator = getattr(indicate, 'IndicatorMessage', 'Indicator')()
         new_indicator.set_property("subtype", "mail")
         new_indicator.set_property("sender", msg)
         new_indicator.show()

Revision history for this message
Mattia Cozzi (solounaterapia) said :
#3

Ok, I'm kinda noob, what do I have to do to make it run?

Revision history for this message
Michael Axiak (mike-axiak) said :
#4

They can fix this in the repository, but for now you can do this:
sudo nano -w /usr/bin/gm-notify.py
goto the following line:
  new_indicator = indicate.IndicatorMessage()
replace that line with:
  new_indicator = getattr(indicate, 'IndicatorMessage', 'Indicator')()

type CTRL-X Y (closes and save file)
then press ALT-F2, type /usr/bin/gm-notify.py

-Mike

Revision history for this message
Michael Axiak (mike-axiak) said :
#5

Rather than doing this, you might want to do this instead:

1) Open a terminal
2) At the terminal, type this:
     sudo sed -i 's/indicate\.IndicatorMessage/getattr\(indicate, "IndicatorMessage", "Indicator"\)/' /usr/bin/gm-notify.py
3) Open ALT-F2, /usr/bin/gm-notify.py

Revision history for this message
Mattia Cozzi (solounaterapia) said :
#6

I changed that line, and when I run from terminal now I get this:

mattia@mattia-laptop:~$ python /usr/bin/gm-notify.py
Traceback (most recent call last):
  File "/usr/bin/gm-notify.py", line 261, in <module>
    cm = CheckMail()
  File "/usr/bin/gm-notify.py", line 109, in __init__
    self.addIndicator("dummy")
  File "/usr/bin/gm-notify.py", line 212, in addIndicator
    new_indicator = getattr(indicate, "IndicatorMessage", "Indicator")()
TypeError: 'str' object is not callable

Sorry for bothering you :(

Revision history for this message
Best Jesse London (jesselondon) said :
#7

Hi Mattia,

I believe you can make that line work like this:

new_indicator = getattr(indicate, "IndicatorMessage", indicate.Indicator)()

or, if you don't care about making your copy of the module compatible with both Karmic and Jaunty, you could make it simpler, (as I did in my own install):

new_indicator = indicate.Indicator()

In case you're curious, the TypeError was because Python's "getattr" works a lot like its dictionary method, "get" -- the last, optional argument isn't meant to be another key to look up, but rather a default value to return.

Hope that works for you! I'm really loving the menubar integrations, so far.

Revision history for this message
Mattia Cozzi (solounaterapia) said :
#8

Ok I did as Jesse said (changed that line in "new_indicator = indicate.Indicator()") and it works perfectly, thanks a lot! And thanks Michael too :)

Revision history for this message
Mattia Cozzi (solounaterapia) said :
#9

Thanks Jesse London, that solved my question.