Add inactive command
authorDavid Bartley <dtbartle@csclub.uwaterloo.ca>
Mon, 10 Mar 2008 04:25:08 +0000 (00:25 -0400)
committerDavid Bartley <dtbartle@csclub.uwaterloo.ca>
Mon, 10 Mar 2008 04:25:08 +0000 (00:25 -0400)
ceo/console/inactive.py [new file with mode: 0644]
ceo/console/main.py

diff --git a/ceo/console/inactive.py b/ceo/console/inactive.py
new file mode 100644 (file)
index 0000000..5e71f9a
--- /dev/null
@@ -0,0 +1,21 @@
+from ceo import members, terms
+
+def max_term(term1, term2):
+    if terms.compare(term1, term2) > 0:
+        return term1
+    else:
+        return term2
+
+class Inactive:
+  def main(self, args):
+    if len(args) != 1:
+        print "Usage: ceo inactive delta-terms"
+        return
+    delta = int(args[0])
+    mlist = members.list_all()
+    for member in mlist.values():
+        term = "f0000"
+        term = reduce(max_term, member.get("term", []), term)
+        term = reduce(max_term, member.get("nonMemberTerm", []), term)
+        if terms.delta(term, terms.current()) > delta:
+            print "%s %s" % (member['uid'][0].ljust(12), term)
index 2a81f55..e375345 100644 (file)
@@ -5,11 +5,13 @@ from ceo import members, terms, uwldap, ldapi
 from ceo.console.memberlist import MemberList
 from ceo.console.updateprograms import UpdatePrograms
 from ceo.console.expiredaccounts import ExpiredAccounts
+from ceo.console.inactive import Inactive
 
 commands = {
   'memberlist' : MemberList(),
   'updateprograms' : UpdatePrograms(),
   'expiredaccounts' : ExpiredAccounts(),
+  'inactive': Inactive(),
 }
 
 shortopts = [