Page 1 of 1

[RC6] Error in par2_repair function (Linux)

Posted: February 18th, 2010, 11:04 am
by thelists
Just installed RC6.  Everything went smoothly during the installation process, and as a whole it works well unless one of the files is corrupted.  After it completes the download of of the relevant files + a couple PARs, I get the error below:

Code: Select all

::ERROR::[newsunpack:703] Error global name 'WindowsError' is not defined while running par2_repair
Per inpheaux's suggestion, I checked around line 703 for something similar to the exception handling in this forum post [http://forums.sabnzbd.org/index.php?topic=2144.0], but found nothing.

For completeness, here is the scrubbed version of the logs immediately before and after the error in question:

Code: Select all

2010-02-18 02:43:54,095::INFO::[postproc:244] Par2 check starting on FOO
2010-02-18 02:43:54,095::INFO::[postproc:251] Running repair on set FOO
2010-02-18 02:43:54,119::INFO::[newsunpack:679] Scanning "/my/path/to/nzb/incomplete/FOO
2010-02-18 02:43:54,181::ERROR::[newsunpack:703] Error global name 'WindowsError' is not defined while running par2_repair on set FOO
2010-02-18 02:43:54,181::INFO::[postproc:268] Par2 check finished on FOO
Any suggestions?

Re: [RC6] Error in par2_repair function (Linux)

Posted: February 18th, 2010, 11:54 am
by shypike
Sloppy programming on our side for assuming that a Windows-only exception is defined on Unix.
However, the root-cause is that par2 doesn't run properly.
Do you have a working par2 installed?

If you are not afraid of a little hacking, find the file newsunpack.py among the SABnzbd files.
Go to line 36 where you'll see this block:

Code: Select all

if sabnzbd.WIN32:
    try:
        import win32api
        from win32con import SW_HIDE
        from win32process import STARTF_USESHOWWINDOW, IDLE_PRIORITY_CLASS
    except ImportError:
        pass
Append this after the pass statement:

Code: Select all

else:
    # Define dummy WindowsError for non-Windows
    class WindowsError(Exception):
        def __init__(self, value):
            self.parameter = value
        def __str__(self):
            return repr(self.parameter)
Next time an error occurs you'll see what's going on.

Please report back what your results are.

Re: [RC6] Error in par2_repair function (Linux)

Posted: February 18th, 2010, 3:22 pm
by thelists
Added that code and restarted sab...

It's possible that I did a "make install" on par2 AFTER running sab the last time, but the par2 binaries were there when the errors occurred.  Could that have caused the problem?

Regardless, it's working beautifully now.

Re: [RC6] Error in par2_repair function (Linux)

Posted: February 18th, 2010, 4:59 pm
by shypike
The bad code is only hit when par2 encounters fatal errors.
Could be caused by what you did.

This will be fixed in 0.5.0Final.
Anyway: a good thing this error was detected.
Thanks for reporting it.