Page 1 of 2

Sab unpack fails with some Python error

Posted: June 10th, 2019, 8:55 pm
by legoman666
Downloads fine. No missing parts

Code: Select all

2019-06-10 21:47:17,240::INFO::[newsunpack:265] 7za starting on xxx
2019-06-10 21:47:17,240::INFO::[newsunpack:947] Starting extract on 7zip set/file: xxx.7z 
2019-06-10 21:47:17,240::ERROR::[postproc:537] Post Processing Failed for xxx (see logfile)
2019-06-10 21:47:17,240::INFO::[postproc:538] Traceback: 
Traceback (most recent call last):
  File "/usr/share/sabnzbdplus/sabnzbd/postproc.py", line 382, in process_job
    unpack_error, newfiles = unpack_magic(nzo, workdir, tmp_workdir_complete, flag_delete, one_folder, (), (), (), (), ())
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 266, in unpack_magic
    error, newf = unseven(nzo, workdir, workdir_complete, dele, one_folder, new_sevens)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 955, in unseven
    res, new_files_set, msg = seven_extract(nzo, seven, extensions, extraction_path, one_folder, delete)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 983, in seven_extract
    fail, new_files, msg = seven_extract_core(sevenset, extensions, extraction_path, one_folder, delete, password)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 1034, in seven_extract_core
    stup, need_shell, command, creationflags = build_command(command)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 2006, in build_command
    if command[0].endswith('.py'):
AttributeError: 'NoneType' object has no attribute 'endswith'
Gives the same error for all files. Mint 18.3. Sab 2.3.9RC1

What is "endswith"?

Re: Sab unpack fails with some Python error

Posted: June 11th, 2019, 4:15 am
by sander
endswith means ends_with ... so a check on the last characters of a strings. In this case: command[0].endswith('.py') ... so does it end on '.py' ... in other words: is it a python script.

As this happens in postproc.py ... what kind of post-processing script did you specify?

Re: Sab unpack fails with some Python error

Posted: June 11th, 2019, 10:50 am
by Puzzled
I don't think it found the 7zip executable. Is 7z or 7za in /usr/bin/?

Re: Sab unpack fails with some Python error

Posted: June 11th, 2019, 12:12 pm
by safihre
In that case there will have been a startup error, was there?

Re: Sab unpack fails with some Python error

Posted: June 24th, 2019, 9:32 pm
by legoman666
Sorry for the long delay in replying, been out of town a lot.

There is no post processing script. The download was in the "TV" category, but all that entails is a specific unpack folder (which isn't full).

7zip is not missing as far as I can tell. I sort of remember setting up a multicore 7z bin a while back, maybe that's it? I'll look in to it more, been a while since I set it up....

Re: Sab unpack fails with some Python error

Posted: June 30th, 2019, 9:31 pm
by legoman666
Seems to be just those particular files. So not any script. Other stuff I've attempted since then has worked.

I was able to go in and extract the files manually from the sab temp folder using 7z. I think that PC has a multicore par2 bin I compiled years ago, but the files weren't missing parts. Who knows.

Anyway, thanks for the reply, guess it was just something weird about that one download.

Re: Sab unpack fails with some Python error

Posted: July 2nd, 2019, 12:40 am
by safihre
Could you maybe send me the NZB at [email protected]? So I can give it a try :)

2.3.9 AttributeError: 'NoneType' object has no attribute 'endswith' during unpack

Posted: July 6th, 2019, 12:22 pm
by wcanyon

Code: Select all

python --version
Python 2.7.15+
sabnzbdplus --version
sabnzbdplus-2.3.9
AttributeError: 'NoneType' object has no attribute 'endswith'

Code: Select all

2019-07-06 10:14:15,478::INFO::[nzbstuff:1759] [sabnzbd.nzbqueue.cleanup_nzo] Purging data for job REDACTED.S02E04.What.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb-AsRequested (keep_basic=True, del_files=False)
2019-07-06 10:14:15,476::INFO::[postproc:558] Cleaning up REDACTED.S02E04.What.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb-AsRequested (keep_basic=True)
AttributeError: 'NoneType' object has no attribute 'endswith'
    if command[0].endswith('.py'):
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 2006, in build_command
    stup, need_shell, command, creationflags = build_command(command)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 1034, in seven_extract_core
    fail, new_files, msg = seven_extract_core(sevenset, extensions, extraction_path, one_folder, delete, password)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 983, in seven_extract
    res, new_files_set, msg = seven_extract(nzo, seven, extensions, extraction_path, one_folder, delete)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 955, in unseven
    error, newf = unseven(nzo, workdir, workdir_complete, dele, one_folder, new_sevens)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 266, in unpack_magic
    unpack_error, newfiles = unpack_magic(nzo, workdir, tmp_workdir_complete, flag_delete, one_folder, (), (), (), (), ())
  File "/usr/share/sabnzbdplus/sabnzbd/postproc.py", line 382, in process_job
Traceback (most recent call last):
2019-07-06 10:14:15,475::INFO::[postproc:538] Traceback: 
2019-07-06 10:14:15,474::ERROR::[postproc:537] Post Processing Failed for REDACTED.S02E04.What.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb-AsRequested (see logfile)
Not sure what else to post here.

Re: Sab unpack fails with some Python error

