Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: filters/get_subscriptions.py

Issue 29336582: Issue 2813 - Catch missing sitescripts module and return empty list on adblockplus.org (Closed)
Left Patch Set: Created Feb. 18, 2016, 11:03 a.m.
Right Patch Set: Fixed warning string spacing Created Feb. 23, 2016, 3:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of the Adblock Plus website, 1 # This file is part of the Adblock Plus website,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 import codecs 16 import codecs
17 import os 17 import os
18 import tarfile 18 import tarfile
19 import urllib 19 import urllib
20 import logging
20 from ConfigParser import SafeConfigParser 21 from ConfigParser import SafeConfigParser
21 22
22 def get_subscriptions(_): 23 def get_subscriptions(_):
23 try: 24 try:
24 from sitescripts.subscriptions import subscriptionParser 25 from sitescripts.subscriptions import subscriptionParser
25 except ImportError as error: 26 except ImportError:
kzar 2016/02/18 15:24:25 Nit: You're not using error, so no point giving it
juliandoucette 2016/02/19 17:00:10 Done.
27 logging.warning("Unable to import sitescripts, proceeding with empty "
28 "subscriptions list.")
26 return [] 29 return []
kzar 2016/02/18 15:24:25 We should also log a warning message here, so that
juliandoucette 2016/02/19 17:00:10 Done.
30
27 result = {} 31 result = {}
28 utf8_reader = codecs.getreader('utf8') 32 utf8_reader = codecs.getreader('utf8')
29 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz") 33 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz")
30 orig_get_settings = subscriptionParser.get_settings 34 orig_get_settings = subscriptionParser.get_settings
31 try: 35 try:
32 # Hack: monkey-patch subscriptionParser.get_settings() 36 # Hack: monkey-patch subscriptionParser.get_settings()
33 settings = SafeConfigParser() 37 settings = SafeConfigParser()
34 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings") 38 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings")
35 try: 39 try:
36 settings.readfp(utf8_reader(settings_handle)) 40 settings.readfp(utf8_reader(settings_handle))
(...skipping 10 matching lines...) Expand all
47 if filedata.unavailable: 51 if filedata.unavailable:
48 continue 52 continue
49 53
50 result[filedata.name] = filedata 54 result[filedata.name] = filedata
51 finally: 55 finally:
52 source.close() 56 source.close()
53 subscriptionParser.get_settings = orig_get_settings 57 subscriptionParser.get_settings = orig_get_settings
54 58
55 subscriptionParser.calculate_supplemented(result) 59 subscriptionParser.calculate_supplemented(result)
56 return result.values() 60 return result.values()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld