def GetNameComponents(board, version_string, alt_naming): """Determine URL and version components of script input. If you update alt_naming values below, remember to update constant NUM_NAMING_SCHEME above. Args: board: target board version_string: string with image version information alt_naming: try alternative build naming 0 - default naming scheme for images hosted on chromeos-images/ 1 - append '-rc' to board for index html page and links 2 - remove chromeos-official for index html page and links 3 - default naming scheme for images hosted on GSD Returns: url, a string, the image index page URL num, a string, the image version number cha, a string, the image channel key, a string, part of the image signing key label """ num, cha, key = version_string.split('/') cha = cha + '-channel' if alt_naming == 1: url = os.path.join(IMAGE_SERVER_PREFIX, cha, board + '-rc', num) elif alt_naming == 2: url = os.path.join( IMAGE_SERVER_PREFIX.replace('chromeos-official', ''), cha, board, num) elif alt_naming == 3: url = os.path.join(IMAGE_GSD_PREFIX, cha, board, num) else: url = os.path.join(IMAGE_SERVER_PREFIX, cha, board, num) return (url, num, cha, key)
def testFactoryUseAlternativeNamingTwo(self): """Verify correct string tuple returned using alt_naming scheme 2.""" mod_prefix = '/'.join(IMAGE_SERVER_PREFIX.split('/')[:-1]) expected = (mod_prefix + '/stable-channel/x86-alex/0.12.433.269', ['chromeos-factory', '0.12.433.269', 'x86-alex', '.zip']) actual = cb_name_lib.GetFactoryName(self.board, self.version_string, 2) self.assertEqual(expected, actual)
def GetFactoryName(board, factory, alt_naming=0): """Determines release page URL and naming pattern of desired factory image. Args: board: target board factory: factory version and channel alt_naming: optional, see docstring for GetNameComponents. Returns: fac_url: a string, the release page URL token_list: a list of strings, in the order they are expected in the url. """ fac_no, fac_ch = factory.split('/') fac_ch = fac_ch + '-channel' if alt_naming == 1: fac_url = os.path.join(IMAGE_SERVER_PREFIX, fac_ch, board + '-rc', fac_no) elif alt_naming == 2: fac_url = os.path.join( IMAGE_SERVER_PREFIX.replace('chromeos-official', ''), fac_ch, board, fac_no) elif alt_naming == 3: fac_url = os.path.join(IMAGE_GSD_PREFIX, fac_ch, board, fac_no) else: fac_url = os.path.join(IMAGE_SERVER_PREFIX, fac_ch, board, fac_no) token_list = ['chromeos-factory', fac_no, board, '.zip'] return (fac_url, token_list)
def testUseAltNamingTwo(self): """Verify correct string tuple returned using alt_naming scheme 2.""" mod_prefix = '/'.join(IMAGE_SERVER_PREFIX.split('/')[:-1]) expected = (mod_prefix + '/stable-channel/x86-alex/0.12.433.269', '0.12.433.269', 'stable-channel', 'mp') actual = cb_name_lib.GetNameComponents(self.board, self.version_string, 2) self.assertEqual(expected, actual)
def GetFactoryName(board, factory, alt_naming=0): """Determines release page URL and naming pattern of desired factory image. Args: board: target board factory: factory version and channel alt_naming: optional, see docstring for GetNameComponents. Returns: fac_url: a string, the release page URL token_list: a list of strings, in the order they are expected in the url. """ fac_no, fac_ch = factory.split('/') fac_ch = fac_ch + '-channel' if alt_naming == 1: fac_url = os.path.join(IMAGE_SERVER_PREFIX, fac_ch, board + '-rc', fac_no) elif alt_naming == 2: fac_url = os.path.join(IMAGE_SERVER_PREFIX.replace('chromeos-official', ''), fac_ch, board, fac_no) elif alt_naming == 3: fac_url = os.path.join(IMAGE_GSD_PREFIX, fac_ch, board, fac_no) else: fac_url = os.path.join(IMAGE_SERVER_PREFIX, fac_ch, board, fac_no) token_list = ['chromeos-factory', fac_no, board, '.zip'] return (fac_url, token_list)