Get xbuddy to work with image_to_live correctly.

There's a lot of small issues here that just piled up. XBuddy pretty
much didn't work at all with image_to_live -- xbuddy:parrot/latest-canary/test
just threw errors. This CL fixes that and addresses some other issues I found
along the way.

1) Added a new flag to xbuddy to return an update_url and had image_to_live
use this specifically rather than rely on --pregenereate_update hack that
FLAGS_image uses.
2) Killed log_thread. This always left a hanging log because of -t -t because
it effectively disconnected the thread from the main script.
3) Optimized update worfklow (from 1) to try to download test / stateful
from GS if they are available as downloading the whole image + processing
an update sucks.
4) Cleaned up some docstrings and fixed board overrides.
5) Piped dev image logic through.

BUG=None
TEST=all unittests, image_to_live with various xbuddy strings and FLAGS_image
+ AU vm tests in CQ.

Change-Id: I4e60394451f7ff3e31be48167d32240160c18895
Reviewed-on: https://chromium-review.googlesource.com/171260
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index 36bc562..9a45b69 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -119,13 +119,12 @@
 
     common_util.IsInsideChroot().AndReturn(True)
     self._xbuddy._GetArtifact(
-        [''], self.test_board, lookup_only=True).AndReturn(
+        [''], board=self.test_board, lookup_only=True).AndReturn(
             (latest_label, constants.TEST_IMAGE_FILE))
 
     au_mock.GenerateUpdateImageWithCache(
         os.path.join(self.static_image_dir, self.test_board, self.latest_dir,
-                     constants.TEST_IMAGE_FILE),
-        static_image_dir=latest_image_dir).AndReturn('update.gz')
+                     constants.TEST_IMAGE_FILE)).AndReturn('update.gz')
 
     self.mox.ReplayAll()
     test_data = _TEST_REQUEST % self.test_dict
@@ -150,18 +149,17 @@
     cache_image_dir = os.path.join(self.static_image_dir, 'cache')
 
     # Mock out GenerateUpdateImageWithCache to make an update file in cache
-    def mock_fn(_image, static_image_dir):
+    def mock_fn(_image):
       print 'mock_fn'
       # No good way to introduce an update file during execution.
-      cache_dir = os.path.join(static_image_dir, 'cache')
+      cache_dir = os.path.join(self.static_image_dir, 'cache')
       common_util.MkDirP(cache_dir)
       update_image = os.path.join(cache_dir, constants.UPDATE_FILE)
       with open(update_image, 'w') as fh:
         fh.write('')
 
     common_util.IsInsideChroot().AndReturn(True)
-    au_mock.GenerateUpdateImageWithCache(forced_image,
-        static_image_dir=self.static_image_dir).WithSideEffects(
+    au_mock.GenerateUpdateImageWithCache(forced_image).WithSideEffects(
         mock_fn).AndReturn('cache')
 
     common_util.GetFileSha1(os.path.join(
@@ -195,7 +193,7 @@
     au_mock.forced_image = "xbuddy:b/v/a"
 
     self._xbuddy._GetArtifact(
-        ['b', 'v', 'a'], None).AndReturn(('label', constants.TEST_IMAGE_FILE))
+        ['b', 'v', 'a']).AndReturn(('label', constants.TEST_IMAGE_FILE))
 
     au_mock.GetUpdateForLabel(
         autoupdate.FORCED_UPDATE, 'b/v/a').AndReturn('p')