Skip to content

Commit

Permalink
Merge branch 'fix/gui-update'
Browse files Browse the repository at this point in the history
* fix/gui-update:
  catch non IO errors in gui_github_versioninfo()
  wrap whole of gui_github_versioninfo in try
  fix one final missing import IJ in gui update
  • Loading branch information
jefferis committed Apr 16, 2015
2 parents 6d84463 + 39d680e commit e66617f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cmtkgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def install_dir():

def gui_install_dir():
'''return sensible location to install CMTK GUI'''
from ij import IJ
pluginsdir=IJ.getDirectory('plugins')
return os.path.join(pluginsdir,'Scripts','Plugins','CMTK_Registration')

Expand Down Expand Up @@ -252,16 +253,19 @@ def gui_github_versioninfo():
Create a dictionary containing version information for current
github code
'''
try: u = urllib2.urlopen(gui_tarball_url)
try:
u = urllib2.urlopen(gui_tarball_url)
headers = u.info()
date = headers['date']
size = int(headers['Content-Length'])
filename = re.sub(".*filename=","",headers['Content-Disposition'])
u.close()
abbrev_sha1 = re.sub(".*-([a-f0-9]+).tar.gz","\\1",filename)
return {'abbrev_sha1':abbrev_sha1, 'filename':filename, 'date':date, 'size':size}
except IOError, e:
myErr("Unable to read github repository")
headers = u.info()
date = headers['date']
size = int(headers['Content-Length'])
filename = re.sub(".*filename=","",headers['Content-Disposition'])
u.close()
abbrev_sha1 = re.sub(".*-([a-f0-9]+).tar.gz","\\1",filename)
return {'abbrev_sha1':abbrev_sha1, 'filename':filename, 'date':date, 'size':size}
except :
myErr("Trouble parsing github return information")

def gui_local_versioninfo():
'''
Expand Down

0 comments on commit e66617f

Please sign in to comment.