Python2 backward compatibility
This commit is contained in:
parent
f44fae9771
commit
736ea10a1f
18
blogthon.cgi
18
blogthon.cgi
@ -18,7 +18,13 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
import re
|
import re
|
||||||
import configparser
|
|
||||||
|
# Backward compatibilty to python2
|
||||||
|
try:
|
||||||
|
import configparser
|
||||||
|
except:
|
||||||
|
import ConfigParser
|
||||||
|
|
||||||
from cgi import FieldStorage
|
from cgi import FieldStorage
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
@ -69,8 +75,11 @@ def document_header(string):
|
|||||||
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
||||||
print("<rss version=\"2.0\">")
|
print("<rss version=\"2.0\">")
|
||||||
|
|
||||||
# Parse configuration
|
# Parse configuration (with backward compatibilty)
|
||||||
configuration = configparser.SafeConfigParser()
|
try:
|
||||||
|
configuration = configparser.SafeConfigParser()
|
||||||
|
except:
|
||||||
|
configuration = ConfigParser.SafeConfigParser()
|
||||||
|
|
||||||
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
||||||
if os.path.exists(config):
|
if os.path.exists(config):
|
||||||
@ -107,6 +116,9 @@ try:
|
|||||||
feed_preview = configuration.get("feed", "feed_preview")
|
feed_preview = configuration.get("feed", "feed_preview")
|
||||||
except configparser.Error as error:
|
except configparser.Error as error:
|
||||||
errorpage(str(error))
|
errorpage(str(error))
|
||||||
|
# And for backward compatibility
|
||||||
|
except ConfigParser.Error as error:
|
||||||
|
errorpage(str(error))
|
||||||
|
|
||||||
if not re.match("^http:\/\/.*$", blog_url):
|
if not re.match("^http:\/\/.*$", blog_url):
|
||||||
blog_url = "http://" + blog_url
|
blog_url = "http://" + blog_url
|
||||||
|
Loading…
Reference in New Issue
Block a user