Facilitate CTS-V upload to APFE gs://bucket.

BUG=b:71722646
TEST=./upload_cts_verifier.py <build_id> <results_dir_path>

Change-Id: Id3fdf65f87a7aa33830776f60131359b38ee2d03
Reviewed-on: https://chromium-review.googlesource.com/855507
Commit-Ready: Nita Nair <nnita@chromium.org>
Tested-by: Nita Nair <nnita@chromium.org>
Reviewed-by: Rohit Makasana <rohitbm@chromium.org>
diff --git a/provingground/cts/lib/upload_utils.py b/provingground/cts/lib/upload_utils.py
index a31d5f6..06ac5d9 100755
--- a/provingground/cts/lib/upload_utils.py
+++ b/provingground/cts/lib/upload_utils.py
@@ -215,20 +215,37 @@
       dir_path: Results directory path.
     """
     build_board = ''
-    build_id = ''
     split_file_list = self.SplitFileName(filename)
     base = split_file_list[0]
     build_board = self.build_info_list[-1][1]
-    build_id = self.build_info_list[-1][2]
+    build_id_folder = self.build_info_list[-1][2]
     release_folder = '%s-release' % build_board
-    build_folder = '%s' % build_id
     manual_folder = 'manual'
-    apfe_path = os.path.join(dir_path, release_folder, build_folder,
+    apfe_path = os.path.join(dir_path, release_folder, build_id_folder,
                              manual_folder)
     if not os.path.exists(apfe_path):
       os.makedirs(apfe_path)
     self.CopyFileToDestination(dir_path, base, apfe_path, base)
 
+  def CreateCtsvApfeFolder(self, filename, dir_path):
+    """Creates hierarchy for uploading CTS-V result files to APFE bucket.
+
+    Args:
+      filename: Valid file to upload to APFE folder.
+      dir_path: Results directory path.
+    """
+    build_board = ''
+    split_file_list = self.SplitFileName(filename)
+    base = split_file_list[0]
+    build_board = self.build_info_list[-1][1]
+    build_id_folder = self.build_info_list[-1][2]
+    release_folder = '%s-release' % build_board
+    apfe_path = os.path.join(dir_path, release_folder, build_id_folder)
+    if not os.path.exists(apfe_path):
+      os.makedirs(apfe_path)
+    self.CopyFileToDestination(dir_path, base, apfe_path, base)
+
+
   def CreateCtsFolder(self, filename, dir_path):
     """Creates hierarchy for upload to CTS Dashboard bucket.
 
diff --git a/provingground/cts/upload_cts_verifier.py b/provingground/cts/upload_cts_verifier.py
index 12e8e84..c7028f8 100755
--- a/provingground/cts/upload_cts_verifier.py
+++ b/provingground/cts/upload_cts_verifier.py
@@ -4,7 +4,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""This script can be used to upload CTS Verifier results to CTS Dashboard."""
+"""This script uploads CTS Verifier results to CTS and APFE gs:// buckets."""
 
 from __future__ import print_function
 from lib.upload_utils import UploadUtils
@@ -63,16 +63,28 @@
     print('\n')
 
   def PrintGsutilLinks(self, dir_path):
-    """Prints gsutil links to upload results to CTS-V dashboard bucket.
+    """Prints gsutil links to upload results to CTS dashboard and APFE buckets.
 
     Args:
       dir_path: Results directory path.
     """
     for item in self.build_info_list:
-      gsutil_msg = ('gsutil cp -r {0}/{1}_{2}/ '
-                    'gs://chromeos-cts-results/ctsVerifier'
-                    .format(dir_path, item[2], item[1]))
-      print(self.BOLD + self.C_PURPLE + gsutil_msg + self.BOLD + self.C_END)
+      gsutil_msg_apfe = ('gsutil cp -r {0}/{1}-release/ '
+                         'gs://chromeos-ctsverifier-results/'
+                         .format(dir_path, item[1]))
+      gsutil_msg_cts = ('gsutil cp -r {0}/{1}_{2}/ '
+                        'gs://chromeos-cts-results/ctsVerifier'
+                        .format(dir_path, item[2], item[1]))
+      print(self.BOLD +
+            self.C_PURPLE +
+            gsutil_msg_cts +
+            self.BOLD +
+            self.C_END)
+      print(self.BOLD +
+            self.C_PURPLE +
+            gsutil_msg_apfe +
+            self.BOLD +
+            self.C_END)
 
   def PrintIfAllTestsPassed(self):
     """Print message to terminal if all tests have passed."""
@@ -163,6 +175,7 @@
         if build_id == input_build_id:
           self.valid_files_exist = True
           self.failed_tests_exist = False
+          self.CreateCtsvApfeFolder(full_file, dir_path)
           self.CreateCtsFolder(full_file, dir_path)
           self.PrintBuildInfoList()
           self.PrintFailedTestResults(tests)