Correction mel de contact
This commit is contained in:
parent
8fd1c0e272
commit
4fed7be766
1 changed files with 6 additions and 9 deletions
15
daemon.py
15
daemon.py
|
@ -34,20 +34,17 @@ def checkPaper():
|
||||||
|
|
||||||
def sendMel(msgfile, etat):
|
def sendMel(msgfile, etat):
|
||||||
fp = open(msgfile, 'rb')
|
fp = open(msgfile, 'rb')
|
||||||
# Create a text/plain message
|
|
||||||
msg = MIMEText(fp.read())
|
msg = MIMEText(fp.read())
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
# me == the sender's email address
|
me = 'oison@crans.org'
|
||||||
# you == the recipient's email address
|
dest = 'respbats@crans.org'
|
||||||
msg['Subject'] = '''Etat de l'imprimante thermique : %s''' % etat
|
msg['Subject'] = '''Etat de l'imprimante thermique : %s''' % etat
|
||||||
msg['From'] = 'oison@crans.org'
|
msg['From'] = me
|
||||||
msg['To'] = 'arrighi@crans.org'
|
msg['To'] = dest
|
||||||
|
|
||||||
# Send the message via our own SMTP server, but don't include the
|
|
||||||
# envelope header.
|
|
||||||
s = smtplib.SMTP('smtp.crans.org', 25)
|
s = smtplib.SMTP('smtp.crans.org', 25)
|
||||||
s.sendmail('oison@crans.org', ['arrighi@crans.org'], msg.as_string())
|
s.sendmail(me, [dest], msg.as_string())
|
||||||
s.quit()
|
s.quit()
|
||||||
|
|
||||||
def checkPrinter(dejaVu, messageCourant, messagePapier):
|
def checkPrinter(dejaVu, messageCourant, messagePapier):
|
||||||
|
@ -111,7 +108,7 @@ if __name__ == "__main__":
|
||||||
print("fork #2 failed: %d (%s)" % (e.errno, e.strerror),file=sys.stderr)
|
print("fork #2 failed: %d (%s)" % (e.errno, e.strerror),file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# start the daemon thread
|
# start the daemon thread to monitor the printer
|
||||||
thHasPaper = threading.Thread(target = checkPaper, name = 'checkPaper')
|
thHasPaper = threading.Thread(target = checkPaper, name = 'checkPaper')
|
||||||
thHasPaper.start()
|
thHasPaper.start()
|
||||||
#main loop
|
#main loop
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue