forward.py: indentation bullshit
This commit is contained in:
parent
83283fc2cb
commit
5d477cc1ac
1 changed files with 31 additions and 37 deletions
|
@ -29,46 +29,43 @@ import lc_ldap.shortcuts
|
||||||
import lc_ldap.printing
|
import lc_ldap.printing
|
||||||
import lc_ldap.filter2 as filter
|
import lc_ldap.filter2 as filter
|
||||||
|
|
||||||
|
def redirection_read(uid):
|
||||||
if __name__ == '__main__':
|
""" Lecture de la redirection courante"""
|
||||||
# Lecture de la redirection courante
|
|
||||||
def redirection_read(uid):
|
|
||||||
forward = open(os.path.expanduser('~%s/.forward' %uid) ,'r')
|
forward = open(os.path.expanduser('~%s/.forward' %uid) ,'r')
|
||||||
print forward.read()
|
print forward.read()
|
||||||
forward.close()
|
forward.close()
|
||||||
return
|
|
||||||
# Modification de la redirection
|
def redirection_write(ligne,uid):
|
||||||
def redirection_write(ligne,uid):
|
""" Modification de la redirection"""
|
||||||
forward = open(os.path.expanduser('~%s/.forward' %uid),'w')
|
forward = open(os.path.expanduser('~%s/.forward' %uid),'w')
|
||||||
forward.write('%s' %ligne)
|
forward.write('%s' %ligne)
|
||||||
forward.close()
|
forward.close()
|
||||||
return
|
|
||||||
|
|
||||||
# On reprends whos_lc() de Valentin
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
# On reprends whos_lc() de Valentin
|
||||||
if len(sys.argv) >1:
|
if len(sys.argv) >1:
|
||||||
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
conn=lc_ldap.shortcuts.lc_ldap_admin()
|
||||||
result=conn.search(filter.human_to_ldap(sys.argv[1]), sizelimit=4000)
|
result=conn.search(filter.human_to_ldap(sys.argv[1]), sizelimit=4000)
|
||||||
if not result:
|
if not result:
|
||||||
print "Aucun résultat !"
|
print "Aucun résultat !"
|
||||||
exit()
|
exit()
|
||||||
else:
|
elif len(result) > 1:
|
||||||
if len(result) == 1:
|
|
||||||
if len(result[0].get(u'droits',None))==0:
|
|
||||||
result[0].display()
|
|
||||||
uid=result[0].get(u'uid',None)[0].value
|
|
||||||
if len(result[0].get(u'droits',None))!=0:
|
|
||||||
print 'Membre actif !'
|
|
||||||
exit()
|
|
||||||
else:
|
|
||||||
print lc_ldap.printing.sprint_list(result)
|
print lc_ldap.printing.sprint_list(result)
|
||||||
print "%s résultats" % len(result)
|
print "%s résultats" % len(result)
|
||||||
exit()
|
exit()
|
||||||
|
elif result[0].get(u'droits',None):
|
||||||
|
print 'Membre actif !'
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
|
result[0].display()
|
||||||
|
uid=result[0].get(u'uid',None)[0].value
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("Utiliser les filtres ldap: uid=, chbre= etc..")
|
sys.stderr.write("Utiliser les filtres ldap: uid=, chbre= etc..")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
r = affich_tools.prompt(u'Confirmer sélection ? [O/N]')
|
r = affich_tools.prompt(u'Confirmer sélection ? [O/N]')
|
||||||
if r == 'O' or r == 'o':
|
if r == 'O' or r == 'o':
|
||||||
print "Redirection actuelle:"
|
print "Redirection actuelle:"
|
||||||
redirection_read(uid)
|
redirection_read(uid)
|
||||||
y = affich_tools.prompt(u'Modifier cette redirection ? [O/N]')
|
y = affich_tools.prompt(u'Modifier cette redirection ? [O/N]')
|
||||||
|
@ -78,9 +75,6 @@ if r == 'O' or r == 'o':
|
||||||
print 'Redirection effectuée !'
|
print 'Redirection effectuée !'
|
||||||
elif y == 'N' or y == 'n':
|
elif y == 'N' or y == 'n':
|
||||||
exit()
|
exit()
|
||||||
elif r == 'N' or r == 'n':
|
elif r == 'N' or r == 'n':
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue