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

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.
Post Reply
tornzbd
Newbie
Newbie
Posts: 4
Joined: August 23rd, 2020, 9:44 am

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

Post 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!
User avatar
sander
Release Testers
Release Testers
Posts: 8830
Joined: January 22nd, 2008, 2:22 pm

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

Post by sander »

Can you tell how / where you specificied the on-finish-queue action?
tornzbd
Newbie
Newbie
Posts: 4
Joined: August 23rd, 2020, 9:44 am

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

Post 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
User avatar
sander
Release Testers
Release Testers
Posts: 8830
Joined: January 22nd, 2008, 2:22 pm

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

Post 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.
tornzbd
Newbie
Newbie
Posts: 4
Joined: August 23rd, 2020, 9:44 am

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

Post 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!
tornzbd
Newbie
Newbie
Posts: 4
Joined: August 23rd, 2020, 9:44 am

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

Post 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?
User avatar
safihre
Administrator
Administrator
Posts: 5366
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post by safihre »

You are right :)
Missed that one! Will fix for 3.0.2
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply