Skip to content

Commit

Permalink
Modified the campfirelistener.py to now read configuration values fro…
Browse files Browse the repository at this point in the history
…m trac.ini. Also updated the documentation.
  • Loading branch information
Ben Belchak committed May 13, 2010
1 parent 4a28996 commit bd31baf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
14 changes: 11 additions & 3 deletions campfirelistener/campfirelistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
import pinder
from trac.core import *
from trac.ticket.api import ITicketChangeListener
from trac.config import Option, IntOption, ListOption, BoolOption

class CampfireListener(Component):
implements(ITicketChangeListener)

prefix = Option('campfire', 'prefix', '')
projectPath = Option('campfire', 'path', '')
tracfqdn = Option('campfire', 'trachost', '')
subdomain = Option('campfire', 'subdomain', '')
apiToken = Option('campfire', 'apitoken', '')
roomId = Option('campfire', 'roomid', '')

def _sendText(self, ticketid, text):
try:
c = pinder.Campfire('SUBDOMAIN', 'API TOKEN')
room = c.room('ROOM ID')
room.speak("Trac: ticket #%i (http://trac.YOURDOMAIN.com/projects/PROJECT/ticket/%i) %s" % (ticketid, ticketid, text))
c = pinder.Campfire(subdomain, apiToken)
room = c.room(roomId)
room.speak("%s: ticket #%i (http://%s%s/ticket/%i) %s" % (prefix, tracfqdn, projectPath, ticketid, text))

except:
print "Unexpected error:", sys.exc_info()[0]
Expand Down
24 changes: 22 additions & 2 deletions readme.textile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
h1 Introduction
If you are using "trac":http://trac.edgewall.org/ and you want to display ticket changes on "Campfire":http://www.campfirenow.com/ here is a handy <strike>hack</strike> plugin.

Here is a juicy screenshot demonstrating how it looks like.
Expand All @@ -6,6 +7,7 @@ Here is a juicy screenshot demonstrating how it looks like.

If you'd rather use IRC instead of Campfire you might want to try out the handy "irccat":http://github.com/RJ/irccat/tree/master which is "notoriously used by the Last.fm development teams":http://www.metabrew.com/article/how-we-use-irc-at-lastfm/ instead. This Campfire plugin is actually only a slight change from the irccat trac plugin.

h1 Installation
So here’s the gist. You will need to install "Pinder":http://dev.oluyede.org/pinder/doc.html, a Campfire listener written in Python. It should be as easy as:

<pre>$ easy_install pinder</pre>
Expand All @@ -14,6 +16,24 @@ Then download or <code>git clone</code> the "Campfire trac listener plugin on gi

You will need to have "setuptools":http://peak.telecommunity.com/DevCenter/setuptools installed. (To install setuptools, download the bootstrap module "ez_setup.py":http://peak.telecommunity.com/dist/ez_setup.py and execute: <code>$ python ez_setup.py</code>)

Now edit <code>campfirelistener/campfirelistener.py</code> to your taste. Especially, you'll need to set up the Campfire subdomain (something like <code>subdomain.campfirenow.com</code>), the Campfire room, and the Campfire username and password (as you can see my Campfire wonderbot is named Hector). When it's all done run <code>python setup.py bdist_egg</code> to build the egg.
Next, go to the <code>campfire-trac-listener</code> directory that you've just created with your <code>git clone</code> and run <code>python ./setup.py install</code>.

If this installs successfully, you are ready to begin configuration.

h1 Configuration
Put the following into your <code>trac.ini</code> file:
<code>
[campfire]
prefix = Project Name (Typically)
path = /projects/project
trachost = trac.yourhost.com
subdomain = campfire_subdomain
apitoken = yourCampfireAPIToken
roomid = RoomID
</code>
You can find your room ID at the tail end of the URL when you are in your chat room.

Add the following to the <code>[components]</code> section:

<code>campfirelistener.* = enabled</code>

<code>setup.py</code> will create several subdirectories. The <code>TracCampfireListener-0.1-py2.5.egg</code> file is located in the <code>dist</code> directory. Copy it to the <code>plugins</code> directory of your local trac project folder (<code>/var/lib/trac/your_project/plugins</code> for instance). Chmod it and restart Apache for trac to use the plugin. That should be it.

0 comments on commit bd31baf

Please sign in to comment.