Posted: July 6th, 2019, 2:22 pm
by sander
I moved this topic here, as it seems to be the same.

So ...
0) what are the 10 log lines before the part you posted? Also something with 7zip?
1) can you share the NZB, via PM/DM or otherwise
2) any postprocessing script involved?

Some technical analysis from Python side:

I think this is meant/expected as normal SAB behaviour:

Code: Select all

>>> command = ['myscript.py', 'blaPar', 'blaDir']
>>> command[0].endswith('.py')
True
Some examples how it can go wrong (Python-wise)

Code: Select all

>>> command = [None, 'blaPar', 'blaDir']
>>> command[0].endswith('.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'endswith'
>>> 
>>> command = [None]
>>> command[0].endswith('.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'endswith'
>>> 

>>> command = [None, 'myscript.py', 'blaPar', 'blaDir']
>>> command[0].endswith('.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'endswith'
>>> 
So, my guess is that somehow command[0] has become None. As the OP has no postprocessing script defined, the reason might be there ... so let's dig deeper:

Two lines before the traceback:

Code: Select all

  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 1034, in seven_extract_core
    stup, need_shell, command, creationflags = build_command(command)


In the source;

Code: Select all

    command = [SEVEN_COMMAND, method, '-y', overwrite, parm, case, password,
               '-o%s' % extraction_path, name]

    stup, need_shell, command, creationflags = build_command(command)
Ah, SEVEN_COMMAND thus None? Let's check the source:

Code: Select all

sabnzbd/newsunpack.py:83:SEVEN_COMMAND = None
Yes, None is the default value ... which causes the problem if it is not overwritten with a meaningful value.

Re: Sab unpack fails with some Python error

Posted: July 6th, 2019, 2:47 pm
by safihre
This is part of the 7zip unpacking code. Not custom post processing scripts. There might be a mistake in there.

On the first page of the Config, does it show that 7zip is missing?

Re: Sab unpack fails with some Python error

Posted: July 6th, 2019, 2:55 pm
by sander
safihre wrote: July 6th, 2019, 2:47 pm This is part of the 7zip unpacking code. Not custom post processing scripts. There might be a mistake in there.

On the first page of the Config, does it show that 7zip is missing?

... and/or check sabnzbd.log for a line like "7za binary", like

Code: Select all

2019-06-23 16:12:23,629::INFO::[sabnzbdplus:447] 7za binary... found (/usr/bin/7za)
And this is bad:

Code: Select all

2019-07-06 21:58:58,720::INFO::[sabnzbdplus:449] 7za binary... NOT found!
Solve it on Ubuntu by installing p7zip-full

Re: Sab unpack fails with some Python error

Posted: July 6th, 2019, 3:04 pm
by sander
OK, I reproduced it:

removed p7zip-full from my Ubuntu
SAB then says "7za binary... NOT found!" in sabnzbd.log
Let SAB download https://raw.githubusercontent.com/sande ... 8fcddd.nzb
... resulting in "Post Processing Failed for reftestnzb-7z-instead-of-rar-ea5b7e8fcddd (see logfile)", plus a traceback:

Code: Select all

2019-07-06 22:01:26,931::INFO::[newsunpack:265] 7za starting on /home/sander/Downloads/incomplete/reftestnzb-7z-instead-of-rar-ea5b7e8fcddd
2019-07-06 22:01:26,932::INFO::[newsunpack:947] Starting extract on 7zip set/file: /home/sander/Downloads/incomplete/reftestnzb-7z-instead-of-rar-ea5b7e8fcddd/blabla.7z 
2019-07-06 22:01:26,933::ERROR::[postproc:537] Post Processing Failed for reftestnzb-7z-instead-of-rar-ea5b7e8fcddd (see logfile)
2019-07-06 22:01:26,935::INFO::[postproc:538] Traceback: 
Traceback (most recent call last):
  File "/usr/share/sabnzbdplus/sabnzbd/postproc.py", line 382, in process_job
    unpack_error, newfiles = unpack_magic(nzo, workdir, tmp_workdir_complete, flag_delete, one_folder, (), (), (), (), ())
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 266, in unpack_magic
    error, newf = unseven(nzo, workdir, workdir_complete, dele, one_folder, new_sevens)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 955, in unseven
    res, new_files_set, msg = seven_extract(nzo, seven, extensions, extraction_path, one_folder, delete)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 983, in seven_extract
    fail, new_files, msg = seven_extract_core(sevenset, extensions, extraction_path, one_folder, delete, password)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 1034, in seven_extract_core
    stup, need_shell, command, creationflags = build_command(command)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 2006, in build_command
    if command[0].endswith('.py'):
AttributeError: 'NoneType' object has no attribute 'endswith'
IMHO SAB should not give a traceback, but a Warning.

Re: Sab unpack fails with some Python error

Posted: July 6th, 2019, 10:51 pm
by sander

Re: Sab unpack fails with some Python error

Posted: July 7th, 2019, 9:36 am
by sander
So @legoman666 and @wcanyon ... did you install 7zip / 7z / 7za / p7zip-full, restart SABnzbd, and try again with the same NZB?

Re: Sab unpack fails with some Python error

Posted: July 7th, 2019, 2:23 pm
by wcanyon
I installed p7zip-full and the error that I was seeing went away. Thanks for the assist.