0005785: print statements in Check.py causing a crash in Windows (pythonw.exe) after outputting 4096 characters. Change warning print statements to logging.

svn: r20011
This commit is contained in:
Tim G L Lyons 2012-07-16 17:57:01 +00:00
parent bfc8d16620
commit 679178d3bb
6 changed files with 22 additions and 18 deletions

View File

@ -35,6 +35,7 @@ This package implements access to GRAMPS configuration.
#--------------------------------------------------------------- #---------------------------------------------------------------
import os, sys import os, sys
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
import logging
#--------------------------------------------------------------- #---------------------------------------------------------------
# #
@ -331,10 +332,10 @@ if not os.path.exists(CONFIGMAN.filename):
# If not, let's read old if there: # If not, let's read old if there:
if os.path.exists(os.path.join(HOME_DIR, "keys.ini")): if os.path.exists(os.path.join(HOME_DIR, "keys.ini")):
# read it in old style: # read it in old style:
print >> sys.stderr, "Importing old key file 'keys.ini'..." logging.warning("Importing old key file 'keys.ini'...")
CONFIGMAN.load(os.path.join(HOME_DIR, "keys.ini"), CONFIGMAN.load(os.path.join(HOME_DIR, "keys.ini"),
oldstyle=True) oldstyle=True)
print >> sys.stderr, "Done importing old key file 'keys.ini'" logging.warning("Done importing old key file 'keys.ini'")
# other version upgrades here... # other version upgrades here...
#--------------------------------------------------------------- #---------------------------------------------------------------

View File

@ -986,7 +986,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
# to loop through each of the primary object tables. # to loop through each of the primary object tables.
for cursor_func, class_func in primary_table: for cursor_func, class_func in primary_table:
print "Rebuilding %s reference map" % class_func.__name__ logging.info("Rebuilding %s reference map" %
class_func.__name__)
with cursor_func() as cursor: with cursor_func() as cursor:
for found_handle, val in cursor: for found_handle, val in cursor:
obj = class_func() obj = class_func()

View File

@ -37,6 +37,7 @@ import time
import ConfigParser import ConfigParser
import errno import errno
import copy import copy
import logging
def safe_eval(exp): def safe_eval(exp):
# restrict eval to empty environment # restrict eval to empty environment
@ -274,13 +275,13 @@ class ConfigManager(object):
if vtype == bool: if vtype == bool:
value = raw_value in ["1", "True"] value = raw_value in ["1", "True"]
elif vtype == list: elif vtype == list:
print >> sys.stderr, "WARNING: ignoring old key '%s'" % key logging.warning("WARNING: ignoring old key '%s'" % key)
continue # there were no lists in oldstyle continue # there were no lists in oldstyle
else: else:
value = vtype(raw_value) value = vtype(raw_value)
else: else:
# else, ignore it # else, ignore it
print >> sys.stderr, "WARNING: ignoring old key '%s'" % key logging.warning("WARNING: ignoring old key '%s'" % key)
continue # with next setting continue # with next setting
####################### End upgrade code ####################### End upgrade code
else: else:
@ -294,7 +295,7 @@ class ConfigManager(object):
elif type(value) == type(self.default[name][setting]): elif type(value) == type(self.default[name][setting]):
self.data[name][setting] = value self.data[name][setting] = value
else: else:
print >> sys.stderr, ("WARNING: ignoring key with wrong type " logging.warning("WARNING: ignoring key with wrong type "
"'%s.%s'" % (name, setting)) "'%s.%s'" % (name, setting))
else: else:
# this could be a third-party setting; add it: # this could be a third-party setting; add it:

View File

@ -105,9 +105,9 @@ def image_dpi(source):
try: try:
import PIL.Image import PIL.Image
except ImportError: except ImportError:
import sys import logging
print >> sys.stderr, _("WARNING: PIL module not loaded. " logging.warning(_("WARNING: PIL module not loaded. "
"Image cropping in report files will not be available.") "Image cropping in report files will not be available."))
dpi = None dpi = None
else: else:

View File

@ -393,9 +393,9 @@ try:
import pyexiv2 import pyexiv2
available = True available = True
except: except:
import sys import logging
print >> sys.stderr, _("WARNING: pyexiv2 module not loaded. " logging.warning(_("WARNING: pyexiv2 module not loaded. "
"Image metadata functionality will not be available.") "Image metadata functionality will not be available."))
available = False available = False
if available: if available:

View File

@ -37,14 +37,15 @@ try :
OSMGPSMAP = True OSMGPSMAP = True
if osmgpsmap.__version__ < '0.7.0': if osmgpsmap.__version__ < '0.7.0':
OSMGPSMAP = False OSMGPSMAP = False
import sys import logging
print >> sys.stderr, _("WARNING: osmgpsmap module not loaded. " logging.warning( _("WARNING: osmgpsmap module not loaded. "
"osmgpsmap must be >= 0.7.0. yours is %s") % osmgpsmap.__version__ "osmgpsmap must be >= 0.7.0. yours is %s") %
osmgpsmap.__version__)
except: except:
OSMGPSMAP = False OSMGPSMAP = False
import sys import logging
print >> sys.stderr, _("WARNING: osmgpsmap module not loaded. " logging.warning(_("WARNING: osmgpsmap module not loaded. "
"Geography functionality will not be available.") "Geography functionality will not be available."))
if OSMGPSMAP: if OSMGPSMAP:
# Load the view only if osmgpsmap library is present. # Load the view only if osmgpsmap library is present.