Adaptation au nouveau wiki et amliorations...
darcs-hash:20070605074355-68412-17c9c8fbb6903bd9364cf4f8ae7e781c2052d9f2.gz
This commit is contained in:
parent
7420dc1761
commit
c9bc130439
1 changed files with 17 additions and 7 deletions
|
@ -14,32 +14,37 @@ from email.MIMEMultipart import MIMEMultipart
|
||||||
from email.Encoders import encode_7or8bit
|
from email.Encoders import encode_7or8bit
|
||||||
|
|
||||||
sys.path.append("/usr/scripts/gestion")
|
sys.path.append("/usr/scripts/gestion")
|
||||||
from affich_tools import coul, prompt
|
from affich_tools import coul, prompt, cprint
|
||||||
|
from user_tests import getuser
|
||||||
|
|
||||||
bugmail = ["glondu@crans.org"]
|
bugmail = ["glondu@crans.org"]
|
||||||
bugreport = u"""
|
bugreport = u"""
|
||||||
Nom d'utilisateur : %(username)s
|
Nom d'utilisateur : %(name)s
|
||||||
Adresse e-mail : %(email)s
|
Adresse e-mail : %(email)s
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# C'est l'encodage du wiki et des bugreports
|
# C'est l'encodage du wiki et des bugreports
|
||||||
encoding = "utf-8"
|
encoding = "utf-8"
|
||||||
|
|
||||||
|
# Utilisateur qui lance le script
|
||||||
|
user = getuser()
|
||||||
|
|
||||||
def send(msg):
|
def send(msg):
|
||||||
msg['From'] = 'root@crans.org'
|
msg['From'] = '%s@crans.org' % user
|
||||||
msg['To'] = ','.join(bugmail)
|
msg['To'] = ','.join(bugmail)
|
||||||
|
msg['User-Agent'] = 'creer_compte_wiki.py'
|
||||||
smtp = SMTP()
|
smtp = SMTP()
|
||||||
smtp.connect()
|
smtp.connect()
|
||||||
smtp.sendmail('glondu@crans.org', bugmail, msg.as_string())
|
smtp.sendmail('%s@crans.org' % user, bugmail, msg.as_string())
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
def creer_compte(nom, mdp, email):
|
def creer_compte(nom, mdp, email):
|
||||||
form = {'action': 'userform',
|
form = {'action': 'userform',
|
||||||
'username': nom.encode(encoding),
|
'name': nom.encode(encoding),
|
||||||
'password': mdp,
|
'password': mdp,
|
||||||
'password2': mdp,
|
'password2': mdp,
|
||||||
'email': email.encode(encoding),
|
'email': email.encode(encoding),
|
||||||
'save': 'Create Profile'}
|
'create': 'Create Profile'}
|
||||||
params = urllib.urlencode(form)
|
params = urllib.urlencode(form)
|
||||||
headers = {"Content-type": "application/x-www-form-urlencoded",
|
headers = {"Content-type": "application/x-www-form-urlencoded",
|
||||||
"Accept": "text/plain"}
|
"Accept": "text/plain"}
|
||||||
|
@ -48,7 +53,10 @@ def creer_compte(nom, mdp, email):
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
data = response.read()
|
data = response.read()
|
||||||
conn.close()
|
conn.close()
|
||||||
if 'User preferences saved!' in data:
|
if 'User account created!' in data:
|
||||||
|
msg = MIMEText(bugreport.encode(encoding) % form, 'plain', encoding)
|
||||||
|
msg['Subject'] = "creer_compte_wiki.py: success"
|
||||||
|
send(msg)
|
||||||
return coul(u"Compte %s créé avec succès !" % nom, "vert")
|
return coul(u"Compte %s créé avec succès !" % nom, "vert")
|
||||||
elif 'This user name already belongs to somebody else.' in data:
|
elif 'This user name already belongs to somebody else.' in data:
|
||||||
return coul(u"Le compte %s existe déjà !" % nom, "rouge")
|
return coul(u"Le compte %s existe déjà !" % nom, "rouge")
|
||||||
|
@ -85,6 +93,8 @@ if __name__ == '__main__':
|
||||||
mdp = getpass(coul("Mot de passe (ne pas utiliser le même que pour zamok) : ", "gras"))
|
mdp = getpass(coul("Mot de passe (ne pas utiliser le même que pour zamok) : ", "gras"))
|
||||||
if getpass(coul("Confirmation du mot de passe :", "gras")) == mdp:
|
if getpass(coul("Confirmation du mot de passe :", "gras")) == mdp:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
cprint(u"Les deux mots de passe sont différents, veuillez réessayer...", "rouge")
|
||||||
email = prompt("Adresse e-mail : ")
|
email = prompt("Adresse e-mail : ")
|
||||||
print creer_compte(nom, mdp, email)
|
print creer_compte(nom, mdp, email)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue