|
| 1 | +import logging |
| 2 | +logger = logging.getLogger('extension') |
| 3 | + |
| 4 | +import sys |
| 5 | +from roundup import __version__ as roundup_version |
| 6 | +def AboutPage(db): |
| 7 | + "report useful info about this tracker" |
| 8 | + |
| 9 | + def is_module_loaded(module): |
| 10 | + modules = sys.modules.keys() |
| 11 | + return module in modules |
| 12 | + |
| 13 | + def get_status_of_module(module, prefix=None, version=True): |
| 14 | + modules = sys.modules.keys() |
| 15 | + is_enabled = module in modules |
| 16 | + if is_enabled: |
| 17 | + if module == 'pyme': |
| 18 | + from pyme import version |
| 19 | + version="version %s"%version.versionstr |
| 20 | + elif module == 'pychart': |
| 21 | + from pychart import version |
| 22 | + version="version %s"%version.version |
| 23 | + elif module == 'sqlite3': |
| 24 | + from sqlite3 import version |
| 25 | + version="version %s"%version |
| 26 | + else: |
| 27 | + if version: |
| 28 | + m = __import__(module) |
| 29 | + try: |
| 30 | + version="version %s"%m.__version__ |
| 31 | + except AttributeError: |
| 32 | + version="version unavailable - exception thrown" |
| 33 | + else: |
| 34 | + version="version unavailable" |
| 35 | + |
| 36 | + if prefix: |
| 37 | + return "%s %s %s enabled: %s"%(prefix, module, version, is_enabled) |
| 38 | + else: |
| 39 | + return "Module: %s %s enabled: %s"%(module, version, is_enabled) |
| 40 | + else: |
| 41 | + if prefix: |
| 42 | + return "%s %s enabled: %s"%(prefix, module, is_enabled) |
| 43 | + else: |
| 44 | + return "Module: %s enabled: %s"%(module, is_enabled) |
| 45 | + |
| 46 | + info = [] |
| 47 | + |
| 48 | + info.append("Tracker name: %s<br>"%db.config['TRACKER_NAME']) |
| 49 | + |
| 50 | + info.append("<h2>Operating environment</h2>") |
| 51 | + info.append('<a href="http://roundup.sourceforge.net/">Roundup</a> version: %s<br>'%roundup_version) |
| 52 | + info.append("Python Version: %s<br>"%sys.version) |
| 53 | + |
| 54 | + info.append("<h2>Configuration</h2>") |
| 55 | + |
| 56 | + backend = db.config['RDBMS_BACKEND'] |
| 57 | + info.append("Roundup backend: %s<br>"%backend) |
| 58 | + if backend != 'anydbm': |
| 59 | + info.append("Roundup db cache: %s<br>"%db.config['RDBMS_CACHE_SIZE']) |
| 60 | + info.append("Roundup isolation_level: %s<br>"%db.config['RDBMS_ISOLATION_LEVEL']) |
| 61 | + |
| 62 | + info.append("Roundup template: %s<br>"%db.config['TEMPLATE_ENGINE']) |
| 63 | + |
| 64 | + info.append("<h2>Database modules</h2>") |
| 65 | + info.append(get_status_of_module('anydbm', version=False) + "<br>") |
| 66 | + info.append(get_status_of_module('sqlite3') + "<br>") |
| 67 | + info.append(get_status_of_module('MySQLdb') + "<br>") |
| 68 | + info.append(get_status_of_module('psycopg2') + "<br>") |
| 69 | + |
| 70 | + info.append("<h2>Other modules</h2>") |
| 71 | + |
| 72 | + info.append(get_status_of_module('pytz') + "<br>") |
| 73 | + if is_module_loaded('xapian'): |
| 74 | + info.append(get_status_of_module('xapian', prefix="Test indexer:") + |
| 75 | + "<br>") |
| 76 | + elif is_module_loaded('whoosh'): |
| 77 | + info.append(get_status_of_module('whoosh', prefix="Test indexer:") + |
| 78 | + "<br>") |
| 79 | + else: |
| 80 | + info.append("Text indexer: Native enabled: True<br>") |
| 81 | + |
| 82 | + info.append(get_status_of_module('pyme') + "<br>") |
| 83 | + info.append(get_status_of_module('OpenSSL') + "<br>") |
| 84 | + info.append(get_status_of_module('pychart') + "<br>") |
| 85 | + |
| 86 | + info.append(get_status_of_module('jinja2') + "<br>") |
| 87 | + |
| 88 | + if db._db.getuid() == "1": |
| 89 | + #may leak sensitive info about system, directory paths etc. |
| 90 | + #and keys so require admin user access. Consider expanding |
| 91 | + #to Admin rights for tracker. |
| 92 | + info.append("") |
| 93 | + info.append("Module Path: %r"%sys.path) |
| 94 | + |
| 95 | + info.append("<h2>Environment Variables</h2>") |
| 96 | + info.append("<pre>") # include pre to prevent wrapping of values |
| 97 | + for key in db._client.env.keys(): |
| 98 | + info.append("%s=%s"%(key,db._client.env[key]) + "<br>") |
| 99 | + info.append("</pre>") |
| 100 | + return "\n".join(info) |
| 101 | + |
| 102 | +def init(instance): |
| 103 | + instance.registerUtil('AboutPage', AboutPage) |
| 104 | + |
0 commit comments