Skip to content

Commit

Permalink
fix trackProvenance if there is no git file
Browse files Browse the repository at this point in the history
  • Loading branch information
ver228 committed Apr 13, 2016
1 parent 849120d commit 9283676
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
18 changes: 1 addition & 17 deletions MWTracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,4 @@
# @author: ajaver
# """

# import os
# import sys

# curr_script_dir = os.path.dirname(os.path.realpath(__file__))
# movement_validation_dir = os.path.join(curr_script_dir, '..', '..', 'open-worm-analysis-toolbox')
# movement_validation_dir = os.path.abspath(movement_validation_dir)
# if not os.path.exists(movement_validation_dir):
# raise FileNotFoundError('%s does not exists. Introduce a valid path in the variable movement_validation_dir of the file config_param.py. \
# The path must point to the openWorm movement_validation repository.' % movement_validation_dir)


# sys.path.append(movement_validation_dir)

# try:
# import open_worm_analysis_toolbox
# except ImportError:
# raise ImportError('No module open_worm_analysis_toolbox in %s\nTake a look into MWTracker __init__ path' % movement_validation_dir)
from .version import __version__
15 changes: 9 additions & 6 deletions MWTracker/helperFunctions/trackProvenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
import tables
from git import Repo

def getGitVersion(main_package):
def getVersion(main_package):
git_file = os.path.join((os.sep).join((main_package.__file__).split(os.sep)[0:-2]), '.git')
assert os.path.exists(git_file)
repo = Repo(git_file)
return repo.commit('HEAD').hexsha
try:
repo = Repo(git_file)
return repo.commit('HEAD').hexsha
except git.exc.NoSuchPathError:
return main_package.__version__



def getGitCommitHash():
import MWTracker
import open_worm_analysis_toolbox

commits_hash = {'MWTracker':getGitVersion(MWTracker),
'open_worm_analysis_toolbox':getGitVersion(open_worm_analysis_toolbox)}
commits_hash = {'MWTracker':getVersion(MWTracker),
'open_worm_analysis_toolbox':getVersion(open_worm_analysis_toolbox)}

return commits_hash

Expand Down
2 changes: 2 additions & 0 deletions MWTracker/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# # -*- coding: utf-8 -*-
__version__='0.1a0'
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from setuptools import setup


exec(open('MWTracker/version.py').read())
setup(name='MWTracker',
version='1.0',
version=__version__,
description='Multiworm Tracker',
author='Avelino Javer',
author_email='avelino.javer@imperial.ac.uk',
Expand Down

0 comments on commit 9283676

Please sign in to comment.