Skip to content

Commit

Permalink
Merge branch 'fix/auto-upgrade'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfobel committed Aug 16, 2017
2 parents 094e162 + e414b48 commit edbe43c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions microdrop_launcher/auto_upgrade.py
Expand Up @@ -24,7 +24,21 @@ def _strip_conda_menuinst_messages(conda_output):
[1]: https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/RWs9of4I2KM
'''
return '\n'.join(line_i for line_i in conda_output.splitlines()
if not line_i.startswith('INFO'))
if not line_i.strip().startswith('INFO'))


def _strip_progress_messages(conda_output):
'''
Strip progress messages from Conda install output log.
For example:
{"maxval": 133256, "finished": false, "fetch": "microdrop-laun", "progress": 0}
'''
cre_json_progress = re.compile(r'{"maxval":[^,]+,\s+"finished":[^,]+,'
r'\s+"fetch":\s+[^,]+,\s+"progress":[^}]+}')
return '\n'.join(line_i for line_i in conda_output.splitlines()
if not cre_json_progress.search(line_i))


def main():
Expand All @@ -38,6 +52,10 @@ def main():
Fix displayed package name during upgrade.
Fail gracefully with warning on JSON decode error.
.. versionchanged:: 0.7.7
Strip progress messages from Conda install output log to prevent JSON
decoding errors.
'''
# Upgrade `microdrop-launcher` package if there is a new version available.
print 'Checking for `microdrop-launcher` updates',
Expand Down Expand Up @@ -67,7 +85,7 @@ def main():
# A new version of the launcher is available for installation.
print 'Upgrading to:', launcher_packages[0]
install_log_json = ch.conda_exec('install', '--json',
'microdrop-launcher',
'microdrop-launcher', '--quiet',
verbose=False)
install_log_json = _strip_conda_menuinst_messages(install_log_json)
try:
Expand Down

0 comments on commit edbe43c

Please sign in to comment.