caronc / nzb-notify

Push Notifications to a large number of supported services for NZBGet and SABnzbd (based on Apprise)
GNU General Public License v3.0
129 stars 15 forks source link

Python Error with NZBGet 16.0-testing-r1353 (No Notifications). #3

Closed gibxxi closed 9 years ago

gibxxi commented 9 years ago

Hi Chris, this is the first attempt at trying this script since the issues with growl last week.

Still not getting any notifications passed from NZBGet. Bear in mind this is being run on my Asustor AS5104T NAS, and is a custom Linux distribution by ASUS. All other built-in NZBGet python scripts are running as expected.

The following was found in the NZBGet logs:

process-script Notify.py for {Title Name Here} Wed Aug 5 23:40:46 2015 1438814446 INFO Notify: env: can't execute 'python ': No such file or directory Wed Aug 5 23:40:46 2015 1438814446 ERROR Post-process-script Notify.py for {Title Name Here} (terminated with unknown status)

(The NZB Title has been removed/replaced).

This was a category-based script call, i.e: Notify.py specified in the "Movies" category. However, not getting any notifications when items get added to the queue or any other activities either. CLI still working when sent manually as we tested it last week. It has been added to the relevant sections in the "Extension Scripts" section of NZBGet (PostScript and QueueScript).

Dan/Gib.

caronc commented 9 years ago

That's strange; the OS that hosts your NAS (the custom Linux distribution) basically can't determine where your python executable is from your environment. You could try changing the very first line of Notify.py which currently reads:

#!/usr/bin/env python

And change it to:

#!/usr/bin/env python2

If that doesn't work; here is another line that might solve the issue.

#!/usr/bin/python

You could peak at what your other working (python) scripts have as their first line and use it too. But the current method in place is preferred. If you feel ambitious; you could report it to ASUS too (as they aren't correctly supporting the /usr/bin/env command which was designed to make things like this easy) :).

One more small note; the script currently doesn't support python v 3.x at this time. I don't think there is much effort involved to make it work with it; but i just haven't had time. So hopefully your NAS is running a copy of python v2.x instead (most people haven't made the switch yet anyway so you're probably safe here).

gibxxi commented 9 years ago

It's running Python 2.7.3 (r13) as reported by the App Center on the NAS. The Python package is a user-installable package not shipped with the unit by default. I'll try to locate where it's stored and compare with your code samples. Even though this is ASUS' own Linux distribution, it must be based on an existing distro I would of thought.

Netgear NASes use Debian primarily, although heavily customized / stripped down. This isn't like those as the file/folder structure is noticeably different.

Will report back if I get any success.

gibxxi commented 9 years ago

Just checked Email.py, the built-in email script for NZBGet, and the first line in that file is the same as in yours. Email.py is working fine, yours isn't.

One thing I did notice is the import statements differ:

Email.py:

import os import sys import datetime (removed smtplib line as it's not relevant)

Notify.py:

import sys import re from os.path import join from os.path import dirname from urllib import unquote

In any case, simply typing "python" in the terminal window starts python fine. However it's not located in /usr/bin or usr/bin/env. No python-related files in that folder (/usr/bin) and that folder has no sub-folders at all.

caronc commented 9 years ago

You can type the following to predetermine that if you want. Also you can take the very first line from the Email.py file and place it in the Notify.py if you want; (just the #!/path/to.. line though).

# find out which executable we're calling
which python

Make sure Notify.py is executable too:

chmod 755 /path/to/Notify.py
gibxxi commented 9 years ago

I found it. It's located in usr/local (symlinked to folder .@Plugins)/bin/python.

I've also made Notify.py "Executable" as it was missing that permission.

caronc commented 9 years ago

Great! If you have some way of adding it to your global path; that would probably fix the /usr/bin/env issue. Keep me posted if all goes well or not. If not pass along the new error message so we can dig deeper!

# Something like:
export PATH=$PATH:/path/to/plugins/bin
gibxxi commented 9 years ago

No joy. It seems (sitting at this end) that NZBGet simply isn't using the script. I don't know why. I've set all the options for the script within NZBGet itself, but the "Notify.py" file remains unchanged from defaults. i.e: the options section in the actual file is stock, is this supposed to be the case?

Nothing gets sent notifications-wise. The error I sent last night showed up in the queue log folder in NZBGet (Download folder/NZBGet/Queue).

The reason I'm suspicious is that on several occasions I've noticed that my settings for your script all get reset to defaults within NZBGet. This might be on a NAS reboot, I don't know at this stage. I'll look at it again on my days off, I have to work tonight, so I'm out of time today.

CLI notifications are working fine, but nothing triggered from within NZBGet apart from the scripts it's bundled with seem to be working for me. The addon was authored by the same guy who makes the nzbtomedia scripts (Clinton Hall) so he must have an Asustor NAS too. I'm simply at a loss as to why this isn't working.

caronc commented 9 years ago

Yeah, that's definitely not cool at all. I noticed you said you're using NZBGet v16. What if you try falling back to an earlier version (I'm still using v15 at home at the moment)? I'm not saying that's the solution; but you never know. If your settings aren't being correctly saved, then that tells me that NZBGet is having a hard time writing it's configuration it uses to disk (after you set it). Remember that you also need to Reload NZBGet after you update the configuration (but it's pretty good for telling you that and putting the Reload button right in your face afterwards). :)

Now I use a custom build of NZBGet where i actually specifically patch this very thing (because I wanted my conf details to be saved in my /home/user/dir). What you could do is locate the current configuration file; it might be something like /usr/local/share/nzbget/nzbget.conf by i can't promise you that (I've never used the NAS you have). But if you can locate it; try making sure the file is writeable.

chmod ug+w /path/to/nzbget.conf

Under the hood NZBGet uses a template file that it reads to give you the basic information already pre-loaded. Then afterwards when you hit save (after making an update), it rights to a different location (leaving the template as it was).

Sooo for this reasons, there may be several .conf files (not sure) (and thus chmod'ing the template won't help you).

One thing you can try though is from the System menu (in the NZBGet Configuration), choose Backup Settings. It'll export you a small file... but more importantly try importing that file back using the Restore Settings. I'm curious to know if that works, or if it spits back an error like 'can't save configuration' or something.

Anyway maybe it'll shed more light on the directly that it can't save the configuration to. I'm not an NZBGet developer; but right now the issue definitely may just be related to the environment not being correctly set the way you want it (like you're already eluding to).

gibxxi commented 9 years ago

Well i just looked at the NZBGet logs again for another test snatch, and have seen the following entries:

Thu Aug 06 2015 17:00:39 Executing post-process-script Notify.py for {Item Name Removed} Thu Aug 06 2015 17:00:39 Notify: Fixing permissions for /usr/local/AppCentral/nzbget/nzbget/scripts/Notify.py

Well that shouldn't be needed as the permissions for Notify.py were already fixed. The file was uploaded to the NAS as the "admin" user, (not root), which is the same user I believe NZBGet runs under, and the permissions were/are 755...

Thu Aug 06 2015 17:00:39 Notify: Could not start /usr/local/AppCentral/nzbget/nzbget/scripts/Notify.py: Permission denied Thu Aug 06 2015 17:00:39 Post-process-script Notify.py for {Item name removed} failed (terminated with unknown status)

I did notice my category for "Movies" was incorrect in CouchPotato, but this shouldn't prevent the Queue notifications working, just the post-processing ones. I will try your suggestions when I get time. The Updates aren't part of the add-on, they are distributed via in-app updates, so I may try reverting to stock, and see. Only thing there is, I think every release I've seen compatible with this NAS is a form of Beta, if memory serves. Will look at it again in a few days.

gibxxi commented 9 years ago

I have reverted NZBGet to version 15, which also meant having to re-copy the Notify script to the NAS as the folder contents were deleted. Also double checked my config settings within NZBGet and it now seems to work as expected.

I'm not completely sure the reversion is what fixed it, as there were a couple of other things settings-wise I changed, but it is now working as expected. I will wait for a "stable" release of NZBGet 16 before upgrading again.

Dan/Gib.