Add logic to download the paygen_au_suite for a particular channel.

BUG=chromium:266675
TEST=Ran the main and tested with gilad's upload

Change-Id: I70ebfe537b2aa3de7d4b5655b10255ca4066711f
Reviewed-on: https://gerrit.chromium.org/gerrit/64416
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/build_artifact.py b/build_artifact.py
old mode 100644
new mode 100755
index 2934467..7bfd27f
--- a/build_artifact.py
+++ b/build_artifact.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
@@ -22,7 +24,7 @@
 ############ Actual filenames of artifacts in Google Storage ############
 
 AU_SUITE_FILE = 'au_control.tar.bz2'
-PAYGEN_AU_SUITE_FILE = 'paygen_au_control.tar.bz2'
+PAYGEN_AU_SUITE_FILE_TEMPLATE = 'paygen_au_%(channel)s_control.tar.bz2'
 AUTOTEST_FILE = 'autotest.tar'
 AUTOTEST_COMPRESSED_FILE = 'autotest.tar.bz2'
 DEBUG_SYMBOLS_FILE = 'debug.tgz'
@@ -345,6 +347,9 @@
     self.name = name
     self.additional_args = additional_args
 
+  def __repr__(self):
+    return '%s_%s' % (self.artifact_class, self.name)
+
 
 # Maps artifact names to their implementation description.
 # Please note, it is good practice to use constants for these names if you're
@@ -374,8 +379,6 @@
       ImplDescription(TarballBuildArtifact, TEST_SUITES_FILE),
   artifact_info.AU_SUITE:
       ImplDescription(TarballBuildArtifact, AU_SUITE_FILE),
-  artifact_info.PAYGEN_AU_SUITE:
-      ImplDescription(TarballBuildArtifact, PAYGEN_AU_SUITE_FILE),
 
   artifact_info.FIRMWARE:
       ImplDescription(BuildArtifact, FIRMWARE_FILE),
@@ -384,6 +387,13 @@
                       ['debug/breakpad']),
 }
 
+# Add all the paygen_au artifacts in one go.
+ARTIFACT_IMPLEMENTATION_MAP.update({
+  artifact_info.PAYGEN_AU_SUITE_TEMPLATE % { 'channel': c }: ImplDescription(
+      TarballBuildArtifact, PAYGEN_AU_SUITE_FILE_TEMPLATE % { 'channel': c })
+  for c in devserver_constants.CHANNELS
+})
+
 
 class ArtifactFactory(object):
   """A factory class that generates build artifacts from artifact names."""
@@ -434,3 +444,12 @@
         optional_names = optional_names.union(optional_list)
 
     return self._Artifacts(optional_names - set(self.artifact_names))
+
+
+# A simple main to verify correctness of the artifact map when making simple
+# name changes.
+if __name__ == '__main__':
+  print 'ARTIFACT IMPLEMENTATION MAP (for debugging)'
+  print 'FORMAT: ARTIFACT -> IMPLEMENTATION (<class>_file)'
+  for key, value in sorted(ARTIFACT_IMPLEMENTATION_MAP.items()):
+    print '%s -> %s' % (key, value)