| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # coding: utf-8 | 1 # coding: utf-8 |
| 3 | 2 |
| 4 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 5 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 Eyeo GmbH |
| 6 # | 5 # |
| 7 # 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 |
| 8 # 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 |
| 9 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 10 # | 9 # |
| 11 # 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, |
| 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
| 15 # | 14 # |
| 16 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
| 17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 17 |
| 19 import os, re | 18 import os |
| 20 from flup.server.fcgi import WSGIServer | |
| 21 | 19 |
| 22 from sitescripts.web import multiplex | 20 from sitescripts.utils import get_config |
| 23 | 21 |
| 24 bindAddress = None | 22 config = get_config() |
| 25 if 'FCGI_BIND_ADDRESS' in os.environ: | 23 live_config = { |
| 26 match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS']) | 24 "database": config.get("filterhitstats", "database"), |
| 27 bindAddress = (match.group(1), int(match.group(2))) | 25 "log_dir": config.get("filterhitstats", "log_dir") |
| 28 srv = WSGIServer(multiplex, debug=False, bindAddress=bindAddress) | 26 } |
| 27 test_config = { | |
| 28 "database": config.get("filterhitstats", "test_database"), | |
| 29 "log_dir": os.path.join(os.path.dirname(__file__), "temp") | |
| 30 } | |
| 29 | 31 |
| 30 if __name__ == '__main__': | 32 def setup_config(): |
| 31 srv.run() | 33 config.set("filterhitstats", "database", test_config["database"]) |
| 34 config.set("filterhitstats", "log_dir", test_config["log_dir"]) | |
|
Wladimir Palant
2015/03/30 13:13:46
Maybe create a real temporary directory rather tha
kzar
2015/03/30 15:14:53
Done.
| |
| 35 return config | |
| 32 | 36 |
| 37 def restore_config(): | |
| 38 config.set("filterhitstats", "database", live_config["database"]) | |
| 39 config.set("filterhitstats", "log_dir", live_config["log_dir"]) | |
|
Wladimir Palant
2015/03/30 13:13:46
Remove the temporary log directory here?
kzar
2015/03/30 15:14:53
Done.
| |
| OLD | NEW |