|
[Rivet-svn] rivet: Fix HepData tarball download handling: StringIO is *not* ...Rivet Mercurial rivet at projects.hepforge.orgTue Jul 10 15:00:02 BST 2018
details: https://rivet.hepforge.org/hg/rivet/rev/8215428ef629 branches: release-2-6-x changeset: 6374:8215428ef629 user: Andy Buckley <andy at insectnation.org> date: Tue Jul 10 14:54:29 2018 +0100 description: Fix HepData tarball download handling: StringIO is *not* safe anymore diffs (truncated from 75 to 50 lines): --- a/ChangeLog Tue Jul 10 11:53:47 2018 +0100 +++ b/ChangeLog Tue Jul 10 14:54:29 2018 +0100 @@ -1,3 +1,7 @@ +2018-07-10 Andy Buckley <andy.buckley at cern.ch> + + * Fix HepData tarball download handling: StringIO is *not* safe anymore + 2018-07-08 Andy Buckley <andy.buckley at cern.ch> * Add LorentzTransform factory functions direct from FourMomentum, and operator()s --- a/bin/rivet-mkanalysis Tue Jul 10 11:53:47 2018 +0100 +++ b/bin/rivet-mkanalysis Tue Jul 10 14:54:29 2018 +0100 @@ -114,7 +114,7 @@ bibkey, bibtex = None, None if STDANA: try: - logging.debug("Getting Inspire/SPIRES biblio data for '%s'" % ANANAME) + logging.info("Getting Inspire/SPIRES biblio data for '%s'" % ANANAME) bibkey, bibtex = rivet.spiresbib.get_bibtex_from_repo(INSPIRE_SPIRES, ANAINSPIREID) except Exception as e: logging.error("Inspire/SPIRES oops: %s" % e) @@ -128,35 +128,31 @@ ## Try to download YODA data file from HepData if STDANA: try: - import tarfile, io try: - from urllib.request import urlopen + from urllib.request import urlretrieve except: - from urllib2 import urlopen + from urllib import urlretrieve # hdurl = None if INSPIRE_SPIRES == "I": hdurl = "http://www.hepdata.net/record/ins%s?format=yoda" % ANAINSPIREID - if hdurl: - logging.debug("Getting data file from HepData at %s" % hdurl) - response = urlopen(hdurl) - download=response.read() - if not download or "<html" in download: - logging.warning("Problem encountered when getting data from HepData (%s). No reference data file written." % hdurl) - else: - tar = tarfile.open(mode= "r:gz", fileobj = io.StringIO(download)) - fnames = tar.getnames() - if len(fnames)>1: - logging.warning("Found more than one file on downloaded archive. Not writing data file") - else: - tar.extractall() - import os
More information about the Rivet-svn mailing list |