Skip to content

Commit

Permalink
new movefile function
Browse files Browse the repository at this point in the history
* bypasses python by using Java for file move
  • Loading branch information
jefferis committed Apr 16, 2015
1 parent 5aab88b commit 6109ca2
Showing 1 changed file with 12 additions and 0 deletions.
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 6109ca2

Please sign in to comment.