| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # coding: utf-8 | |
| 2 | |
| 3 # This file is part of the Adblock Plus web scripts, | |
| 4 # Copyright (C) 2006-2015 Eyeo GmbH | |
| 5 # | |
| 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 | |
| 8 # published by the Free Software Foundation. | |
| 9 # | |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | |
| 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 # GNU General Public License for more details. | |
| 14 # | |
| 15 # You should have received a copy of the GNU General Public License | |
| 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | |
| 18 import tempfile | |
| 19 import shutil | |
| 20 | |
| 21 from sitescripts.utils import get_config | |
| 22 | |
| 23 config = get_config() | |
| 24 live_config = { | |
| 25 "database": config.get("filterhitstats", "database"), | |
| 26 "log_dir": config.get("filterhitstats", "log_dir") | |
| 27 } | |
| 28 test_config = { | |
| 29 "database": config.get("filterhitstats", "test_database"), | |
| 30 "log_dir": tempfile.mkdtemp() | |
|
Wladimir Palant
2015/03/30 19:07:04
This will create the directory exactly once rather
kzar
2015/03/30 19:29:03
Ugh sorry, good point. (I didn't notice this as I'
| |
| 31 } | |
| 32 | |
| 33 def setup_config(): | |
| 34 config.set("filterhitstats", "database", test_config["database"]) | |
| 35 config.set("filterhitstats", "log_dir", test_config["log_dir"]) | |
| 36 return config | |
| 37 | |
| 38 def restore_config(): | |
| 39 config.set("filterhitstats", "database", live_config["database"]) | |
| 40 config.set("filterhitstats", "log_dir", live_config["log_dir"]) | |
| 41 shutil.rmtree(test_config["log_dir"], ignore_errors=True) | |
| OLD | NEW |