Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading notification class Pushover #126

Open
knoer opened this issue Nov 3, 2016 · 8 comments
Open

Error loading notification class Pushover #126

knoer opened this issue Nov 3, 2016 · 8 comments
Assignees
Milestone

Comments

@knoer
Copy link

knoer commented Nov 3, 2016

Hi, I only got around to try Autorippr today, and I must say I am impressed..
I installed the lot using the script supplied, and (almost) all is good.

Running of an old Asus eeeBox with an Atom processor running Lubuntu 14.04
Output from Uname:
Linux kasper-EB1501 3.19.0-28-generic #30~14.04.1-Ubuntu SMP Tue Sep 1 09:32:55 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Python version is 2.7.6
Autorippr version 1.7.0

I registered on pushover to make use of these notifications (and/or to avoid numerous emails to my self when ripping), but have some issues getting this to work..

So basically my settings.cfg are now:

# Enable pushover notifications
enable: True
user_key: ##myuserkey##
app_key: ##myregisteredappkey##

But, when ripping a disc, using --debug, I get the following error:

2016-11-03 22:30:43 - Notification - ERROR - Error loading notification class: pushover

Looking at classes/pushover.py, it seems to be logging something somewhere - but I have not been able to locate the logfile.. Am I missing something?

For now, I'm using pushover's EmailGateway, sending notifications to myself via my gmail (as suggested in the initial settings) and it works - but it would be nice to have this working as intended..

@JasonMillward
Copy link
Owner

The install script is missing sudo pip install pushover which is why it can't find the pushover class

@knoer
Copy link
Author

knoer commented Nov 4, 2016

Hey - thanks for the quick reply.

That would make perfect sense - I will try and install the missing package, when I get near my test machine - which, unfortunately, wont be today..
I will report back in a day or two.

Again, thanks for making this available..

@knoer
Copy link
Author

knoer commented Nov 7, 2016

So, I got around to test a little more on this during the weekend.
Installed pushover through pip, as suggested, but it still throws the same error.

When I installed using sudo pip install pushover there was a mention of incorrect permissions on ~/.cache/pushover/
So I did a very generous chmod on both ~/Autorippr/ and ~/.cache/pushover/ - though it did not make a difference..

I'm being prompted to update to 16.10 - which I'll gladly do - but am holding off for now..
(In the end, when/if I get this sorted, I will do a clean install on a more powerful machine)

Are there anyone else using Pushover for notifications?
Any suggestions to how I can pull more information out regarding this error?
Does anyone have an idea/code snippet to test pushover on its own, so it can be debugged without having to feed Autorippr with movies? ;-)

I'm happy to provide any and all information I can to assist..

@JasonMillward
Copy link
Owner

Can you try sudo pip install python-pushover as well please?

@knoer
Copy link
Author

knoer commented Nov 7, 2016

Sure.. I just managed to install it remotely.

I started a rip this morning, which is has been compressing for half an hour or so (it takes a while on an Atom, in case anyone wonders ;-) )
I will report back when the current job finishes..

Thanks.

@knoer
Copy link
Author

knoer commented Nov 7, 2016

Unfortunately, this was not the solution to my problem.
The job that finished this afternoon also "only" sent me a notification via gmail to pushovers email gateway.

I did some rough debugging - inserting log "info" entries at various points in the code.
What I got to was that it seems the code enters the try in this function in notification.py (I inserted a debug line adding info messages in the log before each method_class in the following snippet) but it never got to the second line starting with method_class

 def _send(self, status):
        for method in self.config['methods']:
            if bool(self.config['methods'][method]['enable']):
                try:
                    method_class = self.import_from('classes.{}'.format(
                        method), method.capitalize(), self.config['methods'][method])
                    method_class.send_notification(status)
                    del method_class
                except ImportError:
                    self.log.error(
                        "Error loading notification class: {}".format(method))

Just now I got to wonder if it has something to do with me having both smtp & pushover activated in settings.cfg?
Just in case, I have just now set smtp to False in settings.cfg, just to be able to rule this out...
I am currently running another compression job, but the next disc is in the drive, so I will return with an update, when it's done.

@knoer
Copy link
Author

knoer commented Nov 8, 2016

tl;dr
installing missing package chump and removing a capitalization in notification.py fixed this issue

One more (long) update on this:

Setting smtp to false in settings.cfg did not make a difference - I do still not get messages directly from pushover.

Yesterday, I created a virtual machine (Lubuntu 16.10) to test this on a clean install - and installed Autorippr with the updated install script (including pip install pushover) but even this install behaves the same way as my first.

