Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:49:45+00:00 2026-06-13T04:49:45+00:00

Full script here: http://pastebin.com/d6isrghF I’ll admit I’m very new to Python so please forgive

  • 0

Full script here: http://pastebin.com/d6isrghF

I’ll admit I’m very new to Python so please forgive my stupidity if this is an easy question to answer. The section in question is this:

sourcePath = jobPath
while os.path.basename(sourcePath):
    if os.path.basename(os.path.dirname(sourcePath)).lower() == category.lower():
        break
    else:
        sourcePath = os.path.dirname(sourcePath)
if not os.path.basename(sourcePath):
    print "Error: The download path couldn't be properly determined"
    sys.exit()

jobPath is being fed to the script from sabnzbd and is:

/mnt/cache/.apps/sabnzbd/complete/name.of.folder

category is:

tv

So I guess my question is: why is this failing with the error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:49:46+00:00Added an answer on June 13, 2026 at 4:49 am

    Why it does not work

    Your code cannot work because while is executed until os.path.basename(sourcePath) is not evaluated to True, then if statement is called, which (because it looks like: if not os.path.basename(sourcePath)) is obviously evaluated as True and thus the message (your “error”) is shown:

    Annotated source code

    sourcePath = jobPath
    
    # This is executed until os.path.basename(sourcePath) is evaluated as true-ish:
    while os.path.basename(sourcePath):
        if os.path.basename(os.path.dirname(sourcePath)).lower() == category.lower():
            break
        else:
            sourcePath = os.path.dirname(sourcePath)
    
    # Then script skips to the remaining part, because os.path.basename(sourcePath)
    # has been evaluated as false-ish (see above)
    
    # And then it checks, whether os.path.basename(sourcePath) is false-ish (it is!)
    if not os.path.basename(sourcePath):
        print "Error: The download path couldn't be properly determined"
        sys.exit()
    

    When (and why) it sometimes works

    It sometimes works only because category is found in the path, which means while loop will be exited (using break) even despite still meeting criteria (the condition after while keyword: os.path.basename(sourcePath)). Because the condition from while loop is still met (we exited the loop even though it was met), the next statement’s condition (not os.path.basename(sourcePath)) is no longer met and the message (“the error”) is not printed.

    Possible solutions

    I believe one of the solutions is to add a counter to your code, that will print the error only if in specific number of iterations you will not be able to find what you needed. You can also try to catch “too many recursions” exception (if you will use recursion, of course, but the error will be like this: RuntimeError: maximum recursion depth exceeded).

    However, you should redesign it rather to meet your own needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working example is here (this script deals with the triangle animation) http://movable.pagodabox.com/ full code
I've been using your fullBg script found here: http://bavotasan.com/2011/full-sizebackground-image-jquery-plugin/ (function($) { $.fn.fullBg = function(){
THIS IS THE FULL SCRIPT http://goo.gl/HoCxk I have a problem with this function: $('.message').click(function(){
I want obtain full URL adres in php script, tell please, this code always
I am having trouble displaying the jQuery datepicker as shown here: http://jqueryui.com/demos/datepicker/ I believe
I've downloaded my accordion from here: http://www.snyderplace.com/demos/accordion.html and was told by my boss that
Here is the full sample script which demonstrates the problem, inner tabs company/department come
Full source here: http://www.vim.org/scripts/download_script.php?src_id=10391 The line is: silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=\\\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/λ\1/eg Someone please decipher this for
OK, so I am using a jQuery plugin called CountUp: http://blog.ogulcanorhan.com/weekend-project-jquery-countup-plugin/ The script is
I am using an horizontal accordion from here: http://www.dynamicdrive.com/dynamicindex17/haccordion.htm I got it to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.