Make wait_for_status robust against multiple calls at different times.

This change removes the dependency between wait_for_status? and
download? by checking for the staged directory if there is the
equivalent of a "cache" miss from the downloader_dict.

I also clean up a previous assumption in the downlaoder.

BUG=chromium-os:27285
TEST=Unittests + download followed by wait_for_status with
same archive_url and different.  Got all expected results.
Also ran pylint on both devserver and downloader and fixed a cpl
bugs it caught.

Change-Id: I8c187cd64e40c12442de3e4be8fd4c12db7958f3
Reviewed-on: https://gerrit.chromium.org/gerrit/19263
Commit-Ready: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/devserver.py b/devserver.py
index 9249314..2529581 100755
--- a/devserver.py
+++ b/devserver.py
@@ -24,7 +24,7 @@
 updater = None
 
 
-def DevServerError(Exception):
+class DevServerError(Exception):
   """Exception class used by this module."""
   pass
 
@@ -251,7 +251,12 @@
       self._downloader_dict[archive_url] = None
       return downloader_instance.GetStatusOfBackgroundDownloads()
     else:
-      raise DevServerError('No download for the given archive_url found.')
+      # We may have previously downloaded but removed the downloader instance
+      # from the cache.
+      if downloader.Downloader.BuildStaged(archive_url, updater.static_dir):
+        return 'Success'
+      else:
+        raise DevServerError('No download for the given archive_url found.')
 
   @cherrypy.expose
   def latestbuild(self, **params):
@@ -409,7 +414,8 @@
   if os.path.exists(cache_dir):
     if options.clear_cache:
       # Clear the cache and exit on error.
-      if os.system('rm -rf %s/*' % cache_dir) != 0:
+      cmd = 'rm -rf %s/*' % cache_dir
+      if os.system(cmd) != 0:
         cherrypy.log('Failed to clear the cache with %s' % cmd,
                      'DEVSERVER')
         sys.exit(1)