Revert "devserver: stop importing cros_update"

This reverts commit 88e277fed16a1adce5e5e18a7e0d79d584388ea8.

Reason for revert: Suspect for crbug.com/1058416

Original change's description:
> devserver: stop importing cros_update
> 
> We already execute it as a standalone program in one codepath, so
> do that all the time.  This simplifies the code too, and allows us
> to migrate cros_update to Python 3 before devserver.
> 
> BUG=chromium:1057760
> TEST=CQ passes
> 
> Change-Id: Ia8ac2db5e053c783b7ddf8ae4ddfb65a3484d6c5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2083676
> Reviewed-by: Amin Hassani <ahassani@chromium.org>
> Tested-by: Mike Frysinger <vapier@chromium.org>
> Commit-Queue: Mike Frysinger <vapier@chromium.org>

Bug: chromium:1057760
Change-Id: I0cdc36f5f34ebacbdba371cc9779e8b99ddb447a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2088203
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
diff --git a/devserver.py b/devserver.py
index 4a4b145..b1888ab 100755
--- a/devserver.py
+++ b/devserver.py
@@ -64,6 +64,7 @@
 from chromite.lib.xbuddy import devserver_constants
 from chromite.lib.xbuddy import downloader
 from chromite.lib.xbuddy import xbuddy
+from chromite.scripts import cros_update
 
 # Module-local log function.
 def _Log(message, *args):
@@ -817,42 +818,42 @@
     devserver_url = updater.GetDevserverUrl()
     static_url = updater.GetStaticUrl()
 
-    # Command of running auto-update.
-    cmd = ['cros_update', '--hostname', host_name, '-b', build_name,
-           '--static_dir', updater.static_dir]
-
-    # The original_build's format is like: link/3428.210.0
-    # The corresponding release_archive_url's format is like:
-    #    gs://chromeos-releases/stable-channel/link/3428.210.0
-    if original_build:
-      release_archive_url = _build_uri_from_build_name(original_build)
-      # First staging the stateful.tgz synchronousely.
-      self.stage(files='stateful.tgz', is_async=False,
-                 archive_url=release_archive_url)
-      cmd += ['--original_build', original_build]
-
-    if force_update:
-      cmd += ['--force_update']
-
-    if full_update:
-      cmd += ['--full_update']
-
-    if payload_filename:
-      cmd += ['--payload_filename', payload_filename]
-
-    if clobber_stateful:
-      cmd += ['--clobber_stateful']
-
-    if quick_provision:
-      cmd += ['--quick_provision']
-
-    if devserver_url:
-      cmd += ['--devserver_url', devserver_url]
-
-    if static_url:
-      cmd += ['--static_url', static_url]
-
     if is_async:
+      # Command of running auto-update.
+      cmd = ['cros_update', '--hostname', host_name, '-b', build_name,
+             '--static_dir', updater.static_dir]
+
+      # The original_build's format is like: link/3428.210.0
+      # The corresponding release_archive_url's format is like:
+      #    gs://chromeos-releases/stable-channel/link/3428.210.0
+      if original_build:
+        release_archive_url = _build_uri_from_build_name(original_build)
+        # First staging the stateful.tgz synchronousely.
+        self.stage(files='stateful.tgz', is_async=False,
+                   archive_url=release_archive_url)
+        cmd += ['--original_build', original_build]
+
+      if force_update:
+        cmd += ['--force_update']
+
+      if full_update:
+        cmd += ['--full_update']
+
+      if payload_filename:
+        cmd += ['--payload_filename', payload_filename]
+
+      if clobber_stateful:
+        cmd += ['--clobber_stateful']
+
+      if quick_provision:
+        cmd += ['--quick_provision']
+
+      if devserver_url:
+        cmd += ['--devserver_url', devserver_url]
+
+      if static_url:
+        cmd += ['--static_url', static_url]
+
       p = subprocess.Popen(cmd, preexec_fn=os.setsid)
       pid = os.getpgid(p.pid)
 
@@ -863,7 +864,12 @@
 
       return json.dumps((True, pid))
     else:
-      subprocess.check_call(cmd)
+      cros_update_trigger = cros_update.CrOSUpdateTrigger(
+          host_name, build_name, updater.static_dir, force_update=force_update,
+          full_update=full_update, original_build=original_build,
+          payload_filename=payload_filename, quick_provision=quick_provision,
+          devserver_url=devserver_url, static_url=static_url)
+      cros_update_trigger.TriggerAU()
       return json.dumps((True, -1))
 
   @cherrypy.expose