Some more python2.3 support changes

This commit is contained in:
dim 2008-09-18 12:58:12 +00:00
parent 2bacf1a854
commit 848595f49b
3 changed files with 13 additions and 3 deletions

2
debian/changelog vendored
View File

@ -4,6 +4,8 @@ pgloader (2.3.2-1) unstable; urgency=low
* FIX fixedreader: it now know about -C
* FIX Round Robin Reader with respect to offsets in readlines()
* allow python 2.3 to run pgloader when it does not need collections.deque (no Round Robin Reader)
* change logger initialisation to support python 2.3
* FIX bad usage of STDERR in the code
-- Dimitri Fontaine <dim@tapoueh.org> Wed, 17 Sep 2008 17:53:53 +0200

View File

@ -607,15 +607,15 @@ if __name__ == "__main__":
try:
ret = load_data()
except Exception, e:
print >>STDERR, e
sys.stderr.write(str(e) + '\n')
sys.exit(1)
except IOError, e:
print >>STDERR, e
sys.stderr.write(str(e) + '\n')
sys.exit(1)
except KeyboardInterrupt, e:
print >>STDERR, e
sys.stderr.write(str(e) + '\n')
sys.exit(1)
sys.exit(ret)

View File

@ -20,6 +20,14 @@ def init(client_min_messages = logging.INFO,
datefmt = '%d-%m-%Y %H:%M:%S',
filename = filename,
filemode = 'w')
except TypeError:
# very old python (2.3 or such) didn't have kwargs in basicConfig
logfile = logging.FileHandler(filename, filemode)
logfile.setLevel(log_min_messages)
logfile_fmt = logging.Formatter(fmt, datefmt)
logfile.setFormatter(logfile_fmt)
logging.getLogger('').addHandler(logfile)
except IOError, e:
raise PGLoader_Error, e