From 0d757b0522de7b53a26a6826cf4651ef43b8ef14 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Fri, 24 Jul 2009 16:21:56 +0200 Subject: [PATCH 1/2] Added exception for not writable commentsfile --- blogthon.cgi | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/blogthon.cgi b/blogthon.cgi index 89594c2..277d335 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -189,21 +189,24 @@ if cname and ctext and ctitle: except: errorpage('not writable entries_dir') comments_file = glob.glob(entries_dir + ctitle + '.comments') - content = open(comments_file[0], "a+") - content.write("-." + cname + "\n") - content.write("+." + time.asctime() + "\n") - ctext = ctext.split("\n") - for line in ctext: - content.write("." + line + "\n") - content.close() - # Send mail? - if new_comment_mail: - msg = 'From: Blogthon\nSubject: New comment on ' + blog_title + '\n\nSomeone wrote a comment to this entry: ' + blog_url + '?p=' + re.sub(' ', '-', ctitle) - smtp = smtplib.SMTP(smtp_host) - if smtp_user != '' and smtp_pass != '': - smtp.login(smtp_user, smtp_pass) - smtp.sendmail(blog_title, mail_to, msg) - smtp.quit() + try: + content = open(comments_file[0], "a+") + content.write("-." + cname + "\n") + content.write("+." + time.asctime() + "\n") + ctext = ctext.split("\n") + for line in ctext: + content.write("." + line + "\n") + content.close() + # Send mail? + if new_comment_mail: + msg = 'From: Blogthon\nSubject: New comment on ' + blog_title + '\n\nSomeone wrote a comment to this entry: ' + blog_url + '?p=' + re.sub(' ', '-', ctitle) + smtp = smtplib.SMTP(smtp_host) + if smtp_user != '' and smtp_pass != '': + smtp.login(smtp_user, smtp_pass) + smtp.sendmail(blog_title, mail_to, msg) + smtp.quit() + except: + errorpage('commentsfile seems not to be writable!) # Read entries and store their title and timestamp entries = [] From f24d0587a587dfd8c93aafa7678d2cfb7116e2f8 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Fri, 24 Jul 2009 16:23:07 +0200 Subject: [PATCH 2/2] Added missing ' --- blogthon.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blogthon.cgi b/blogthon.cgi index 277d335..f262ca6 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -206,7 +206,7 @@ if cname and ctext and ctitle: smtp.sendmail(blog_title, mail_to, msg) smtp.quit() except: - errorpage('commentsfile seems not to be writable!) + errorpage('commentsfile seems not to be writable!') # Read entries and store their title and timestamp entries = []