aboutsummaryrefslogtreecommitdiffstats
path: root/blogthon.cgi
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2011-03-23 22:53:59 +0100
committerStefan Ritter <xeno@thehappy.de>2011-03-23 22:53:59 +0100
commit736ea10a1f3a4934d59c23fa908f627831d5d347 (patch)
treeeb3b2363b671675e49778fcf8dd36b74829f874e /blogthon.cgi
parentf44fae97710483f71bb1cbdcbe5bb41656660486 (diff)
Python2 backward compatibility1.0rc4
Diffstat (limited to 'blogthon.cgi')
-rwxr-xr-xblogthon.cgi18
1 files changed, 15 insertions, 3 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index d176c6c..1c7c8db 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -18,7 +18,13 @@ import sys
import time
import locale
import re
-import configparser
+
+# Backward compatibilty to python2
+try:
+ import configparser
+except:
+ import ConfigParser
+
from cgi import FieldStorage
from smtplib import SMTP
from hashlib import md5
@@ -69,8 +75,11 @@ def document_header(string):
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
print("<rss version=\"2.0\">")
-# Parse configuration
-configuration = configparser.SafeConfigParser()
+# Parse configuration (with backward compatibilty)
+try:
+ configuration = configparser.SafeConfigParser()
+except:
+ configuration = ConfigParser.SafeConfigParser()
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
if os.path.exists(config):
@@ -107,6 +116,9 @@ try:
feed_preview = configuration.get("feed", "feed_preview")
except configparser.Error as error:
errorpage(str(error))
+# And for backward compatibility
+except ConfigParser.Error as error:
+ errorpage(str(error))
if not re.match("^http:\/\/.*$", blog_url):
blog_url = "http://" + blog_url