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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 build_url = '%s/%s?update' % (builds_url, os.path.basename(build['path'])) | 62 build_url = '%s/%s?update' % (builds_url, os.path.basename(build['path'])) |
63 with open(build['path'], 'rb') as build_file: | 63 with open(build['path'], 'rb') as build_file: |
64 build_content = build_file.read() | 64 build_content = build_file.read() |
65 return _MANIFEST_TEMPLATE.render({ | 65 return _MANIFEST_TEMPLATE.render({ |
66 'build': { | 66 'build': { |
67 'build_id': build['id'], | 67 'build_id': build['id'], |
68 'url': build_url, | 68 'url': build_url, |
69 'hash_function': 'SHA512', | 69 'hash_function': 'SHA512', |
70 'hash_value': hashlib.sha512(build_content).hexdigest(), | 70 'hash_value': hashlib.sha512(build_content).hexdigest(), |
71 'size': len(build_content) | 71 'size': len(build_content), |
72 } | 72 }, |
73 }) | 73 }) |
74 | 74 |
75 | 75 |
76 def _get_update_manifest(current_build_id, builds_dir, builds_url): | 76 def _get_update_manifest(current_build_id, builds_dir, builds_url): |
77 if not os.path.isdir(builds_dir): | 77 if not os.path.isdir(builds_dir): |
78 return _render_manifest() | 78 return _render_manifest() |
79 | 79 |
80 latest_build = _get_latest_build(builds_dir) | 80 latest_build = _get_latest_build(builds_dir) |
81 if not latest_build or current_build_id >= latest_build['id']: | 81 if not latest_build or current_build_id >= latest_build['id']: |
82 return _render_manifest() | 82 return _render_manifest() |
(...skipping 28 matching lines...) Expand all Loading... |
111 def adblockbrowser_devbuild_updates(environ, start_response): | 111 def adblockbrowser_devbuild_updates(environ, start_response): |
112 config = get_config() | 112 config = get_config() |
113 | 113 |
114 nightlies_dir = config.get('extensions', 'nightliesDirectory') | 114 nightlies_dir = config.get('extensions', 'nightliesDirectory') |
115 builds_dir = os.path.join(nightlies_dir, 'adblockbrowser') | 115 builds_dir = os.path.join(nightlies_dir, 'adblockbrowser') |
116 | 116 |
117 nightlies_url = config.get('extensions', 'nightliesURL').rstrip('/') | 117 nightlies_url = config.get('extensions', 'nightliesURL').rstrip('/') |
118 builds_url = '%s/adblockbrowser' % nightlies_url | 118 builds_url = '%s/adblockbrowser' % nightlies_url |
119 | 119 |
120 return _handle_request(environ, start_response, builds_dir, builds_url) | 120 return _handle_request(environ, start_response, builds_dir, builds_url) |
OLD | NEW |