Why is os.path.basename() making my HTPC script fail?
<p>Full script here: <a href="http://pastebin.com/d6isrghF" rel="nofollow">http://pastebin.com/d6isrghF</a></p>

<p>I'll admit I'm <strong><em>very</em></strong> new to Python so please forgive my stupidity if this is an easy question to answer. The section in question is this:</p>

<pre><code>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()
</code></pre>

<p>jobPath is being fed to the script from sabnzbd and is:</p>

<pre><code>/mnt/cache/.apps/sabnzbd/complete/name.of.folder
</code></pre>

<p>category is:</p>

<pre><code>tv
</code></pre>

<p>So I guess my question is: why is this failing with the error?</p>
