File LHAPDF-pdfset-download-url-update.patch of Package LHAPDF

# HG changeset patch
# User Graeme Watt <graeme.watt@durham.ac.uk>
# Date 1540393858 -3600
#      Wed Oct 24 16:10:58 2018 +0100
# Node ID 4cc834904ebe36c62b6a1bc03773bf86ef037bba
# Parent  750ef2c28181d05374f0e091ae187f59bdf87c61
Update lhapdf download script for new HepForge

diff --git a/bin/lhapdf.in b/bin/lhapdf.in
--- a/bin/lhapdf.in
+++ b/bin/lhapdf.in
@@ -21,7 +21,7 @@
 
 
 ## Base paths etc. for set and index file downloading
-urlbase = 'http://www.hepforge.org/archive/lhapdf/pdfsets/%s/' % major_version
+urlbase = 'https://lhapdf.hepforge.org/downloads?f=pdfsets/%s/' % major_version
 afsbase = '/afs/cern.ch/sw/lcg/external/lhapdfsets/current/'
 cvmfsbase='/cvmfs/sft.cern.ch/lcg/external/lhapdfsets/current/'
 index_filename = 'pdfsets.index'
@@ -277,7 +277,7 @@
             import urllib2 as urllib
         try:
             u = urllib.urlopen(url)
-            file_size = int(u.info().get('Content-Length')[0])
+            file_size = int(u.info().get('Content-Length', [0])[0])
         except urllib.URLError:
             e = sys.exc_info()[1]
             logging.error('Unable to download %s' % url)
@@ -286,7 +286,10 @@
         logging.debug('Downloading from %s' % url)
         logging.debug('Downloading to %s' % dest_filepath)
         if dryrun:
-            logging.info('%s [%s]' % (os.path.basename(url), convertBytes(file_size)))
+            if file_size:
+                logging.info('%s [%s]' % (os.path.basename(url), convertBytes(file_size)))
+            else:
+                logging.info('%s' % os.path.basename(url))
             return False
 
         try:
@@ -306,7 +309,10 @@
                     dest_file.write(buffer)
 
                     status  = chr(13) + '%s: ' % os.path.basename(url)
-                    status += r'%s [%3.1f%%]' % (convertBytes(file_size_dl).rjust(10), file_size_dl * 100. / file_size)
+                    if file_size:
+                        status += r'%s [%3.1f%%]' % (convertBytes(file_size_dl).rjust(10), file_size_dl * 100. / file_size)
+                    else:
+                        status += r'%s' % convertBytes(file_size_dl).rjust(10)
                     sys.stdout.write(status+' ')
             except urllib.URLError:
                 e = sys.exc_info()[1]

openSUSE Build Service is sponsored by