From a16c2eb6bb3e1f94a37c1dc89d4b05853f7b0d4f Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 31 Aug 2012 14:52:51 +0800 Subject: [PATCH] Command to purge cache --- moodle-purge.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 moodle-purge.py diff --git a/moodle-purge.py b/moodle-purge.py new file mode 100755 index 0000000..da93498 --- /dev/null +++ b/moodle-purge.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Moodle Development Kit + +Copyright (c) 2012 Frédéric Massart - FMCorz.net + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +http://github.com/FMCorz/mdk +""" + +import sys +import argparse +from lib import config, workplace, moodle, tools +from lib.tools import debug + +C = config.Conf().get +Wp = workplace.Workplace() + +# Arguments +parser = argparse.ArgumentParser(description='Purge an instance cache') +parser.add_argument('name', metavar='name', default=None, nargs='?', help='name of the instance') +args = parser.parse_args() + +M = Wp.resolve(args.name) +if not M: + debug('This is not a Moodle instance') + sys.exit(1) + +try: + M.cli('admin/cli/purge_caches.php', stderr=None, stdout=None) +except Exception as e: + debug(e) + +debug('Done.') -- 2.11.0