Silence pychecker and pylint warnings
[public/pyceo-broken.git] / pylib / csc / apps / urwid / main.py
index dd58865..43f7ca7 100644 (file)
@@ -1,5 +1,5 @@
-import random, time, re
-import urwid, urwid.curses_display
+import random
+import urwid.curses_display
 
 from csc.apps.urwid.widgets import *
 from csc.apps.urwid.window import *
@@ -9,7 +9,6 @@ import csc.apps.urwid.info as info
 import csc.apps.urwid.search as search
 import csc.apps.urwid.positions as positions
 import csc.apps.urwid.groups as groups
-from csc.apps.urwid.error import *
 
 from csc.adm import accounts, members, terms
 from csc.common.excep import InvalidArgument
@@ -34,10 +33,10 @@ def program_name():
         "Embryonic", "Emigrant", "Emissary's", "Emoting", "Employment", "Emulated",
         "Enabling", "Enamoring", "Encapsulated", "Enchanted", "Encoded", "Encrypted",
         "Encumbered", "Endemic", "Enhanced", "Enigmatic", "Enlightened", "Enormous",
-        "Enrollment", "Enshrouded", "Ephermal", "Epidemic", "Episodic", "Epsilon",
+        "Enrollment", "Enshrouded", "Ephemeral", "Epidemic", "Episodic", "Epsilon",
         "Equitable", "Equestrian", "Equilateral", "Erroneous", "Erratic",
         "Espresso", "Essential", "Estate", "Esteemed", "Eternal", "Ethical", "Eucalyptus",
-        "Euphemistic", "Envangelist", "Evasive", "Everyday", "Evidence", "Eviction", "Evildoer's",
+        "Euphemistic", "Evangelist", "Evasive", "Everyday", "Evidence", "Eviction", "Evildoer's",
         "Evolution", "Exacerbation", "Exalted", "Examiner's", "Excise", "Exciting", "Exclusion",
         "Exec", "Executioner's", "Exile", "Existential", "Expedient", "Expert", "Expletive",
         "Exploiter's", "Explosive", "Exponential", "Exposing", "Extortion", "Extraction",
@@ -74,25 +73,16 @@ def main_menu():
         ("Search", search_members, None),
         ("Manage Club or Group Members", manage_group, None),
         ("Manage Positions", manage_positions, None),
-        ("Manage Office Staff", group_members, office_data),
-        ("Manage Systems Committee", group_members, syscom_data),
+        ("Manage Office Staff", groups.group_members,
+            (office_data, ui.uid)),
+        ("Manage Systems Committee", groups.group_members,
+            (syscom_data, ui.uid)),
         ("Exit", raise_abort, None),
     ]
 
     listbox = urwid.ListBox( menu_items( menu ) )
     return listbox
 
-def push_wizard(name, pages, dimensions=(50, 10)):
-    state = {}
-    wiz = Wizard()
-    for page in pages:
-        if type(page) != tuple:
-            page = (page, )
-        wiz.add_panel( page[0](state, *page[1:]) )
-    push_window( urwid.Filler( urwid.Padding(
-        urwid.LineBox(wiz), 'center', dimensions[0]),
-        'middle', dimensions[1] ), name )
-
 def new_member(*args, **kwargs):
     push_wizard("New Member", [
         newmember.IntroPage,
@@ -112,7 +102,7 @@ def new_club(*args, **kwargs):
 def manage_group(*args, **kwargs):
     push_wizard("Manage Club or Group Members", [
         groups.IntroPage,
-        groups.InfoPage,
+        (groups.InfoPage, ui.uid),
     ], (60, 15))
 
 def renew_member(*args, **kwargs):
@@ -157,24 +147,6 @@ def manage_positions(data):
         positions.EndPage,
     ], (50, 15))
 
-def group_members(data):
-    add_data = data.copy()
-    add_data['type'] = 'Add'
-    remove_data = data.copy()
-    remove_data['type'] = 'Remove'
-    menu = [
-        ("Add %s member" % data["name"].lower(),
-            groups.change_group_member, add_data),
-        ("Remove %s member" % data["name"].lower(),
-            groups.change_group_member, remove_data),
-        ("List %s members" % data["name"].lower(),
-            groups.list_group_members, data),
-        ("Back", raise_back, None),
-    ]
-
-    listbox = urwid.ListBox( menu_items( menu ) )
-    push_window(listbox, "Manage %s" % data["name"])
-
 def run():
     members.connect()
     accounts.connect()
@@ -182,8 +154,11 @@ def run():
     push_window( main_menu(), program_name() )
     event_loop( ui )
 
-def start():
+def start(uid, gid):
+    ui.uid = uid
+    ui.gid = gid
     ui.run_wrapper( run )
 
 if __name__ == '__main__':
-    start()
+    import os
+    start(os.getuid(), os.getgid())