homes: plus de généricité & /home-adh/x/xlogin
This commit is contained in:
parent
de45237b50
commit
20a6ee6afb
6 changed files with 15 additions and 14 deletions
|
@ -32,13 +32,13 @@ import lc_ldap.filter2 as filter
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Lecture de la redirection courante
|
# Lecture de la redirection courante
|
||||||
def redirection_read(uid):
|
def redirection_read(uid):
|
||||||
forward = open('/home/%s/.forward' %uid ,'r')
|
forward = open(os.path.expanduser('~%s/.forward' %uid) ,'r')
|
||||||
print forward.read()
|
print forward.read()
|
||||||
forward.close()
|
forward.close()
|
||||||
return
|
return
|
||||||
# Modification de la redirection
|
# Modification de la redirection
|
||||||
def redirection_write(ligne,uid):
|
def redirection_write(ligne,uid):
|
||||||
forward = open('/home/%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
|
return
|
||||||
|
|
|
@ -2538,8 +2538,7 @@ class Adherent(BaseProprietaire):
|
||||||
if mailexist(login):
|
if mailexist(login):
|
||||||
raise ValueError(u"Login existant ou correspondant à un alias mail.", 1)
|
raise ValueError(u"Login existant ou correspondant à un alias mail.", 1)
|
||||||
|
|
||||||
# <!> b2moo: à fixer pour les homes
|
home = '/home/%s/%s' % (login[0], login)
|
||||||
home = '/home/' + login
|
|
||||||
if os.path.exists(home):
|
if os.path.exists(home):
|
||||||
raise ValueError(u'Création du compte impossible : home existant', 1)
|
raise ValueError(u'Création du compte impossible : home existant', 1)
|
||||||
|
|
||||||
|
@ -2877,7 +2876,7 @@ class Club(BaseProprietaire):
|
||||||
# la 2ème vérif est pour vérifier que ce n'est pas la ML du club
|
# la 2ème vérif est pour vérifier que ce n'est pas la ML du club
|
||||||
raise ValueError(u"Login existant ou correspondant à un alias mail.", 1)
|
raise ValueError(u"Login existant ou correspondant à un alias mail.", 1)
|
||||||
|
|
||||||
home = '/home/' + login.replace('-', '/', 1)
|
home = '/home/%s/%s' % (login[0], login.replace('-', '/', 1))
|
||||||
if os.path.exists(home):
|
if os.path.exists(home):
|
||||||
raise ValueError(u'Création du compte impossible : home existant', 1)
|
raise ValueError(u'Création du compte impossible : home existant', 1)
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,7 @@ def adher_details(adher) :
|
||||||
if len(adher.gpgFingerprint()) > 0:
|
if len(adher.gpgFingerprint()) > 0:
|
||||||
f += u"\n".join([coul(u'Fingerprint GPG : ', 'gras') + u"%s" % (i) for i in adher.gpgFingerprint()])+"\n"
|
f += u"\n".join([coul(u'Fingerprint GPG : ', 'gras') + u"%s" % (i) for i in adher.gpgFingerprint()])+"\n"
|
||||||
try:
|
try:
|
||||||
forward = file("/home/%s/.forward" % adher.compte()).readlines()
|
forward = file(os.path.join(adher.home(), ".forward")).readlines()
|
||||||
if len(forward) > 1:
|
if len(forward) > 1:
|
||||||
forward = forward[0].strip() + u" ...\n"
|
forward = forward[0].strip() + u" ...\n"
|
||||||
elif len(forward) == 1:
|
elif len(forward) == 1:
|
||||||
|
|
|
@ -11,9 +11,10 @@ robots_file = '/usr/scripts/var/perso/robots.txt'
|
||||||
|
|
||||||
robots = collections.defaultdict(lambda:collections.defaultdict(list))
|
robots = collections.defaultdict(lambda:collections.defaultdict(list))
|
||||||
def add_robots(user, robots):
|
def add_robots(user, robots):
|
||||||
if os.path.exists('/home/%s/www/robots.txt' % user):
|
robots_path = os.expanduser('~%s/www/robots.txt' % user)
|
||||||
|
if os.path.exists(robots_path):
|
||||||
rp = robotparser.RobotFileParser()
|
rp = robotparser.RobotFileParser()
|
||||||
rp.parse(open('/home/%s/www/robots.txt' % user))
|
rp.parse(open(robots_path))
|
||||||
for entry in ([rp.default_entry] if rp.default_entry else []) + rp.entries:
|
for entry in ([rp.default_entry] if rp.default_entry else []) + rp.entries:
|
||||||
for user_agent in entry.useragents:
|
for user_agent in entry.useragents:
|
||||||
for rule in entry.rulelines:
|
for rule in entry.rulelines:
|
||||||
|
@ -31,7 +32,7 @@ def write_robots(file, robots):
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
def get_users():
|
def get_users():
|
||||||
return os.listdir('/home/')
|
return os.listdir('/home/mail')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -10,8 +10,8 @@ class ClubList(PagesPerso.AccountList):
|
||||||
|
|
||||||
def comptes(self):
|
def comptes(self):
|
||||||
"""Retourne la liste des comptes"""
|
"""Retourne la liste des comptes"""
|
||||||
return filter(lambda x: os.path.isdir(u"/home/club/%s" % x) and not os.path.islink(u"/home/club/%s" % x),
|
return filter(lambda x: os.path.isdir(u"/home/c/club/%s" % x) and not os.path.islink(u"/home/c/club/%s" % x),
|
||||||
os.listdir(u"/home/club"))
|
os.listdir(u"/home/c/club"))
|
||||||
|
|
||||||
def execute(macro, args):
|
def execute(macro, args):
|
||||||
return macro.formatter.rawHTML(ClubList().to_html())
|
return macro.formatter.rawHTML(ClubList().to_html())
|
||||||
|
|
|
@ -12,8 +12,9 @@ class AccountList:
|
||||||
|
|
||||||
def comptes(self):
|
def comptes(self):
|
||||||
"""Retourne la liste des comptes"""
|
"""Retourne la liste des comptes"""
|
||||||
return filter(lambda x: os.path.isdir(u"/home/%s/www" % x) and not os.path.islink(u"/home/%s/www" % x),
|
return filter(lambda x: os.path.isdir(os.path.expanduser(u"~%s/www" % x)) and not os.path.islink(os.path.expanduser(u"~%s/www" % x)),
|
||||||
os.listdir(u"/home/mail"))
|
os.listdir(u"/home/mail"))
|
||||||
|
### ^^^^^^ le code m'a tuer
|
||||||
|
|
||||||
|
|
||||||
def makeAnchor(self,letter):
|
def makeAnchor(self,letter):
|
||||||
|
@ -50,7 +51,7 @@ class Account:
|
||||||
def __init__(self, home, login, www, url):
|
def __init__(self, home, login, www, url):
|
||||||
"""Instanciation avec le `login' de la personne"""
|
"""Instanciation avec le `login' de la personne"""
|
||||||
self.login = login
|
self.login = login
|
||||||
self.home = "%s/%s" % (home, login)
|
self.home = os.path.expanduser("~%s" % login)
|
||||||
self.www = www
|
self.www = www
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ class Account:
|
||||||
|
|
||||||
def chemin(self):
|
def chemin(self):
|
||||||
"""Chemin vers le www"""
|
"""Chemin vers le www"""
|
||||||
return u"%s%s" % (self.home, self.www)
|
return os.path.join(self.home, self.www)
|
||||||
|
|
||||||
def logo(self):
|
def logo(self):
|
||||||
"""URL du logo s'il y en a un"""
|
"""URL du logo s'il y en a un"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue