changeset 5:a38efa4937d7 draft

Uploaded
author petr-novak
date Wed, 03 Jul 2019 07:23:21 -0400
parents 6a92134a105b
children 6dcecbe81d78
files dante.py
diffstat 1 files changed, 29 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/dante.py	Wed Jul 03 05:29:51 2019 -0400
+++ b/dante.py	Wed Jul 03 07:23:21 2019 -0400
@@ -413,25 +413,35 @@
 
 
 def get_version(path, LAST_DB):
-    branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD",
-                                     shell=True,
-                                     cwd=path).decode('ascii').strip()
-    shorthash = subprocess.check_output("git log --pretty=format:'%h' -n 1  ",
-                                        shell=True,
-                                        cwd=path).decode('ascii').strip()
-    revcount = len(subprocess.check_output("git log --oneline",
-                                           shell=True,
-                                           cwd=path).decode('ascii').split())
-    version_string = (
-        "##-----------------------------------------------\n"
-        "##PIPELINE VERSION         : "
-        "{branch}-rv-{revcount}({shorthash})\n"
-        "##PROTEIN DATABASE VERSION : {PD}\n"
-        "##-----------------------------------------------\n").format(
-            branch=branch,
-            shorthash=shorthash,
-            revcount=revcount,
-            PD=os.path.basename(LAST_DB))
+    '''Return version is run from git repository '''
+    try:
+        branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD",
+                                         shell=True,
+                                         cwd=path).decode('ascii').strip()
+        shorthash = subprocess.check_output("git log --pretty=format:'%h' -n 1  ",
+                                            shell=True,
+                                            cwd=path).decode('ascii').strip()
+        revcount = len(subprocess.check_output("git log --oneline",
+                                               shell=True,
+                                               cwd=path).decode('ascii').split())
+        version_string = (
+            "##-----------------------------------------------\n"
+            "##PIPELINE VERSION         : "
+            "{branch}-rv-{revcount}({shorthash})\n"
+            "##PROTEIN DATABASE VERSION : {PD}\n"
+            "##-----------------------------------------------\n").format(
+                branch=branch,
+                shorthash=shorthash,
+                revcount=revcount,
+                PD=os.path.basename(LAST_DB))
+    except:
+        version_string = (
+            "##-----------------------------------------------\n"
+            "##PROTEIN DATABASE VERSION : {PD}\n"
+            "##-----------------------------------------------\n").format(
+                PD=os.path.basename(LAST_DB)
+            )
+
     return version_string