Skip to content

/ Zope / gocept svn checkins / Archive / 2009 / 2009-05 / SVN: r29713 - gocept.infrastructure/testing/util/tools

[ << ] [ >> ]

[ SVN: r29710 - zopeversions / Wolfgang Schnerring ... ] [ SVN: r29720 - gocept.lms/deployment/profiles / ... ]

SVN: r29713 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 14:05:35 [ FULL ]
Author: ckauhaus
Date: Tue May  5 14:05:33 2009
New Revision: 29713

Log:
started RT to Redmine migration script



Added:
   gocept.infrastructure/testing/util/tools/
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Added: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- (empty file)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 14:05:33
2009
(at)(at) -0,0 +1,6 (at)(at)
+#!/bin/bash
+# Migrate RT ticket content to redmine. We scan RT's database for open tickets
+# in the specified queue and format a nice output which can be fed into
Redmine
+# through the mail interface.
+
+set -e

SVN: r29714 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 14:24:14 [ FULL ]
Author: ckauhaus
Date: Tue May  5 14:24:13 2009
New Revision: 29714

Log:
queue selection


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine   (contents, props
changed)

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 14:24:13
2009
(at)(at) -2,5 +2,20 (at)(at)
 # Migrate RT ticket content to redmine. We scan RT's database for open tickets
 # in the specified queue and format a nice output which can be fed into
Redmine
 # through the mail interface.
-
+# We assume that we can access RT's psql database without password.
+#
+# Copyright (c) 2009 gocept gmbh & co. kg
 set -e
+
+DBNAME="rt3"
+
+psqlc() {
+    local cmd="$1"
+    echo "$cmd" | psql -t -q "${DBNAME}"
+}
+
+queue=${1:?"queue name missing"}
+qid=$(psqlc "select id from queues where name = '${queue}'")
+if [[ -z ${qid} ]]; then
+    echo "$0: cannot find RT queue ${queue}"
+fi

SVN: r29715 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 14:57:20 [ FULL ]
Author: ckauhaus
Date: Tue May  5 14:57:19 2009
New Revision: 29715

Log:
does roughly what it is supposed to do


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 14:57:19
2009
(at)(at) -15,7 +15,26 (at)(at)
 }
 
 queue=${1:?"queue name missing"}
+recipient=${2}
+mailcmd="cat"
+
 qid=$(psqlc "select id from queues where name = '${queue}'")
 if [[ -z ${qid} ]]; then
     echo "$0: cannot find RT queue ${queue}"
 fi
+
+IFS="| "
+psqlc "select id, subject from tickets where status in ('new', 'open') 
+and queue = ${qid} order by told
+" | while read oid subject; do
+    echo subject=${subject}
+    if [[ -z ${oid} ]]; then continue; fi
+    tmp=$(tempfile -p mail)
+    echo oid=${oid} > ${tmp}
+    psqlc "select headers, content from attachments a join transactions txn on
+    a.transactionid = txn.id where txn.objectid = ${oid} and content like
'___%'
+    order by txn.created
+    " | tr '|' '\n' >> ${tmp}
+    ${mailcmd} < ${tmp}
+    rm -f ${tmp}
+done

SVN: r29716 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 15:42:47 [ FULL ]
Author: ckauhaus
Date: Tue May  5 15:42:46 2009
New Revision: 29716

Log:
output tickets as files in current dir


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 15:42:46
2009
(at)(at) -4,6 +4,8 (at)(at)
 # through the mail interface.
 # We assume that we can access RT's psql database without password.
 #
+# Individual tickets are output as files named with the ticket number. The
+# conform to the RFC822 message standard and can be piped into sendmail.
 # Copyright (c) 2009 gocept gmbh & co. kg
 set -e
 
(at)(at) -15,8 +17,6 (at)(at)
 }
 
 queue=${1:?"queue name missing"}
-recipient=${2}
-mailcmd="cat"
 
 qid=$(psqlc "select id from queues where name = '${queue}'")
 if [[ -z ${qid} ]]; then
(at)(at) -27,14 +27,15 (at)(at)
 psqlc "select id, subject from tickets where status in ('new', 'open') 
 and queue = ${qid} order by told
 " | while read oid subject; do
-    echo subject=${subject}
     if [[ -z ${oid} ]]; then continue; fi
-    tmp=$(tempfile -p mail)
-    echo oid=${oid} > ${tmp}
-    psqlc "select headers, content from attachments a join transactions txn on
-    a.transactionid = txn.id where txn.objectid = ${oid} and content like
'___%'
-    order by txn.created
-    " | tr '|' '\n' >> ${tmp}
-    ${mailcmd} < ${tmp}
-    rm -f ${tmp}
+    fname="${oid}.txt"
+    cat <<__EOT__ > ${fname}
+Subject: ${subject}
+X-OID: ${oid}
+
+__EOT__
+    psqlc "select a.headers, a.content from attachments a join transactions
txn
+    on a.transactionid = txn.id where txn.objectid = ${oid} and
+    content like '___%' order by txn.created
+    " | tr '|' '\n' >> ${fname}
 done

