[autotest] Extract _stage_artifacts method

BUG=chromium:672348
TEST=None

Change-Id: I57d4f988cb442da4351acccdc7de2fe4b3f31839
Reviewed-on: https://chromium-review.googlesource.com/418472
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@google.com>
diff --git a/server/cros/dynamic_suite/dynamic_suite.py b/server/cros/dynamic_suite/dynamic_suite.py
index a2d475b..b9dd3d6 100644
--- a/server/cros/dynamic_suite/dynamic_suite.py
+++ b/server/cros/dynamic_suite/dynamic_suite.py
@@ -545,14 +545,7 @@
     # We can't do anything else until the devserver has finished downloading
     # control_files and test_suites packages so that we can get the control
     # files we should schedule.
-    try:
-        if not spec.run_prod_code:
-            spec.devserver.stage_artifacts(
-                    image=spec.test_source_build,
-                    artifacts=['control_files', 'test_suites'])
-    except dev_server.DevServerException as e:
-        # If we can't get the control files, there's nothing to run.
-        raise error.AsynchronousBuildFailure(e)
+    _stage_artifacts(spec)
 
     timestamp = datetime.datetime.now().strftime(time_utils.TIME_FMT)
     utils.write_keyval(
@@ -602,3 +595,18 @@
     else:
         logging.info('wait_for_results is set to False, suite job will exit '
                      'without waiting for test jobs to finish.')
+
+
+def _stage_artifacts(suite_spec):
+    """Stage artifacts for a suite job.
+
+    @param suite_spec: a populated SuiteSpec object.
+    """
+    try:
+        if not suite_spec.run_prod_code:
+            suite_spec.devserver.stage_artifacts(
+                    image=suite_spec.test_source_build,
+                    artifacts=['control_files', 'test_suites'])
+    except dev_server.DevServerException as e:
+        # If we can't get the control files, there's nothing to run.
+        raise error.AsynchronousBuildFailure(e)