Skip to content

CRITICAL (python 2.7): eGFRD doesn't function without python hack #83

@Jintram

Description

@Jintram

eGFRD uses the logger function in Python, which has been updated from python 2.6 to python 2.7.

A check has been introduced which checks if the presented loglevel is a string or not. We however present an object, which leads to the following error:


jintram@jintram-Aspire-7745G:~/jul2012_gfrd_git/samples/simple$ ./simple.py 
Traceback (most recent call last):
  File "./simple.py", line 12, in <module>
    from egfrd import *
  File "/home/jintram/jul2012_gfrd_git/egfrd.py", line 31, in <module>
    from gfrdbase import *
  File "/home/jintram/jul2012_gfrd_git/gfrdbase.py", line 71, in <module>
    setup_logging()
  File "/home/jintram/jul2012_gfrd_git/gfrdbase.py", line 60, in setup_logging
    handler = _gfrd.CppLoggerHandler(_gfrd.Logger.get_logger("ecell"))
  File "/usr/lib/python2.7/logging/__init__.py", line 668, in __init__
    self.level = _checkLevel(level)
  File "/usr/lib/python2.7/logging/__init__.py", line 194, in _checkLevel
    raise TypeError("Level not an integer or a valid string: %r" % level)
TypeError: Level not an integer or a valid string: <_gfrd.Logger object at 0x996510c>

Only if we remove this check from the python code (!) eGFRD currently functions:

$ sudo vim /usr/lib/python2.7/logging/__init__.py
 182 def _checkLevel(level):
 183 
 184     # ugly hack :)
 185     return level
 186 
 187     if isinstance(level, int):
 188         rv = level
 189     elif str(level) == level:
 190         if level not in _levelNames:
 191             raise ValueError("Unknown level: %r" % level)
 192         rv = _levelNames[level]
 193     else:
 194         raise TypeError("Level not an integer or a valid string: %r" % level)
 195     return rv

We should thus use a string instead of an object to pass on loglevel information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions