Revision: 856
http://assorted.svn.sourceforge.net/assorted/?rev=856&view=rev
Author: yangzhang
Date: 2008-06-29 19:54:06 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
added pidgin monitor
Added Paths:
-----------
pidgin-mon/
pidgin-mon/trunk/
pidgin-mon/trunk/README
pidgin-mon/trunk/publish.bash
pidgin-mon/trunk/src/
pidgin-mon/trunk/src/colorize.py
pidgin-mon/trunk/src/mon.bash
Added: pidgin-mon/trunk/README
===================================================================
--- pidgin-mon/trunk/README (rev 0)
+++ pidgin-mon/trunk/README 2008-06-30 02:54:06 UTC (rev 856)
@@ -0,0 +1,28 @@
+Overview
+========
+
+This tool monitors [Pidgin] system logs for changes in your buddies' statuses.
+Provides some simple coloring of output.
+
+[Pidgin]: http://pidgin.im/
+
+Setup
+=====
+
+Requirements:
+
+- [Python Commons](http://assorted.sf.net/python-commons/)
+
+Todo
+====
+
+Known issues:
+
+- ctrl-c/sigint does not actually manage to kill everything; you must manually
+ `pkill tail` afterward.
+
+General tasks:
+
+- Investigate whether Pidgin flushes logs in reasonable time bounds, and
+ whether there are any other such issues that could possibly be causing the
+ monitor to exhibit high latency.
Added: pidgin-mon/trunk/publish.bash
===================================================================
--- pidgin-mon/trunk/publish.bash (rev 0)
+++ pidgin-mon/trunk/publish.bash 2008-06-30 02:54:06 UTC (rev 856)
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+fullname='Pidgin Monitor'
+version=0.1
+license=gpl3
+websrcs=( README )
+rels=( src-tgz: )
+nodl=true
+. assorted.bash "$@"
Property changes on: pidgin-mon/trunk/publish.bash
___________________________________________________________________
Name: svn:executable
+ *
Added: pidgin-mon/trunk/src/colorize.py
===================================================================
--- pidgin-mon/trunk/src/colorize.py (rev 0)
+++ pidgin-mon/trunk/src/colorize.py 2008-06-30 02:54:06 UTC (rev 856)
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+from re import sub
+from sys import stdout
+from commons.misc import TerminalController
+from commons.startup import run_main
+
+def main( argv ):
+ term = TerminalController()
+ for line in stdin:
+ line = sub(r'(Online)', r'${BOLD}${GREEN}\1${NORMAL}', line)
+ line = sub(r'(Available)', r'${BOLD}${GREEN}\1${NORMAL}', line)
+ line = sub(r'(Away)', r'${BOLD}${YELLOW}\1${NORMAL}', line)
+ line = sub(r'(Offline)', r'${BOLD}${RED}\1${NORMAL}', line)
+ line = sub(r'^---- (.*) changed status', r'---- ${BOLD}${WHITE}\1${NORMAL} changed status', line)
+ print term.render(line),
+ stdout.flush()
+
+run_main()
Property changes on: pidgin-mon/trunk/src/colorize.py
___________________________________________________________________
Name: svn:executable
+ *
Added: pidgin-mon/trunk/src/mon.bash
===================================================================
--- pidgin-mon/trunk/src/mon.bash (rev 0)
+++ pidgin-mon/trunk/src/mon.bash 2008-06-30 02:54:06 UTC (rev 856)
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset
+
+pgid=
+
+lastlogs() {
+ for i in ~/.purple/logs/*/*/.system
+ do ls -t $i/* | head -1
+ done
+}
+
+colorize() {
+ "$(dirname "$0")/colorize.py"
+}
+
+tailit() {
+ tail -f $( lastlogs ) |
+ egrep -v '^$|^==> |Online to Online|Available to Available|Away to Away|Offline to Offline' |
+ colorize
+}
+
+handle() {
+ kill $pgid
+ exit
+}
+
+monitor() {
+ trap handle sigint
+ while true ; do
+ if [[ "$( lastlogs )" != "${currlogs:-}" ]] ; then
+ local currlogs="$( lastlogs )"
+ if [[ ! -z $pgid ]]
+ then kill $pgid ; wait $pgid
+ fi
+ tailit &
+ local pid=$!
+ # TODO: actually get the pgid instead of pid!
+ pgid=$pid
+ echo pgid $pgid
+ fi
+ sleep 60
+ done
+}
+
+monitor
Property changes on: pidgin-mon/trunk/src/mon.bash
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|