Commit ea563dc9 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

greet_newcomers: use a local shelf, as homes are not available by cron

parent 3d5a046a
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
import shelve import shelve
from email.mime.text import MIMEText from email.mime.text import MIMEText
from getpass import getuser from getpass import getuser
from os.path import abspath, dirname, expanduser, join
from smtplib import SMTP from smtplib import SMTP
from pathlib import Path
from ldap3 import Connection from ldap3 import Connection
SHELF = expanduser('~/.cache/gepetto_newcomers') HERE = Path(__file__).resolve().parent
SHELF = HERE / '.cache'
def get_gepetto(): def get_gepetto():
...@@ -49,7 +50,7 @@ def greet(to, sender): ...@@ -49,7 +50,7 @@ def greet(to, sender):
if '@' not in to: if '@' not in to:
to = '%s@laas.fr' % to to = '%s@laas.fr' % to
with open(join(dirname(abspath(__file__)), 'template.txt')) as f: with (HERE / 'template.txt').open() as f:
msg = MIMEText(f.read()) msg = MIMEText(f.read())
msg['Subject'] = 'Welcome in Gepetto !' msg['Subject'] = 'Welcome in Gepetto !'
......
Supports Markdown
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