| OLD | NEW | 
|---|
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, | 
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present 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 | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 48     subscriptions = subscriptionParser.readSubscriptions().values() | 48     subscriptions = subscriptionParser.readSubscriptions().values() | 
| 49     subscriptions.sort(key=lambda s: s.name.lower()) | 49     subscriptions.sort(key=lambda s: s.name.lower()) | 
| 50 | 50 | 
| 51     urls = {} | 51     urls = {} | 
| 52     sites = {} | 52     sites = {} | 
| 53     for subscription in subscriptions: | 53     for subscription in subscriptions: | 
| 54         for key in ('homepage', 'forum', 'blog', 'faq', 'contact', 'changelog', 
     'policy'): | 54         for key in ('homepage', 'forum', 'blog', 'faq', 'contact', 'changelog', 
     'policy'): | 
| 55             url = getattr(subscription, key) | 55             url = getattr(subscription, key) | 
| 56             if url != None: | 56             if url != None: | 
| 57                 urls[url] = True | 57                 urls[url] = True | 
| 58         for (title, url, complete) in subscription.variants: | 58         for title, url, complete in subscription.variants: | 
| 59             urls[url] = True | 59             urls[url] = True | 
| 60 | 60 | 
| 61     pool = eventlet.GreenPool() | 61     pool = eventlet.GreenPool() | 
| 62     for (url, result) in pool.imap(checkURL, urls.iterkeys()): | 62     for url, result in pool.imap(checkURL, urls.iterkeys()): | 
| 63         urls[url] = result | 63         urls[url] = result | 
| 64         if result is False: | 64         if result is False: | 
| 65             sites[urlparse(url).netloc] = True | 65             sites[urlparse(url).netloc] = True | 
| 66     for (site, result) in pool.imap(checkSite, sites.iterkeys()): | 66     for site, result in pool.imap(checkSite, sites.iterkeys()): | 
| 67         sites[site] = result | 67         sites[site] = result | 
| 68 | 68 | 
| 69     result = [] | 69     result = [] | 
| 70     for subscription in subscriptions: | 70     for subscription in subscriptions: | 
| 71         s = {'name': subscription.name, 'links': []} | 71         s = {'name': subscription.name, 'links': []} | 
| 72         result.append(s) | 72         result.append(s) | 
| 73         for key in ('homepage', 'forum', 'blog', 'faq', 'contact', 'changelog', 
     'policy'): | 73         for key in ('homepage', 'forum', 'blog', 'faq', 'contact', 'changelog', 
     'policy'): | 
| 74             url = getattr(subscription, key) | 74             url = getattr(subscription, key) | 
| 75             if url != None: | 75             if url != None: | 
| 76                 site = urlparse(url).netloc | 76                 site = urlparse(url).netloc | 
| 77                 s['links'].append({ | 77                 s['links'].append({ | 
| 78                     'url': url, | 78                     'url': url, | 
| 79                     'title': key[0].upper() + key[1:], | 79                     'title': key[0].upper() + key[1:], | 
| 80                     'result': urls[url], | 80                     'result': urls[url], | 
| 81                     'siteResult': site in sites and sites[site], | 81                     'siteResult': site in sites and sites[site], | 
| 82                 }) | 82                 }) | 
| 83         for (title, url, complete) in subscription.variants: | 83         for title, url, complete in subscription.variants: | 
| 84             site = urlparse(url).netloc | 84             site = urlparse(url).netloc | 
| 85             s['links'].append({ | 85             s['links'].append({ | 
| 86                 'url': url, | 86                 'url': url, | 
| 87                 'title': title, | 87                 'title': title, | 
| 88                 'result': urls[url], | 88                 'result': urls[url], | 
| 89                 'siteResult': site in sites and sites[site], | 89                 'siteResult': site in sites and sites[site], | 
| 90             }) | 90             }) | 
| 91     return result | 91     return result | 
| 92 | 92 | 
| 93 | 93 | 
| 94 if __name__ == '__main__': | 94 if __name__ == '__main__': | 
| 95     setupStderr() | 95     setupStderr() | 
| 96 | 96 | 
| 97     subscriptions = checkSubscriptions() | 97     subscriptions = checkSubscriptions() | 
| 98     outputFile = get_config().get('subscriptions', 'statusPage') | 98     outputFile = get_config().get('subscriptions', 'statusPage') | 
| 99     template = get_template(get_config().get('subscriptions', 'statusTemplate')) | 99     template = get_template(get_config().get('subscriptions', 'statusTemplate')) | 
| 100     template.stream({'subscriptions': subscriptions}).dump(outputFile, encoding=
     'utf-8') | 100     template.stream({'subscriptions': subscriptions}).dump(outputFile, encoding=
     'utf-8') | 
| OLD | NEW | 
|---|