Adding the previously mentioned self.log.info entries in notfification.py as so:

    def _send(self, status):
        for method in self.config['methods']:
            if bool(self.config['methods'][method]['enable']):
                self.log.info("loading notification class before try")
                try:
                    self.log.info("loading notification class part1")
                    method_class = self.import_from('classes.{}'.format(
                        method), method.capitalize(), self.config['methods'][method])
                    self.log.info("loading notification class part2")
                    method_class.send_notification(status)
                    del method_class
                except ImportError:
                    self.log.error(
                        "Error loading notification class: {}".format(method))

Gives the following log output:

2016-11-08 10:47:31 - Notification - INFO - loading notification class before try
2016-11-08 10:47:31 - Notification - INFO - loading notification class part1
2016-11-08 10:47:31 - Notification - ERROR - Error loading notification class: pushover

Assuming the error originated from this line:
method_class = self.import_from('classes.{}'.format(method), method.capitalize(), self.config['methods'][method])
I started experimenting with pdb, setting a pdb.set_trace() before the above line

kn@kn-virtual-machine:~/Autorippr$ python autorippr.py --rip --debug
2016-11-08 11:49:15 - Rip - DEBUG - Ripping initialised
2016-11-08 11:49:15 - Notification - INFO - trying method pushover
2016-11-08 11:49:15 - Notification - INFO - loading notification class part1
> /home/kn/Autorippr/classes/notification.py(38)_send()
-> method_class = self.import_from('classes.{}'.format(method), method.capitalize(), self.config['methods'][method])
(Pdb) p method
'pushover'
(Pdb) n
ImportError: 'No module named chump'
> /home/kn/Autorippr/classes/notification.py(38)_send()
-> method_class = self.import_from('classes.{}'.format(method), method.capitalize(), self.config['methods'][method])

Now, suddenly, it is complaining about chump?

  • feeling experimental, I installed it using sudo pip install chump, which led to the following output:
kn@kn-virtual-machine:~/Autorippr$ python autorippr.py --rip --debug
2016-11-08 11:54:04 - Rip - DEBUG - Ripping initialised
2016-11-08 11:54:04 - Notification - INFO - trying method pushover
2016-11-08 11:54:04 - Notification - INFO - loading notification class part1
Traceback (most recent call last):
  File "autorippr.py", line 434, in <module>
    rip(config)
  File "autorippr.py", line 134, in rip
    notify.rip_fail("title")
  File "/home/kn/Autorippr/classes/notification.py", line 54, in rip_fail
    self._send(status)
  File "/home/kn/Autorippr/classes/notification.py", line 38, in _send
    method_class = self.import_from('classes.{}'.format(method), method.capitalize(), self.config['methods'][method])
  File "/home/kn/Autorippr/classes/notification.py", line 28, in import_from
    class_ = getattr(module, name)
AttributeError: 'module' object has no attribute 'Pushover'

(I did a change to notify.rip_fail() allowing me to test without passing dbvideo as a paramter)

Having thought about the meaning of method.capitalize() in the line that started it all, I (experimentally) removed .capitalize() to avoid capitalization, yielding:
method_class = self.import_from('classes.{}'.format(method), method, self.config['methods'][method])

Then, I tried again

kn@kn-virtual-machine:~/Autorippr$ python autorippr.py --rip --debug
2016-11-08 11:56:38 - Rip - DEBUG - Ripping initialised
2016-11-08 11:56:38 - Notification - INFO - trying method pushover
2016-11-08 11:56:38 - Notification - INFO - loading notification class part1
2016-11-08 11:56:38 - Notification - INFO - loading notification class part2
2016-11-08 11:56:39 - Pushover - INFO - Pushover message sent successfully

HEY - bing-bong - a message appeared on my phone!

So, in short, installing chump and removing a capitalization solved this for me on my virtual test machine.
I will implement these changes on my working/ripping machine, test, and, in case this keeps working for both pushover and smtp notifications. issue a pull request..

@knoer
Copy link
Author

knoer commented Nov 30, 2016

Sorry for the delay - it has been running fine with my modifications since my last post, so I assume it is ready for a commit. Will look into this in one of the next days, and issue a pull request.

I did add another minor edit to the notification system; a message when ripping actually starts (DVD title(s) found and passed on to MakeMKV).
I found it nice to get a confirmation that something was found on the disc (matching the title lengths in settings.cfg), and get a confirmation within a couple of minutes after inserting the disc for ripping.

I will embed this in the existing notification system, so this can be turned on/off via settings.cfg with new parameter "start"

 # Notify on these events
 # start: title(s) found on disc - ripping started
 # rip: rip complete
 # compress: compression complete
 # extra: subtitles, renaming etc. complete
    notify_on_state:         start, rip, compress, extra

Still very pleased with this script 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants