Skip to content

Commit

Permalink
Merge branch 'fix/jython-move-error'
Browse files Browse the repository at this point in the history
* fix/jython-move-error:
  shutil.move->cmtkgui.movefile in CMTK installer
  new movefile function
  • Loading branch information
jefferis committed Apr 16, 2015
2 parents 5aab88b + 97986f2 commit 452e4a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Install_CMTK.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def untar_binaries(f,target_dir):
for binary in binaries:
frompath = os.path.join(td,binary.name)
# print 'from = '+frompath
shutil.move(frompath,target_dir)
cmtkgui.movefile(frompath,target_dir)
print("Cleaning up!")
shutil.rmtree(td)

Expand Down
12 changes: 12 additions & 0 deletions cmtkgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,15 @@ def download_and_untar_url(download_url,target_dir,untarfun,download_file=None,
untarfun(tf.name,target_dir)
IJ.showStatus('Cleaning up!')
tf.close()

def movefile(frompath, todir):
'''
move a file to a new location (renaming) using Java calls
needed because jython shutil.move has bugs
'''
if is_jython:
fromf=java.io.File(frompath)
tof=java.io.File(os.path.join(todir,os.path.basename(frompath)))
fromf.renameTo(tof)
else:
shutil.move(frompath, to)

0 comments on commit 452e4a1

Please sign in to comment.