Catalogs: multiple download URLs (mirrors) supported
This commit is contained in:
parent
e4007bae99
commit
99b893368b
@ -213,7 +213,7 @@ def append_author_nodes(node, info):
|
|||||||
# traditional single author string
|
# traditional single author string
|
||||||
node.append( make_xml_leaf('author', info['author']) )
|
node.append( make_xml_leaf('author', info['author']) )
|
||||||
|
|
||||||
def make_aircraft_node(aircraftDirName, package, variants, downloadBase):
|
def make_aircraft_node(aircraftDirName, package, variants, downloadBase, mirrors):
|
||||||
#print "package:", package
|
#print "package:", package
|
||||||
#print "variants:", variants
|
#print "variants:", variants
|
||||||
package_node = ET.Element('package')
|
package_node = ET.Element('package')
|
||||||
@ -262,9 +262,15 @@ def make_aircraft_node(aircraftDirName, package, variants, downloadBase):
|
|||||||
|
|
||||||
package_node.append( make_xml_leaf('dir', aircraftDirName) )
|
package_node.append( make_xml_leaf('dir', aircraftDirName) )
|
||||||
|
|
||||||
|
# primary URL is first
|
||||||
download_url = downloadBase + aircraftDirName + '.zip'
|
download_url = downloadBase + aircraftDirName + '.zip'
|
||||||
package_node.append( make_xml_leaf('url', download_url) )
|
package_node.append( make_xml_leaf('url', download_url) )
|
||||||
|
|
||||||
|
for m in mirrors:
|
||||||
|
mu = m + aircraftDirName + '.zip'
|
||||||
|
package_node.append( make_xml_leaf('url', mu) )
|
||||||
|
|
||||||
|
|
||||||
if 'thumbnail' in package:
|
if 'thumbnail' in package:
|
||||||
thumbnail_url = downloadBase + 'thumbnails/' + aircraftDirName + '_' + package['thumbnail']
|
thumbnail_url = downloadBase + 'thumbnails/' + aircraftDirName + '_' + package['thumbnail']
|
||||||
package_node.append( make_xml_leaf('thumbnail', thumbnail_url) )
|
package_node.append( make_xml_leaf('thumbnail', thumbnail_url) )
|
||||||
|
@ -30,6 +30,7 @@ parser.add_argument("dir", help="Catalog directory")
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
includes = []
|
includes = []
|
||||||
|
mirrors = [] # mirror base URLs
|
||||||
|
|
||||||
# xml node (robust) get text helper
|
# xml node (robust) get text helper
|
||||||
def get_xml_text(e):
|
def get_xml_text(e):
|
||||||
@ -132,6 +133,7 @@ def process_aircraft_dir(name, repo_path):
|
|||||||
global output_dir
|
global output_dir
|
||||||
global valid_zips
|
global valid_zips
|
||||||
global previews_dir
|
global previews_dir
|
||||||
|
global mirrors
|
||||||
|
|
||||||
aircraft_dir = os.path.join(repo_path, name)
|
aircraft_dir = os.path.join(repo_path, name)
|
||||||
if not os.path.isdir(aircraft_dir):
|
if not os.path.isdir(aircraft_dir):
|
||||||
@ -146,7 +148,7 @@ def process_aircraft_dir(name, repo_path):
|
|||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print "%s:" % name,
|
print "%s:" % name,
|
||||||
|
|
||||||
package_node = catalog.make_aircraft_node(name, package, variants, download_base)
|
package_node = catalog.make_aircraft_node(name, package, variants, download_base, mirrors)
|
||||||
|
|
||||||
download_url = download_base + name + '.zip'
|
download_url = download_base + name + '.zip'
|
||||||
if 'thumbnail' in package:
|
if 'thumbnail' in package:
|
||||||
@ -256,9 +258,18 @@ else:
|
|||||||
# SCM providers
|
# SCM providers
|
||||||
scm_list = config_node.findall('scm')
|
scm_list = config_node.findall('scm')
|
||||||
upload_node = config_node.find('upload')
|
upload_node = config_node.find('upload')
|
||||||
download_base = get_xml_text(config_node.find('download-url'))
|
|
||||||
if not download_base.endswith('/'):
|
download_base = None
|
||||||
download_base += '/'
|
for i in config_node.findall("download-url"):
|
||||||
|
url = get_xml_text(i)
|
||||||
|
if not url.endswith('/'):
|
||||||
|
url += '/'
|
||||||
|
|
||||||
|
if download_base == None:
|
||||||
|
# download_base is the first entry
|
||||||
|
download_base = url
|
||||||
|
else:
|
||||||
|
mirrors.append(url)
|
||||||
|
|
||||||
output_dir = get_xml_text(config_node.find('local-output'))
|
output_dir = get_xml_text(config_node.find('local-output'))
|
||||||
if output_dir == '':
|
if output_dir == '':
|
||||||
|
Loading…
Reference in New Issue
Block a user