From 5732b16afc553c74b1278019271c91d9ad8ce4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 31 Aug 2016 16:01:42 +0200 Subject: [PATCH] Allow kicking the SVN observer from an HTTP entry point. For now just uses a hard-coded SVN URL, and never stores the last-seen revision. As a result, it always examines all revisions. --- attract_server/modules.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/attract_server/modules.py b/attract_server/modules.py index 6a69e7e..5fa54c0 100644 --- a/attract_server/modules.py +++ b/attract_server/modules.py @@ -1,9 +1,32 @@ +import logging + from flask import Blueprint from pillar.api.utils import jsonify blueprint = Blueprint('attract', __name__) +log = logging.getLogger(__name__) @blueprint.route('/jemoeder') def jemoeder(): return jsonify({'je': 'moeder'}) + + +@blueprint.route('/subversion/kick') +def subversion_kick(): + from . import subversion + + # TODO: each project should have its own SVN server. + svn_server_url = 'svn://localhost/agent327' + log.info('Re-examining SVN server %s', svn_server_url) + client = subversion.obtain(svn_server_url) + + # TODO: last_seen_revision should be stored, probably at the project level. + last_seen_revision = 0 + observer = subversion.CommitLogObserver(client, last_seen_revision=last_seen_revision) + observer.fetch_and_observe() + + return jsonify({ + 'previous_last_seen_revision': last_seen_revision, + 'last_seen_revision': observer.last_seen_revision, + })