Skip to content
Snippets Groups Projects
Commit e8269967 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Closes #63 - adds git has and change time to logging output

During setup, this writes a file tupak/.version which contains the git
hash and change date. We can extend this in future to contain other
information. This is then printed when the logging is initialised.
parent 6cb756cc
No related branches found
No related tags found
No related merge requests found
Pipeline #
#!/usr/bin/env python #!/usr/bin/env python
from distutils.core import setup from distutils.core import setup
import subprocess
# Write a version file containing the git hash and info
git_log = subprocess.check_output(['git', 'log', '-1', '--pretty=%h %ai'])
git_diff = (subprocess.check_output(['git', 'diff', '.'])
+ subprocess.check_output(['git', 'diff', '--cached', '.']))
if git_diff == '':
status = '(CLEAN) ' + git_log
else:
status = '(UNCLEAN) ' + git_log
version_file = '.version'
with open('tupak/' + version_file, 'w+') as f:
f.write(status)
setup(name='tupak', setup(name='tupak',
version='0.1', version='0.1',
packages=['tupak'], packages=['tupak'],
package_dir={'tupak': 'tupak'}, package_dir={'tupak': 'tupak'},
package_data={'tupak': ['noise_curves/*.txt', 'prior_files/*.txt']} package_data={'tupak': ['noise_curves/*.txt', 'prior_files/*.txt',
version_file]}
) )
...@@ -322,6 +322,11 @@ def setup_logger(outdir=None, label=None, log_level='info'): ...@@ -322,6 +322,11 @@ def setup_logger(outdir=None, label=None, log_level='info'):
file_handler.setLevel(LEVEL) file_handler.setLevel(LEVEL)
logger.addHandler(file_handler) logger.addHandler(file_handler)
version_file = os.path.join(os.path.dirname(__file__), '.version')
with open(version_file, 'r') as f:
version = f.readline()
logging.info('Running tupak version: {}'.format(version))
def get_progress_bar(module='tqdm'): def get_progress_bar(module='tqdm'):
if module in ['tqdm']: if module in ['tqdm']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment