Index: trunk/tools/editor_trends/cronjobs.py |
— | — | @@ -0,0 +1,70 @@ |
| 2 | +#!/usr/bin/python |
| 3 | +# -*- coding: utf-8 -*- |
| 4 | +''' |
| 5 | +Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com) |
| 6 | +This program is free software; you can redistribute it and/or |
| 7 | +modify it under the terms of the GNU General Public License version 2 |
| 8 | +as published by the Free Software Foundation. |
| 9 | +This program is distributed in the hope that it will be useful, |
| 10 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | +See the GNU General Public License for more details, at |
| 13 | +http://www.fsf.org/licenses/gpl.html |
| 14 | +''' |
| 15 | + |
| 16 | +__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ]) |
| 17 | +__email__ = 'dvanliere at gmail dot com' |
| 18 | +__date__ = '2010-10-21' |
| 19 | +__version__ = '0.1' |
| 20 | + |
| 21 | +from multiprocessing import Process |
| 22 | + |
| 23 | + |
| 24 | +from database import db |
| 25 | +from utils import wikiprojects |
| 26 | +import manage as manager |
| 27 | + |
| 28 | +def launch_editor_trends_toolkit(task): |
| 29 | + ''' |
| 30 | + This function should only be called as a cronjob. |
| 31 | + ''' |
| 32 | + parser, settings, wiki = manager.init_args_parser() |
| 33 | + args = parser.parse_args(['django']) |
| 34 | + args.language = wikiprojects.get_language(task['language']) |
| 35 | + args.project = task['project'] |
| 36 | + print args |
| 37 | + wiki = wikiprojects.Wiki(settings, args) |
| 38 | + manager.all_launcher(wiki, settings, None) |
| 39 | + #wiki.update_language(language) |
| 40 | + #wiki.update_project(project) |
| 41 | + |
| 42 | + #p = Process(target=manager.all_launcher, args=(wiki, settings, None)) |
| 43 | + #p.start() |
| 44 | + |
| 45 | +def launch_chart(project, language): |
| 46 | + pass |
| 47 | + |
| 48 | + |
| 49 | +def launcher(): |
| 50 | + mongo = db.init_mongo_db('wikilytics') |
| 51 | + coll = mongo['jobs'] |
| 52 | + tasks = [] |
| 53 | + #'in_progress': False} |
| 54 | + jobs = coll.find({'finished': False, 'in_progress': False}) |
| 55 | + for job in jobs: |
| 56 | + tasks.append(job) |
| 57 | + |
| 58 | + for task in tasks: |
| 59 | + if task['jobtype'] == 'dataset': |
| 60 | + launch_editor_trends_toolkit(task) |
| 61 | + elif task['jobtype'] == 'chart': |
| 62 | + launch_chart(task) |
| 63 | + |
| 64 | +def debug(): |
| 65 | + project = 'wiki' |
| 66 | + language = 'en' |
| 67 | + #launch_editor_trends_toolkit(project, language) |
| 68 | + launcher() |
| 69 | + |
| 70 | +if __name__ == '__main__': |
| 71 | + debug() |
Property changes on: trunk/tools/editor_trends/cronjobs.py |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 72 | + native |