Sab unpack fails with some Python error

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
legoman666
Newbie
Newbie
Posts: 7
Joined: November 28th, 2012, 7:59 pm

Sab unpack fails with some Python error

Post by legoman666 » June 10th, 2019, 8:55 pm

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"?

User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » June 11th, 2019, 4:15 am

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?

Puzzled
Newbie
Newbie
Posts: 42
Joined: September 2nd, 2017, 3:02 am

Re: Sab unpack fails with some Python error

Post by Puzzled » June 11th, 2019, 10:50 am

I don't think it found the 7zip executable. Is 7z or 7za in /usr/bin/?

User avatar
safihre
Administrator
Administrator
Posts: 3304
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Sab unpack fails with some Python error

Post by safihre » June 11th, 2019, 12:12 pm

In that case there will have been a startup error, was there?

legoman666
Newbie
Newbie
Posts: 7
Joined: November 28th, 2012, 7:59 pm

Re: Sab unpack fails with some Python error

Post by legoman666 » June 24th, 2019, 9:32 pm

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....

legoman666
Newbie
Newbie
Posts: 7
Joined: November 28th, 2012, 7:59 pm

Re: Sab unpack fails with some Python error

Post by legoman666 » June 30th, 2019, 9:31 pm

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.

User avatar
safihre
Administrator
Administrator
Posts: 3304
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Sab unpack fails with some Python error

Post by safihre » July 2nd, 2019, 12:40 am

Could you maybe send me the NZB at [email protected]? So I can give it a try :)

wcanyon
Newbie
Newbie
Posts: 25
Joined: October 15th, 2011, 11:50 pm

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

Post by wcanyon » July 6th, 2019, 12:22 pm

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.

User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » July 6th, 2019, 2:22 pm

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.

User avatar
safihre
Administrator
Administrator
Posts: 3304
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Sab unpack fails with some Python error

Post by safihre » 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?

User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » July 6th, 2019, 2:55 pm

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

User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » July 6th, 2019, 3:04 pm

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.

User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » July 6th, 2019, 10:51 pm


User avatar
sander
Release Testers
Release Testers
Posts: 6738
Joined: January 22nd, 2008, 2:22 pm

Re: Sab unpack fails with some Python error

Post by sander » July 7th, 2019, 9:36 am

So @legoman666 and @wcanyon ... did you install 7zip / 7z / 7za / p7zip-full, restart SABnzbd, and try again with the same NZB?

wcanyon
Newbie
Newbie
Posts: 25
Joined: October 15th, 2011, 11:50 pm

Re: Sab unpack fails with some Python error

Post by wcanyon » July 7th, 2019, 2:23 pm

I installed p7zip-full and the error that I was seeing went away. Thanks for the assist.

Post Reply