pyceo-broken/bin/ceo

43 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
2009-09-09 06:56:31 -04:00
import sys, ldap
from getpass import getpass
import ceo.urwid.main
import ceo.console.main
from ceo import ldapi, members, library
def start():
try:
2009-11-02 15:18:55 -05:00
if len(sys.argv) == 1:
print "Reading config file...",
members.configure()
library.configure()
2009-09-09 06:56:31 -04:00
2009-11-02 15:18:55 -05:00
print "Connecting to LDAP..."
members.connect(AuthCallback())
2009-09-09 06:56:31 -04:00
ceo.urwid.main.start()
else:
2009-11-02 15:18:55 -05:00
members.configure()
library.configure()
members.connect(AuthCallback())
2009-09-09 06:56:31 -04:00
ceo.console.main.start()
except ldap.LOCAL_ERROR, e:
print ldapi.format_ldaperror(e)
except ldap.INSUFFICIENT_ACCESS, e:
print ldapi.format_ldaperror(e)
print "You probably aren't permitted to do whatever you just tried."
print "Admittedly, ceo probably shouldn't have crashed either."
class AuthCallback:
def callback(self, error):
try:
print "Password: ",
return getpass("")
except KeyboardInterrupt:
print ""
sys.exit(1)
if __name__ == '__main__':
start()