Page 1 of 1

"on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 10:48 am
by tornzbd
recently upgraded from 2.3.9 to 3.0.1 on windows 7 and found that the script i have set to execute "on finish queue" no longer appears to actually execute

i also tried 3.0.2 RC1 and then completely removed sabnzbd and reinstalled 3.0.1 and none of that seemed to help

was going to revert back to 2.3.9 next but figured it was worth a shot to see if anyone else experienced the same

by the way, the log does show it was executed but nothing really happened. here's the relevant log output:

Code: Select all

2020-08-23 11:32:58,354::INFO::[postproc:433] Finished unpack_magic on [**removed**]
2020-08-23 11:32:58,637::INFO::[nzbstuff:1795] [N/A] Purging data for job [**removed**] (delete_all_data=True)
2020-08-23 11:32:58,650::INFO::[database:290] Added job [**removed**] to history
2020-08-23 11:32:58,651::INFO::[postproc:132] Saving postproc queue
2020-08-23 11:32:58,653::INFO::[downloader:310] Post-processing finished, resuming download
2020-08-23 11:33:02,681::INFO::[nzbqueue:225] Saving queue
2020-08-23 11:33:02,699::INFO::[postproc:132] Saving postproc queue
2020-08-23 11:33:02,701::INFO::[postproc:992] Queue has finished, launching: <function run_script at 0x000000000540C160> (script.bat)
2020-08-23 11:33:02,701::INFO::[__init__:855] Spawning external command "\\?\X:\script.bat"
any input would be greatly appreciated, thank you!

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 3:15 pm
by sander
Can you tell how / where you specificied the on-finish-queue action?

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 3:24 pm
by tornzbd
just on the main ui using the drop down list that says "on queue finish" from the hamburger menu

i've selected my windows batch file (script.bat) and the hamburger menu icon turns red when it's selected

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 3:37 pm
by sander
Ah, the hamburger menu! :-)

On my Linux, it just works. And the script done.sh does really run (although twice, according to logging?).

How do you know your script 1) works at all and 2) is not run by the on-finish-queue ?

Code: Select all

2020-08-23 22:32:55,601::INFO::[newsunpack:268] Running user script /home/sander/.sabnzbd/scripts/done.sh(queue_done, SABnzbd: Queue finished)
2020-08-23 22:32:55,625::INFO::[notifier:365] Successfully executed notification script /home/sander/.sabnzbd/scripts/done.sh
2020-08-23 22:32:55,628::INFO::[postproc:994] Queue has finished, launching: <function run_script at 0x7ff7798ce0d0> (done.sh)
2020-08-23 22:32:55,628::INFO::[__init__:861] Spawning external command ['/home/sander/.sabnzbd/scripts/done.sh']
Out of curioisity: what did SAB 2.x say at "Queue has finished, launching: <function run_script at 0x7ff7798ce0d0> (done.sh)"? I find the "<function run_script at 0x7ff7798ce0d0> " a bit strange.

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 5:02 pm
by tornzbd
i know it works because it was running flawlessly before i upgraded from 2.3.9 to 3.0.1 and then it stopped immediately after

also i can still execute script.bat manually and it performs what i want it to

it just no longer does so automatically when the queue completes like it used to, even though log oddly does still show that it was executed

and good call! i just pulled up a log prior to the upgrade and i see the following with regards to executing the script:

Code: Select all

2020-08-15 22:55:31,697::INFO::[nzbqueue:260] Saving queue
2020-08-15 22:55:31,730::INFO::[postproc:94] Saving postproc queue
2020-08-15 22:55:31,732::INFO::[postproc:814] Queue has finished, launching: <function run_script at 0x0000000004119438> (script.bat)
2020-08-15 22:55:31,733::INFO::[__init__:829] Spawning external command "X:\script.bat"
i find it interesting that the spawning external command on 2.3.9 shows:
Spawning external command "X:\script.bat"

whereas on 3.0.1 it shows:
Spawning external command "\\?\X:\script.bat"

hopefully someone can shed some light on that, but i think we might be getting somewhere now. thank you!

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 23rd, 2020, 6:17 pm
by tornzbd
i was curious so looked through the source code for 2.3.9 and 3.0.1, and while i'm not very familiar with python i think i may have spotted the issue

2.3.9:
run_script(script) calls cfg.script_dir.get_path()
get_path(self) calls sabnzbd.misc.real_path(self.__root, value)
real_path(loc, path) returns os.path.normpath(os.path.abspath(path))

3.0.1:
run_script(script) calls cfg.script_dir.get_path()
get_path(self) calls real_path(self.__root, value)
real_path(loc, path) returns long_path(os.path.normpath(os.path.abspath(path)))

the key difference is that 3.0.1 returns long_path of the same location as 2.3.9 and that function is defined as:

Code: Select all

def long_path(path):
    """ For Windows, convert to long style path; others, return same path """
    if sabnzbd.WIN32 and path and not path.startswith("\\\\?\\"):
        if path.startswith("\\\\"):
            # Special form for UNC paths
            path = path.replace("\\\\", "\\\\?\\UNC\\", 1)
        else:
            # Normal form for local paths
            path = "\\\\?\\" + path
    return path
and this is exactly why i think we're going from the command on 2.3.9 being:
Spawning external command "X:\script.bat"

to the command on 3.0.1 being:
Spawning external command "\\?\X:\script.bat"

so if i'm on the right track here simply removing long_path on the return statement in 3.0.1 would correct the issue

how can i get someone to double check me and get this corrected?

Re: "on finish queue" script no longer executes even though log shows otherwise

Posted: August 24th, 2020, 2:14 am
by safihre
You are right :)
Missed that one! Will fix for 3.0.2