1. Benoît Allard
  2. msgboard

Commits

Benoit Allard  committed 5407c00

Also give information about wich version of MsgBard is running

  • Participants
  • Parent commits fd7a66d
  • Branches default
  • Tags 1.0

Comments (0)

Files changed (2)

File msgboard/controller.py

View file
  • Ignore whitespace
+import os
+from subprocess import Popen, PIPE
+
 try:
     from docutils.core import publish_parts as publish
     from docutils.utils import SystemMessage
         return message
     else:
         return str(flash)
-        
+
+self_version = None
+
+def get_self_version():
+    global self_version
+    if self_version is not None:
+        return self_version
+    import msgboard
+    root = os.path.dirname(os.path.abspath(os.path.dirname(msgboard.__file__)))
+    proc = Popen(['hg', '--repository', root, 'identify'], stdout=PIPE)
+    (out, err) = proc.communicate()
+    version = out.split()[0]
+    if version[-1] == '+':
+        self_version = version[:6]+'+'
+    else:
+        self_version = version[:6]
+    return self_version

File msgboard/views.py

View file
  • Ignore whitespace
 @app.route('/about')
 def about():
     deps = []
-    deps.append(("MsgBoard", "https://bitbucket.org/benallard/msgboard", "0"))
+    deps.append(("MsgBoard", "https://bitbucket.org/benallard/msgboard",
+                  controller.get_self_version()))
     import sys
     deps.append(("Python", "http://python.org", sys.version.split()[0]))
     import flask
     deps.append(("Flask", "http://flask.pocoo.org/", str(flask.__version__)))
     import werkzeug
-    deps.append(("Werkzeug", "http://werkzeug.pocoo.org/", str(werkzeug.__version__)))
+    deps.append(("Werkzeug", "http://werkzeug.pocoo.org/",
+                  str(werkzeug.__version__)))
     import jinja2
-    deps.append(("Jinja2", "http://jinja.pocoo.org/2/", str(jinja2.__version__)))
+    deps.append(("Jinja2", "http://jinja.pocoo.org/2/",
+                  str(jinja2.__version__)))
     # don't know how to extract the version info from it
-    deps.append(("Flask-SQLAlchemy", "http://packages.python.org/Flask-SQLAlchemy/", None))
+    deps.append(("Flask-SQLAlchemy",
+                  "http://packages.python.org/Flask-SQLAlchemy/", None))
     import sqlalchemy
-    deps.append(("SQLAlchemy", "http://www.sqlalchemy.org/", str(sqlalchemy.__version__)))
+    deps.append(("SQLAlchemy", "http://www.sqlalchemy.org/",
+                  str(sqlalchemy.__version__)))
     if controller.publish is not None:
         import docutils
-        deps.append(("docutils", "http://docutils.sourceforge.net/", str(docutils.__version__)))
+        deps.append(("docutils", "http://docutils.sourceforge.net/",
+                      str(docutils.__version__)))
     return render_template('about.html', deps=deps)
 
 @app.route('/ajax', methods=['GET', 'POST'])