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

Side by Side Diff: sitescripts/subscriptions/subscriptionParser.py

Issue 10942098: Make sure subprocess calls don`t ignore result codes indicating errors. Fix JS docs generation whil… (Closed)
Patch Set: Addressed issues Created July 5, 2013, 11:22 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
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 for fileData in lists.itervalues(): 218 for fileData in lists.itervalues():
219 for supplements in fileData.supplements: 219 for supplements in fileData.supplements:
220 if supplements in lists: 220 if supplements in lists:
221 lists[supplements].supplemented.append(fileData) 221 lists[supplements].supplemented.append(fileData)
222 else: 222 else:
223 warn('Subscription %s supplements an unknown subscription %s' % (fileDat a.name, supplements)) 223 warn('Subscription %s supplements an unknown subscription %s' % (fileDat a.name, supplements))
224 224
225 @cached(60) 225 @cached(60)
226 def get_settings(): 226 def get_settings():
227 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) 227 repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
228 settingsData = subprocess.check_output(['hg', '-q', '-R', repo, 'cat', '-r', ' default', os.path.join(repo, 'settings')]) 228 settingsData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul t', os.path.join(repo, 'settings')])
229 settings = SafeConfigParser() 229 settings = SafeConfigParser()
230 settings.readfp(codecs.getreader('utf8')(StringIO(settingsData))) 230 settings.readfp(codecs.getreader('utf8')(StringIO(settingsData)))
231 return settings 231 return settings
232 232
233 def readSubscriptions(): 233 def readSubscriptions():
234 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) 234 repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
235 data = subprocess.check_output(['hg', 'archive', '-q', '-R', repo, '-r', 'defa ult', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-']) 235 data = subprocess.check_output(['hg', 'archive', '-R', repo, '-r', 'default', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-'])
236 236
237 result = {} 237 result = {}
238 tarFile = tarfile.open(mode='r:', fileobj=StringIO(data)) 238 tarFile = tarfile.open(mode='r:', fileobj=StringIO(data))
239 fileInfo = tarFile.next() 239 fileInfo = tarFile.next()
240 while fileInfo: 240 while fileInfo:
241 fileData = parseFile(fileInfo.name, codecs.getreader('utf8')(tarFile.extract file(fileInfo))) 241 fileData = parseFile(fileInfo.name, codecs.getreader('utf8')(tarFile.extract file(fileInfo)))
242 fileInfo = tarFile.next() 242 fileInfo = tarFile.next()
243 if fileData.unavailable: 243 if fileData.unavailable:
244 continue 244 continue
245 245
246 if fileData.name in result: 246 if fileData.name in result:
247 warn('Name %s is claimed by multiple files' % (fileData.name)) 247 warn('Name %s is claimed by multiple files' % (fileData.name))
248 result[fileData.name] = fileData 248 result[fileData.name] = fileData
249 tarFile.close() 249 tarFile.close()
250 250
251 calculateSupplemented(result) 251 calculateSupplemented(result)
252 return result 252 return result
253 253
254 def getFallbackData(): 254 def getFallbackData():
255 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) 255 repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
256 redirectData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul t', os.path.join(repo, 'redirects')]) 256 redirectData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul t', os.path.join(repo, 'redirects')])
257 goneData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')]) 257 goneData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')])
258 return (redirectData, goneData) 258 return (redirectData, goneData)
259 259
260 def _validateURL(url): 260 def _validateURL(url):
261 parseResult = urlparse(url) 261 parseResult = urlparse(url)
262 return (parseResult.scheme == 'http' or parseResult.scheme == 'https') and par seResult.netloc != '' 262 return (parseResult.scheme == 'http' or parseResult.scheme == 'https') and par seResult.netloc != ''
OLDNEW

Powered by Google App Engine
This is Rietveld