1from __future__ import absolute_import 2 3from urlparse import urlunsplit 4 5product_ftp_map = { 6 "fennec": "mobile", 7} 8 9 10def product2ftp(product): 11 return product_ftp_map.get(product, product) 12 13 14def getCandidatesDir(product, version, buildNumber, protocol=None, server=None): 15 if protocol: 16 assert server is not None, "server is required with protocol" 17 18 product = product2ftp(product) 19 directory = "/{}/candidates/{}-candidates/build{}".format( 20 product, str(version), str(buildNumber), 21 ) 22 23 if protocol: 24 return urlunsplit((protocol, server, directory, None, None)) 25 else: 26 return directory 27 28 29def getReleasesDir(product, version=None, protocol=None, server=None): 30 if protocol: 31 assert server is not None, "server is required with protocol" 32 33 directory = "/{}/releases".format(product) 34 if version: 35 directory = "{}/{}".format(directory, version) 36 37 if protocol: 38 return urlunsplit((protocol, server, directory, None, None)) 39 else: 40 return directory 41 42 43def getReleaseInstallerPath(productName, brandName, version, platform, 44 locale='en-US'): 45 if productName not in ('fennec',): 46 if platform.startswith('linux'): 47 return '/'.join([p.strip('/') for p in [ 48 platform, locale, '%s-%s.tar.bz2' % (productName, version)]]) 49 elif 'mac' in platform: 50 return '/'.join([p.strip('/') for p in [ 51 platform, locale, '%s %s.dmg' % (brandName, version)]]) 52 elif platform.startswith('win'): 53 return '/'.join([p.strip('/') for p in [ 54 platform, locale, '%s Setup %s.exe' % (brandName, version)]]) 55 else: 56 raise "Unsupported platform" 57 else: 58 if platform.startswith('android'): 59 filename = '%s-%s.%s.android-arm.apk' % ( 60 productName, version, locale) 61 return '/'.join([p.strip('/') for p in [ 62 platform, locale, filename]]) 63 else: 64 raise "Unsupported platform" 65