Reland "Store metadata about updates in a file alongside with payload."

Relands CL: I3695b0903514eb6840e88810b8546fdca690819e

This original CL had an issue where we only generated metadata in the root
folder. This means updating twice using image_to_live with different images
would break updates.

I've fixed this in the second patch. Please compare P1 vs P2 as P1 is just
the re-landed version of I3695b0903514eb6840e88810b8546fdca690819e. I've
also fixed a bunch of pylint warnings that are now required per upload.

BUG=chromium-os:36990
TEST=Unittests on all changed code, pylint on all changed files, ran update
on x86-generic image using both the serve_only and generate latest workflows.
Ran autoupdate_EndToEndTest

Change-Id: I6bb65b23a34f071e388a4e522fb0fb42eae8781b
Reviewed-on: https://gerrit.chromium.org/gerrit/42271
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
diff --git a/devserver.py b/devserver.py
index 9c0b6a3..eb5afc0 100755
--- a/devserver.py
+++ b/devserver.py
@@ -26,14 +26,13 @@
 
 
 # Module-local log function.
-def _Log(message, *args, **kwargs):
-  return log_util.LogWithTag('DEVSERVER', message, *args, **kwargs)
+def _Log(message, *args):
+  return log_util.LogWithTag('DEVSERVER', message, *args)
 
 
 CACHED_ENTRIES = 12
 
 # Sets up global to share between classes.
-global updater
 updater = None
 
 
@@ -574,7 +573,6 @@
   @cherrypy.expose
   def index(self):
     """Presents a welcome message and documentation links."""
-    method_dict = DevServerRoot.__dict__
     return ('Welcome to the Dev Server!<br>\n'
             '<br>\n'
             'Here are the available methods, click for documentation:<br>\n'
@@ -659,9 +657,6 @@
   parser.add_option('--exit',
                     action='store_true',
                     help='do not start server (yet pregenerate/clear cache)')
-  parser.add_option('--factory_config',
-                    metavar='PATH',
-                    help='config file for serving images from factory floor')
   parser.add_option('--for_vm',
                     dest='vm', action='store_true',
                     help='update is for a vm image')
@@ -712,9 +707,6 @@
   parser.add_option('-u', '--urlbase',
                     metavar='URL',
                     help='base URL for update images, other than the devserver')
-  parser.add_option('--validate_factory_config',
-                    action="store_true",
-                    help='validate factory config file, then exit')
   (options, _) = parser.parse_args()
 
   devserver_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
@@ -759,6 +751,8 @@
   _Log('Source root is %s' % root_dir)
   _Log('Serving from %s' % static_dir)
 
+  # We allow global use here to share with cherrypy classes.
+  # pylint: disable=W0603
   global updater
   updater = autoupdate.Autoupdate(
       root_dir=root_dir,
@@ -766,7 +760,6 @@
       serve_only=serve_only,
       urlbase=options.urlbase,
       test_image=options.test_image,
-      factory_config_path=options.factory_config,
       forced_image=options.image,
       payload_path=options.payload,
       proxy_port=options.proxy_port,
@@ -781,19 +774,8 @@
       host_log=options.host_log,
   )
 
-  # Sanity-check for use of validate_factory_config.
-  if not options.factory_config and options.validate_factory_config:
-    parser.error('You need a factory_config to validate.')
-
-  if options.factory_config:
-    updater.ImportFactoryConfigFile(options.factory_config,
-                                     options.validate_factory_config)
-    # We don't run the dev server with this option.
-    if options.validate_factory_config:
-      sys.exit(0)
-  elif options.pregenerate_update:
-    if not updater.PreGenerateUpdate():
-      sys.exit(1)
+  if options.pregenerate_update:
+    updater.PreGenerateUpdate()
 
   # If the command line requested after setup, it's time to do it.
   if not options.exit: