add version.py needed for previous commit '4ce8492'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 01 Nov 2016 14:44:22 +0300
changeset 1561 f53ece47e18d
parent 1560 4ce8492159ab
child 1562 6e38f13d4b7b
add version.py needed for previous commit '4ce8492'
version.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/version.py	Tue Nov 01 14:44:22 2016 +0300
@@ -0,0 +1,34 @@
+import subprocess, os
+
+def GetAppRevision():
+    rev = None
+    app_dir=os.path.dirname(os.path.realpath(__file__))    
+    try:
+        pipe = subprocess.Popen(
+            ["hg", "id", "-i"],
+            stdout = subprocess.PIPE,
+            cwd = app_dir
+        )
+        rev = pipe.communicate()[0]
+        if pipe.returncode != 0:
+            rev = None
+    except:
+        pass
+    
+    # if this is not mercurial repository
+    # try to read revision from file
+    if rev is None:
+        try:
+            f = open(os.path.join(app_dir,"revision"))
+            rev = f.readline()
+        except:
+            pass
+    return rev
+
+app_version =  "1.2"
+rev = GetAppRevision()
+if rev is not None:
+    app_version = app_version + "-" + rev.rstrip()
+    
+        
+