1 |
commit: a196c4873b3508e1f2bf60abdefe4887f2b872fb |
2 |
Author: Mart Raudsepp <leio <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Mar 3 22:28:54 2017 +0000 |
4 |
Commit: Mart Raudsepp <leio <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Mar 3 22:28:54 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoo-bumpchecker.git/commit/?id=a196c487 |
7 |
|
8 |
gnome: Use requests instead of urllib2 |
9 |
|
10 |
This should give us connection pooling, which can be important for |
11 |
further planned changes. |
12 |
|
13 |
modules/gnome_module.py | 16 ++++++++-------- |
14 |
1 file changed, 8 insertions(+), 8 deletions(-) |
15 |
|
16 |
diff --git a/modules/gnome_module.py b/modules/gnome_module.py |
17 |
index 0edf973..7c8f613 100644 |
18 |
--- a/modules/gnome_module.py |
19 |
+++ b/modules/gnome_module.py |
20 |
@@ -2,7 +2,8 @@ |
21 |
# LICENSE - GPL2 |
22 |
# vim: set sts=4 sw=4 et tw=0 : |
23 |
|
24 |
-import urllib2, package_module, clioptions_module |
25 |
+import requests |
26 |
+import package_module, clioptions_module |
27 |
|
28 |
DEBUG = False |
29 |
|
30 |
@@ -23,17 +24,17 @@ class GNOME: |
31 |
gnome_release_list[1] = str(int(gnome_release_list[1]) + 1) |
32 |
self.gnome_release = ".".join(gnome_release_list[:2]) |
33 |
|
34 |
- self.ftpserver = "download.gnome.org" |
35 |
- self.release_versions_file_path = 'https://download.gnome.org/teams/releng/' |
36 |
+ self.http = requests.session() |
37 |
+ self.url_base = "https://download.gnome.org/" |
38 |
+ self.release_versions_file_path = self.url_base + 'teams/releng/' |
39 |
|
40 |
def generate_data_from_versions_markup(self, url): |
41 |
- try: |
42 |
- f = urllib2.urlopen(url) |
43 |
- except: |
44 |
+ data = self.http.get(url) |
45 |
+ if not data: |
46 |
raise ValueError("Couldn't open %s" % url) |
47 |
|
48 |
ret = [] |
49 |
- for line in f.readlines(): |
50 |
+ for line in data.iter_lines(): |
51 |
components = str.strip(line).split(':') |
52 |
# Skip invalid lines |
53 |
if len(components) != 4 or len(components[2]) == 0: |
54 |
@@ -46,7 +47,6 @@ class GNOME: |
55 |
ret.append(pkg) |
56 |
else: |
57 |
print "Warning: Ignoring package %s because parsing of its name or version string '%s' failed" % (components[1], components[2]) |
58 |
- f.close() |
59 |
return ret |
60 |
|
61 |
def generate_data_individual(self): |