SVN: r29717 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 15:53:46 [ FULL ]
Author: ckauhaus
Date: Tue May  5 15:53:45 2009
New Revision: 29717

Log:
improve ticket presentation


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 15:53:45
2009
(at)(at) -36,6 +36,8 (at)(at)
 __EOT__
     psqlc "select a.headers, a.content from attachments a join transactions
txn
     on a.transactionid = txn.id where txn.objectid = ${oid} and
-    content like '___%' order by txn.created
-    " | tr '|' '\n' >> ${fname}
+    content like '___%' and type in ('Create', 'Comment', 'Reply')
+    order by txn.created
+    " | tr '|' '\n' | sed -e 's/^ *//' >> ${fname}
+    echo >> ${fname}
 done

SVN: r29718 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-05 16:33:14 [ FULL ]
Author: ckauhaus
Date: Tue May  5 16:33:12 2009
New Revision: 29718

Log:
delete useless spaces that confuse textile


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Tue May  5 16:33:12
2009
(at)(at) -34,10 +34,10 (at)(at)
 X-OID: ${oid}
 
 __EOT__
-    psqlc "select a.headers, a.content from attachments a join transactions
txn
-    on a.transactionid = txn.id where txn.objectid = ${oid} and
+    psqlc "select '', a.headers, a.content from attachments a
+    join transactions txn on a.transactionid = txn.id
+    where txn.objectid = ${oid} and
     content like '___%' and type in ('Create', 'Comment', 'Reply')
     order by txn.created
-    " | tr '|' '\n' | sed -e 's/^ *//' >> ${fname}
-    echo >> ${fname}
+    " | sed -e 's/ *| */\n/g' >> ${fname}
 done

SVN: r29719 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-07 15:10:22 [ FULL ]
Author: ckauhaus
Date: Thu May  7 15:10:21 2009
New Revision: 29719

Log:
usage example


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Thu May  7 15:10:21
2009
(at)(at) -6,6 +6,8 (at)(at)
 #
 # Individual tickets are output as files named with the ticket number. The
 # conform to the RFC822 message standard and can be piped into sendmail.
+# Example: for f in [0-9]*.txt; do sendmail -f FROMADDR TOADDR < $f; done
+#
 # Copyright (c) 2009 gocept gmbh & co. kg
 set -e

SVN: r29722 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-08 15:33:40 [ FULL ]
Author: ckauhaus
Date: Fri May  8 15:33:39 2009
New Revision: 29722

Log:
whitespace


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Fri May  8 15:33:39
2009
(at)(at) -43,3 +43,4 (at)(at)
     order by txn.created
     " | sed -e 's/ *| */\n/g' >> ${fname}
 done
+

SVN: r29723 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-08 15:35:42 [ FULL ]
Author: ckauhaus
Date: Fri May  8 15:35:41 2009
New Revision: 29723

Log:
whitespace


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Fri May  8 15:35:41
2009
(at)(at) -43,4 +43,3 (at)(at)
     order by txn.created
     " | sed -e 's/ *| */\n/g' >> ${fname}
 done
-

SVN: r29724 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-08 15:45:23 [ FULL ]
Author: ckauhaus
Date: Fri May  8 15:45:22 2009
New Revision: 29724

Log:
whitespace


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Fri May  8 15:45:22
2009
(at)(at) -43,3 +43,4 (at)(at)
     order by txn.created
     " | sed -e 's/ *| */\n/g' >> ${fname}
 done
+

SVN: r29725 - gocept.infrastructure/testing/util/tools
Christian Kauhaus <kc(at)gocept.com>
2009-05-08 15:46:16 [ FULL ]
Author: ckauhaus
Date: Fri May  8 15:46:15 2009
New Revision: 29725

Log:
whitespace


Modified:
   gocept.infrastructure/testing/util/tools/rt-to-redmine

Modified: gocept.infrastructure/testing/util/tools/rt-to-redmine
==============================================================================
--- gocept.infrastructure/testing/util/tools/rt-to-redmine	(original)
+++ gocept.infrastructure/testing/util/tools/rt-to-redmine	Fri May  8 15:46:15
2009
(at)(at) -43,4 +43,3 (at)(at)
     order by txn.created
     " | sed -e 's/ *| */\n/g' >> ${fname}
 done
-

MailBoxer