Commit 20a6ee6a authored by Daniel STAN's avatar Daniel STAN

homes: plus de généricité & /home-adh/x/xlogin

parent de45237b
......@@ -32,13 +32,13 @@ import lc_ldap.filter2 as filter
if __name__ == '__main__':
# Lecture de la redirection courante
def redirection_read(uid):
forward = open('/home/%s/.forward' %uid ,'r')
forward = open(os.path.expanduser('~%s/.forward' %uid) ,'r')
print forward.read()
forward.close()
return
# Modification de la redirection
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.close()
return
......
......@@ -2538,8 +2538,7 @@ class Adherent(BaseProprietaire):
if mailexist(login):
raise ValueError(u"Login existant ou correspondant à un alias mail.", 1)
# <!> b2moo: à fixer pour les homes
home = '/home/' + login
home = '/home/%s/%s' % (login[0], login)
if os.path.exists(home):
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
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):
raise ValueError(u'Création du compte impossible : home existant', 1)
......
......@@ -488,7 +488,7 @@ def adher_details(adher) :
if len(adher.gpgFingerprint()) > 0:
f += u"\n".join([coul(u'Fingerprint GPG : ', 'gras') + u"%s" % (i) for i in adher.gpgFingerprint()])+"\n"
try:
forward = file("/home/%s/.forward" % adher.compte()).readlines()
forward = file(os.path.join(adher.home(), ".forward")).readlines()
if len(forward) > 1:
forward = forward[0].strip() + u" ...\n"
elif len(forward) == 1:
......
......@@ -11,9 +11,10 @@ robots_file = '/usr/scripts/var/perso/robots.txt'
robots = collections.defaultdict(lambda:collections.defaultdict(list))
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.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 user_agent in entry.useragents:
for rule in entry.rulelines:
......@@ -31,7 +32,7 @@ def write_robots(file, robots):
f.write("\n")
def get_users():
return os.listdir('/home/')
return os.listdir('/home/mail')
if __name__ == '__main__':
......
......@@ -10,8 +10,8 @@ class ClubList(PagesPerso.AccountList):
def comptes(self):
"""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),
os.listdir(u"/home/club"))
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/c/club"))
def execute(macro, args):
return macro.formatter.rawHTML(ClubList().to_html())
......
......@@ -12,8 +12,9 @@ class AccountList:
def comptes(self):
"""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"))
### ^^^^^^ le code m'a tuer
def makeAnchor(self,letter):
......@@ -50,7 +51,7 @@ class Account:
def __init__(self, home, login, www, url):
"""Instanciation avec le `login' de la personne"""
self.login = login
self.home = "%s/%s" % (home, login)
self.home = os.path.expanduser("~%s" % login)
self.www = www
self.url = url
......@@ -78,7 +79,7 @@ class Account:
def chemin(self):
"""Chemin vers le www"""
return u"%s%s" % (self.home, self.www)
return os.path.join(self.home, self.www)
def logo(self):
"""URL du logo s'il y en a un"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment