Improved output of version and commit hash
@@ -3,6 +3,9 @@ import colorama
import os
import numpy as np
import subprocess
+import sharpy.utils.sharpydir as sharpydir
+
+cwd = os.getcwd()
class Writer(object):
@@ -55,8 +58,6 @@ class Writer(object):
def print_welcome_message(self):
self.__call__(self.sharpy_ascii)
self.__call__(self.sharpy_license)
- import sharpy.utils.sharpydir as sharpydir
- cwd = os.getcwd()
self.__call__('Running SHARPy from ' + cwd, 2)
self.__call__('SHARPy being run is in ' + sharpydir.SharpyDir, 2)
self.__call__(print_git_status(), 2)
@@ -169,20 +170,20 @@ class TablePrinter(object):
# version tracker and output
-def get_git_revision_hash():
- return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8')
+def get_git_revision_hash(di=sharpydir.SharpyDir):
+ return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=di).strip().decode('utf-8')
-def get_git_revision_short_hash():
- return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')
+def get_git_revision_short_hash(di=sharpydir.SharpyDir):
+ return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=di).strip().decode('utf-8')
-def get_git_revision_branch():
- return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode('utf-8')
+def get_git_revision_branch(di=sharpydir.SharpyDir):
+ return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=di).strip().decode('utf-8')
-def get_git_tag():
- return subprocess.check_output(['git', 'describe']).strip().decode('utf-8')
+def get_git_tag(di=sharpydir.SharpyDir):
+ return subprocess.check_output(['git', 'describe'], cwd=di).strip().decode('utf-8')
def print_git_status():
