[24039] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r23647 - in trunk/athena/bin/bugme: . debian

daemon@ATHENA.MIT.EDU (Evan Broder)
Fri Mar 27 19:34:55 2009

Date: Fri, 27 Mar 2009 19:34:37 -0400
From: Evan Broder <broder@MIT.EDU>
Message-Id: <200903272334.n2RNYbVT008922@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: broder
Date: 2009-03-27 19:34:37 -0400 (Fri, 27 Mar 2009)
New Revision: 23647

Added:
   trunk/athena/bin/bugme/Makefile
   trunk/athena/bin/bugme/bugme
   trunk/athena/bin/bugme/bugme.glade
   trunk/athena/bin/bugme/bugme.xsession
   trunk/athena/bin/bugme/debian/
   trunk/athena/bin/bugme/debian/changelog
   trunk/athena/bin/bugme/debian/compat
   trunk/athena/bin/bugme/debian/control.in
   trunk/athena/bin/bugme/debian/copyright
   trunk/athena/bin/bugme/debian/rules
Removed:
   trunk/athena/bin/bugme/Makefile.in
   trunk/athena/bin/bugme/Snoop.c
   trunk/athena/bin/bugme/Snoop.h
   trunk/athena/bin/bugme/bugme.1
   trunk/athena/bin/bugme/bugme.c
   trunk/athena/bin/bugme/bugme.h
   trunk/athena/bin/bugme/configure.in
Log:
Initial Debianization of new PyGTK-based bugme.

Added: trunk/athena/bin/bugme/Makefile
===================================================================
--- trunk/athena/bin/bugme/Makefile	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/Makefile	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,10 @@
+DEFAULT:
+	@echo "Valid targets: install"
+
+install:
+	mkdir -p $(DESTDIR)/usr/bin
+	mkdir -p $(DESTDIR)/usr/share/bugme
+	mkdir -p $(DESTDIR)/etc/X11/Xsession.d
+	install -m 755 bugme $(DESTDIR)/usr/bin/bugme
+	install -m 644 bugme.glade $(DESTDIR)/usr/share/bugme/
+	install -m 644 bugme.xsession $(DESTDIR)/etc/X11/Xsession.d/98debathena-bugme

Deleted: trunk/athena/bin/bugme/Makefile.in

Deleted: trunk/athena/bin/bugme/Snoop.c

Deleted: trunk/athena/bin/bugme/Snoop.h

Added: trunk/athena/bin/bugme/bugme
===================================================================
--- trunk/athena/bin/bugme/bugme	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/bugme	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,120 @@
+#!/usr/bin/python -Wall
+
+import gtk
+import gtk.glade
+import gobject
+import time
+import os
+import sys
+from optparse import OptionParser
+
+gladeFile = "/usr/share/bugme/bugme.glade"
+
+class BugMe:
+    def __init__(self):
+        # Time limit in seconds  (600)
+        self.timeLimit = 600
+        # First warn the user when this many seconds remain (120)
+        self.firstWarn = 120
+        # How often to warn initially (secs)
+        self.warnInterval = 60
+        # How often to warn after time has expired (secs)
+        self.annoyInterval = 30
+        if options.debugMode:
+            self.timeLimit = 120
+            self.firstWarn = 90
+            self.warnInterval = 30
+            self.annoyInterval = 10
+        # (foreground, background)
+        self.colors = ('black', 'white')
+        try:
+            self.xml = gtk.glade.XML(gladeFile)
+        except:
+            print "Failed to create GladeXML object."
+            # Kill the child
+            os.kill(pid, 9)
+            sys.exit(255)
+        self.startTime = int(time.time())
+        self.timerWindow = self.xml.get_widget('TimerWindow')
+        self.nagDialog = self.xml.get_widget('NagDialog')
+        self.nagLabel = self.xml.get_widget('NagLabel')
+        self.elapsed_label = self.xml.get_widget('ElapsedLabel')
+        self.elapsed_label.set_markup("<span font_desc=\"50\">00:00</span>")
+        self.timer = gobject.timeout_add(1000, self.updateTimer)
+        self.xml.signal_autoconnect(self)
+        # 26 px should allow room for top panel
+        self.timerWindow.move(0,26)
+        self.timerWindow.show_all()
+        self.nextWarn = self.startTime + (self.timeLimit - self.firstWarn)
+        self.timeExpired = False
+        self.timerWindow.modify_bg(gtk.STATE_NORMAL, 
+                                   gtk.gdk.color_parse(self.colors[1]))
+
+
+    def updateTimer(self):
+        if pid == os.waitpid(pid, os.WNOHANG)[0]:
+            sys.exit(0)
+        now = int(time.time())
+        elapsed = now - self.startTime
+        elapsedTime = (elapsed / 60, elapsed % 60)
+        self.elapsed_label.set_markup("<span foreground=\"%s\" background=\"%s\" font_desc=\"50\">%02d:%02d</span>" % (self.colors + elapsedTime))
+        self.timerWindow.modify_bg(gtk.STATE_NORMAL, 
+                                   gtk.gdk.color_parse(self.colors[1]))
+        if elapsed >= self.timeLimit:
+            self.colors = ('white', 'red')
+            self.warnInterval = self.annoyInterval
+            self.timeExpired = True
+        if now >= self.nextWarn:
+            if elapsed < self.timeLimit:
+                self.colors = ('black', 'orange')
+            self.nextWarn = now + self.warnInterval
+            self.nag(((self.timeLimit - elapsed) / 60, 
+                      (self.timeLimit - elapsed) % 60))
+        return True
+
+    def nag(self, remainingTime):
+        if self.timeExpired:
+            self.nagLabel.set_markup("<span font_desc=\"20\">Please log out immediately.</span>")
+        else:
+            seconds = "%d second%s" % (remainingTime[1], 
+                                       remainingTime[1] != 1 and 's' or '')
+            minutes = "%d minute%s" % (remainingTime[0], 
+                                       remainingTime[0] != 1 and 's' or '')
+            if remainingTime[0] < 1:
+                remaining = seconds
+            elif remainingTime[1] == 0:
+                remaining = minutes
+            else:
+                remaining = "%s, %s" % (minutes, seconds)
+            self.nagLabel.set_markup("<span font_desc=\"20\">You have %s remaining\nin your login session.</span>" % (remaining))
+
+        self.nagDialog.show()
+
+    def on_dialog_response(self, dialog, response_id):
+        self.nagDialog.hide()
+
+
+if __name__ == '__main__':
+    if not os.access(gladeFile, os.R_OK):
+        print 'error: Unable to read glade file "' + gladeFile + '"'
+        sys.exit(255)
+
+    parser = OptionParser(usage="%prog [--debug] progname [args]",
+                          version="%prog 0.1")
+    parser.disable_interspersed_args()
+    parser.add_option("--debug", 
+                     action="store_true", dest="debugMode", default=False,
+                     help="Enable debug mode (time limit of 2 minutes)")
+    (options, args) = parser.parse_args()
+    if len(args) < 1:
+        parser.error("'progname' is required")
+    pid = os.fork()
+    if not pid:
+        os.putenv('ATHENA_QUICK', '1')
+        try:
+            os.execvp(args[0], args)
+        except:
+            print "error: Could not execvp(%s,%s)" % (args[0], args)
+    else:
+        BugMe()
+        gtk.main()


Property changes on: trunk/athena/bin/bugme/bugme
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/athena/bin/bugme/bugme.1

Deleted: trunk/athena/bin/bugme/bugme.c

Added: trunk/athena/bin/bugme/bugme.glade
===================================================================
--- trunk/athena/bin/bugme/bugme.glade	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/bugme.glade	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,171 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkWindow" id="TimerWindow">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Athena Quickstation</property>
+  <property name="type">GTK_WINDOW_POPUP</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="default_width">200</property>
+  <property name="default_height">70</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">False</property>
+  <property name="skip_taskbar_hint">True</property>
+  <property name="skip_pager_hint">True</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+
+  <child>
+    <widget class="GtkLabel" id="ElapsedLabel">
+      <property name="width_request">200</property>
+      <property name="height_request">70</property>
+      <property name="visible">True</property>
+      <property name="label" translatable="yes">00:00</property>
+      <property name="use_underline">False</property>
+      <property name="use_markup">True</property>
+      <property name="justify">GTK_JUSTIFY_CENTER</property>
+      <property name="wrap">False</property>
+      <property name="selectable">False</property>
+      <property name="xalign">0.5</property>
+      <property name="yalign">0.5</property>
+      <property name="xpad">0</property>
+      <property name="ypad">0</property>
+      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+      <property name="width_chars">4</property>
+      <property name="single_line_mode">False</property>
+      <property name="angle">0</property>
+    </widget>
+  </child>
+</widget>
+
+<widget class="GtkDialog" id="NagDialog">
+  <property name="title" translatable="yes">Athena Quickstation</property>
+  <property name="type">GTK_WINDOW_POPUP</property>
+  <property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
+  <property name="modal">True</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">True</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">True</property>
+  <signal name="response" handler="on_dialog_response" last_modification_time="Thu, 19 Mar 2009 16:24:14 GMT"/>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area1">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="okbutton1">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkFrame" id="frame1">
+	  <property name="border_width">5</property>
+	  <property name="visible">True</property>
+	  <property name="label_xalign">0</property>
+	  <property name="label_yalign">0.52999997139</property>
+	  <property name="shadow_type">GTK_SHADOW_IN</property>
+
+	  <child>
+	    <widget class="GtkAlignment" id="alignment1">
+	      <property name="visible">True</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xscale">1</property>
+	      <property name="yscale">1</property>
+	      <property name="top_padding">0</property>
+	      <property name="bottom_padding">0</property>
+	      <property name="left_padding">12</property>
+	      <property name="right_padding">0</property>
+
+	      <child>
+		<widget class="GtkLabel" id="NagLabel">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">label2</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">5</property>
+		  <property name="ypad">5</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+	      </child>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label1">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">&lt;span font_desc=&quot;13&quot;&gt;Athena Quickstation&lt;/span&gt;</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">True</property>
+	      <property name="justify">GTK_JUSTIFY_CENTER</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">5</property>
+	      <property name="ypad">5</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="type">label_item</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>

Deleted: trunk/athena/bin/bugme/bugme.h

Added: trunk/athena/bin/bugme/bugme.xsession
===================================================================
--- trunk/athena/bin/bugme/bugme.xsession	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/bugme.xsession	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,6 @@
+: ${FORCE_QUICKSTATION=0}
+
+grep -iq $(hostname --fqdn) /afs/athena/system/config/quick/quickstations
+if [ $? -eq 0 -o $FORCE_QUICKSTATION -eq 1 ] && [ -x /usr/bin/bugme ]; then
+    STARTUP="/usr/bin/bugme $STARTUP"
+fi

Deleted: trunk/athena/bin/bugme/configure.in

Added: trunk/athena/bin/bugme/debian/changelog
===================================================================
--- trunk/athena/bin/bugme/debian/changelog	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/debian/changelog	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,6 @@
+debathena-bugme (10.0.0-0debathena1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Jonathan Reed <jdreed@mit.edu>  Wed, 25 Mar 2009 11:23:10 -0400
+

Added: trunk/athena/bin/bugme/debian/compat
===================================================================
--- trunk/athena/bin/bugme/debian/compat	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/debian/compat	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1 @@
+4

Added: trunk/athena/bin/bugme/debian/control.in
===================================================================
--- trunk/athena/bin/bugme/debian/control.in	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/debian/control.in	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,15 @@
+Source: debathena-bugme
+Section: debathena/base
+Priority: extra
+Maintainer: Debathena Project <debathena@mit.edu>
+Build-Depends: @cdbs@
+Standards-Version: 3.8.0
+
+Package: debathena-bugme
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, python, python-gtk2, python-glade2
+Description: Display a timer for Athena Quickstations
+ Athena quickstations are designed for short-term login sessions.  This
+ time limit is enforced by a timer in the top left corner of the workstation
+ which displays the elapsed time of the login session and warns users when
+ they have exceeded the time limit.

Added: trunk/athena/bin/bugme/debian/copyright
===================================================================
--- trunk/athena/bin/bugme/debian/copyright	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/debian/copyright	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,18 @@
+The Athena source code was obtained from the Athena SVN repository at
+<svn://debathena.mit.edu/athena/trunk>, and is licensed as follows:
+
+  Copyright © 2008 by the Massachusetts Institute of Technology.
+
+  Permission to use, copy, modify, and distribute this software and
+  its documentation for any purpose and without fee is hereby granted,
+  provided that the above copyright notice appear in all copies and
+  that both that copyright notice and this permission notice appear in
+  supporting documentation, and that the name of M.I.T. not be used in
+  advertising or publicity pertaining to distribution of the software
+  without specific, written prior permission.  M.I.T. makes no
+  representations about the suitability of this software for any
+  purpose.  It is provided "as is" without express or implied
+  warranty.
+
+The Debian packaging is Copyright © 2008 Massachusetts Institute of
+Technology, and has the same license as the original software.

Added: trunk/athena/bin/bugme/debian/rules
===================================================================
--- trunk/athena/bin/bugme/debian/rules	2009-03-26 20:08:47 UTC (rev 23646)
+++ trunk/athena/bin/bugme/debian/rules	2009-03-27 23:34:37 UTC (rev 23647)
@@ -0,0 +1,6 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/makefile.mk
+
+DEB_MAKE_INSTALL_TARGET += install DESTDIR=$(DEB_DESTDIR)


Property changes on: trunk/athena/bin/bugme/debian/rules
___________________________________________________________________
Name: svn:executable
   + *


home help back first fref pref prev next nref lref last post