diff options
author | 2017-03-04 00:28:54 +0200 | |
---|---|---|
committer | 2017-03-04 00:28:54 +0200 | |
commit | a196c4873b3508e1f2bf60abdefe4887f2b872fb (patch) | |
tree | c36299f3277a991df7b09f3f291c4e1cde478ee8 | |
parent | gnome: Remove unused simple_cache_module import (diff) | |
download | gentoo-bumpchecker-a196c4873b3508e1f2bf60abdefe4887f2b872fb.tar.gz gentoo-bumpchecker-a196c4873b3508e1f2bf60abdefe4887f2b872fb.tar.bz2 gentoo-bumpchecker-a196c4873b3508e1f2bf60abdefe4887f2b872fb.zip |
gnome: Use requests instead of urllib2
This should give us connection pooling, which can be important for
further planned changes.
-rw-r--r-- | modules/gnome_module.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/gnome_module.py b/modules/gnome_module.py index 0edf973..7c8f613 100644 --- a/modules/gnome_module.py +++ b/modules/gnome_module.py @@ -2,7 +2,8 @@ # LICENSE - GPL2 # vim: set sts=4 sw=4 et tw=0 : -import urllib2, package_module, clioptions_module +import requests +import package_module, clioptions_module DEBUG = False @@ -23,17 +24,17 @@ class GNOME: gnome_release_list[1] = str(int(gnome_release_list[1]) + 1) self.gnome_release = ".".join(gnome_release_list[:2]) - self.ftpserver = "download.gnome.org" - self.release_versions_file_path = 'https://download.gnome.org/teams/releng/' + self.http = requests.session() + self.url_base = "https://download.gnome.org/" + self.release_versions_file_path = self.url_base + 'teams/releng/' def generate_data_from_versions_markup(self, url): - try: - f = urllib2.urlopen(url) - except: + data = self.http.get(url) + if not data: raise ValueError("Couldn't open %s" % url) ret = [] - for line in f.readlines(): + for line in data.iter_lines(): components = str.strip(line).split(':') # Skip invalid lines if len(components) != 4 or len(components[2]) == 0: @@ -46,7 +47,6 @@ class GNOME: ret.append(pkg) else: print "Warning: Ignoring package %s because parsing of its name or version string '%s' failed" % (components[1], components[2]) - f.close() return ret def generate_data_individual(self): |