Add email on upload to lookaside cache
Also cleaned up small whitespace issues
This commit is contained in:
parent
8092476297
commit
bf991365a5
1 changed files with 18 additions and 2 deletions
|
@ -11,6 +11,8 @@ import sys
|
|||
import cgi
|
||||
import tempfile
|
||||
import grp
|
||||
import smtplib
|
||||
from email.mine.text import MIMEText
|
||||
try:
|
||||
import hashlib
|
||||
md5_constructor = hashlib.md5
|
||||
|
@ -51,6 +53,19 @@ def check_auth(username):
|
|||
pass
|
||||
return authenticated
|
||||
|
||||
def send_email(name, md5, filename):
|
||||
text='File %s has been uploaded to the lookaside cache with md5sum %s' % \
|
||||
(filename, md5)
|
||||
msg = MIMEText(text)
|
||||
sender = 'nobody@fedoraproject.org'
|
||||
recepients = [ '%s-owner@fedoraproject.org' % name, \
|
||||
'fedora-extras-commits@redhat.com' ]
|
||||
msg['Subject'] = 'File %s uploaded to lookaside cache' % filename
|
||||
msg['From'] = sender
|
||||
msg['To'] = recepients
|
||||
s = smtplib.SMTP(host='bastion.fedoraproject.org')
|
||||
s.sendmail(sender, recepients, msg.as_string())
|
||||
|
||||
def main():
|
||||
os.umask(002)
|
||||
|
||||
|
@ -152,6 +167,7 @@ def main():
|
|||
os.rename(tmpfile, dest_file)
|
||||
print >> sys.stderr, '[username=%s] Stored %s (%d bytes)' % (username, dest_file, filesize)
|
||||
print 'File %s size %d MD5 %s stored OK' % (filename, filesize, md5sum)
|
||||
send_email(name, md5sum, filename)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue