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

Side by Side Diff: filters/get_subscriptions.py

Issue 29336582: Issue 2813 - Catch missing sitescripts module and return empty list on adblockplus.org (Closed)
Patch Set: Created Feb. 18, 2016, 11:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 from ConfigParser import SafeConfigParser 20 from ConfigParser import SafeConfigParser
21 21
22 def get_subscriptions(_): 22 def get_subscriptions(_):
23 from sitescripts.subscriptions import subscriptionParser 23 try:
24 24 from sitescripts.subscriptions import subscriptionParser
25 except ImportError as error:
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.
26 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.
25 result = {} 27 result = {}
26 utf8_reader = codecs.getreader('utf8') 28 utf8_reader = codecs.getreader('utf8')
27 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz") 29 source = urllib.urlopen("https://hg.adblockplus.org/subscriptionlist/archive/d efault.tar.gz")
28 orig_get_settings = subscriptionParser.get_settings 30 orig_get_settings = subscriptionParser.get_settings
29 try: 31 try:
30 # Hack: monkey-patch subscriptionParser.get_settings() 32 # Hack: monkey-patch subscriptionParser.get_settings()
31 settings = SafeConfigParser() 33 settings = SafeConfigParser()
32 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings") 34 settings_handle = urllib.urlopen("https://hg.adblockplus.org/subscriptionlis t/rawfile/default/settings")
33 try: 35 try:
34 settings.readfp(utf8_reader(settings_handle)) 36 settings.readfp(utf8_reader(settings_handle))
(...skipping 10 matching lines...) Expand all
45 if filedata.unavailable: 47 if filedata.unavailable:
46 continue 48 continue
47 49
48 result[filedata.name] = filedata 50 result[filedata.name] = filedata
49 finally: 51 finally:
50 source.close() 52 source.close()
51 subscriptionParser.get_settings = orig_get_settings 53 subscriptionParser.get_settings = orig_get_settings
52 54
53 subscriptionParser.calculate_supplemented(result) 55 subscriptionParser.calculate_supplemented(result)
54 return result.values() 56 return result.values()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld