Index: sitescripts/subscriptions/subscriptionParser.py |
=================================================================== |
--- a/sitescripts/subscriptions/subscriptionParser.py |
+++ b/sitescripts/subscriptions/subscriptionParser.py |
@@ -220,29 +220,24 @@ def calculateSupplemented(lists): |
if supplements in lists: |
lists[supplements].supplemented.append(fileData) |
else: |
warn('Subscription %s supplements an unknown subscription %s' % (fileData.name, supplements)) |
@cached(60) |
def get_settings(): |
repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
- (settingsData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'settings')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |
- if errors: |
- print >>sys.stderr, errors |
- |
+ settingsData = subprocess.check_output(['hg', '-q', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'settings')]) |
settings = SafeConfigParser() |
settings.readfp(codecs.getreader('utf8')(StringIO(settingsData))) |
return settings |
def readSubscriptions(): |
repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
- (data, errors) = subprocess.Popen(['hg', 'archive', '-R', repo, '-r', 'default', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |
- if errors: |
- print >>sys.stderr, errors |
+ data = subprocess.check_output(['hg', 'archive', '-q', '-R', repo, '-r', 'default', '-t', 'tar', '-I', os.path.join(repo, '*.subscription'), '-']) |
result = {} |
tarFile = tarfile.open(mode='r:', fileobj=StringIO(data)) |
fileInfo = tarFile.next() |
while fileInfo: |
fileData = parseFile(fileInfo.name, codecs.getreader('utf8')(tarFile.extractfile(fileInfo))) |
fileInfo = tarFile.next() |
if fileData.unavailable: |
@@ -253,21 +248,15 @@ def readSubscriptions(): |
result[fileData.name] = fileData |
tarFile.close() |
calculateSupplemented(result) |
return result |
def getFallbackData(): |
repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
- (redirectData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'redirects')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |
- if errors: |
- print >>sys.stderr, errors |
- |
- (goneData, errors) = subprocess.Popen(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |
- if errors: |
- print >>sys.stderr, errors |
- |
+ redirectData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'redirects')]) |
+ goneData = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')]) |
return (redirectData, goneData) |
def _validateURL(url): |
parseResult = urlparse(url) |
return (parseResult.scheme == 'http' or parseResult.scheme == 'https') and parseResult.netloc != '' |