#!/usr/bin/env python # run-client-event # ---------------------------------------------------------------------------- # Copyright (c) 2008 Colin Guthrie # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # ---------------------------------------------------------------------------- # This email integration script is meant to interface to the Trac # (http://www.edgewall.com/products/trac/) issue tracking/wiki/etc # system import os import sys import locale import time from optparse import OptionParser from StringIO import StringIO from trac import __version__ from trac.core import * from trac.env import open_environment from trac.util.datefmt import format_date, to_datetime from trac.wiki import wiki_to_html from genshi import escape parser = OptionParser() depr = '(not used anymore)' parser.add_option('-e', '--env', dest='envpath', help='Required. Path to the Trac environment.') parser.add_option('-c', '--event', dest='event', help='The client event to run (required)') #parser.add_option('-d', action='store_true', dest='debug', # help='Turn on debug mode - does not update database and prints verbose messages.') #parser.add_option('-m', '--mail', dest='mail', # help='Email override. Useful in combination with -d.') #parser.set_defaults(period='daily', mailtype='summary') (options, args) = parser.parse_args(sys.argv[1:]) class SendClientFakeReq: def __init__(self): class SendClientFakeHref: def __call__(self, *args, **keywords): return '' def wiki(self, *args, **keywords): return '' def ticket(self, num): return '#%d' % (num) self.href = SendClientFakeHref() self.abs_href = SendClientFakeHref() self.perm = [] def __call__(self, *args, **keywords): return '' def perm(self, *args, **keywords): return [] class RunClientEvents: def __init__(self): locale.setlocale(locale.LC_ALL, '') self.env = open_environment(options.envpath) self.req = SendClientFakeReq() # Sync the repo so that any commits that happen to have been made # that include client comments are included. repos = self.env.get_repository() repos.sync() from clients.events import ClientEvent ClientEvent.triggerall(self.env, self.req, options.event) if __name__ == "__main__": if not options.envpath or not options.event: print "For usage: %s --help" % (sys.argv[0]) else: RunClientEvents()