Show your open Trac tickets across all projects
This is a quick perl script to go through all the Trac projects in your environment and check for your open tickets.
#!/usr/bin/perl -w
use DBI;
use strict;
my $user = shift @ARGV;
if (not $user) {
print “USAGE: $0 username\n”;
exit;
}
$user = lc($user);my $baseurl = “http://trac.dade.co.za/”;
my $projdir = “/home/trac/projects”;
my @data = ();
$baseurl =~ s/\/$//;
foreach my $dir (<$projdir/*>) {
my $db = “$dir/db/trac.db”;
my $ini = “$dir/conf/trac.ini”;
my $projname = “unknown”;
my ($base) = $dir =~ /\/(\w+$)/;
my $url = “$baseurl/$base”;
open(FH,$ini) or die $!;
while(<FH>) {
chomp;
if (/^name = (.*)/) {
$projname = $1;
}
}
close(FH);
if (-e $db) {
#select sid,last_visit from session;
my $dbh = DBI->connect(“dbi:SQLite:dbname=$db”,””,””);
my $sth = $dbh->prepare(“select id,type,time,changetime,status,summary from ticket where lower(owner)= ? and status <> ‘closed'”);
$sth->bind_param(1,$user);
$sth->execute;
while (my @cols = $sth->fetchrow_array()) {
my $ticketurl = $url.”/ticket/”.$cols[0];
print “$ticketurl “.$projname.” – “.$cols[5].” [“.$cols[4].”]\n”;
}
$dbh->disconnect;
}
}
and the result …
[trac@pcmd001zapprh tools]$ ./user_tickets.pl leonard
http://trac.dade.co.za/Project1/ticket/2080 Access Request Management (ARM) – Remedy requirements for IDV integration [new]
http://trac.dade.co.za/Project31/ticket/130 Identity Registration System (IRS) – Move IRS training material out of EIT divisional site [new]
[trac@pcmd001zapprh tools]$
0 Comments