Loading crossbow/crossbow.py +19 −3 Original line number Diff line number Diff line from ckanapi import RemoteCKAN from shutil import copyfile from progressbar import ProgressBar, Bar, Percentage from clint.textui import progress import os Loading Loading @@ -160,6 +160,7 @@ class crossbowMount(crossbowBase): nonstandard Python package requirements: - clint - ckanapi - progressbar parameters: - NFS_path: string Loading Loading @@ -327,8 +328,23 @@ class crossbowMount(crossbowBase): resource_path = resource_path.replace("file://CROSSBOW_NFS/", self.NFS_path) dest_path = destination + os.path.basename(resource_path) print "copying %s to %s" % (resource_path, dest_path) copyfile(resource_path, dest_path) #custom function to copy with progress bar def copy_with_progress(src, dst, callback, length=16*1024): copied = 0 size = os.path.getsize(src) with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: while True: buf = fsrc.read(length) if not buf: break fdst.write(buf) copied += len(buf) callback(copied,size) prog = ProgressBar(widgets=[Percentage(), Bar()], maxval=100).start() copy_with_progress(resource_path, dest_path, lambda pos, total: prog.update(100*pos/float(total))) print '' def delete_resource(self,package,resource,delete_from_nfs=False): ''' Loading Loading
crossbow/crossbow.py +19 −3 Original line number Diff line number Diff line from ckanapi import RemoteCKAN from shutil import copyfile from progressbar import ProgressBar, Bar, Percentage from clint.textui import progress import os Loading Loading @@ -160,6 +160,7 @@ class crossbowMount(crossbowBase): nonstandard Python package requirements: - clint - ckanapi - progressbar parameters: - NFS_path: string Loading Loading @@ -327,8 +328,23 @@ class crossbowMount(crossbowBase): resource_path = resource_path.replace("file://CROSSBOW_NFS/", self.NFS_path) dest_path = destination + os.path.basename(resource_path) print "copying %s to %s" % (resource_path, dest_path) copyfile(resource_path, dest_path) #custom function to copy with progress bar def copy_with_progress(src, dst, callback, length=16*1024): copied = 0 size = os.path.getsize(src) with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: while True: buf = fsrc.read(length) if not buf: break fdst.write(buf) copied += len(buf) callback(copied,size) prog = ProgressBar(widgets=[Percentage(), Bar()], maxval=100).start() copy_with_progress(resource_path, dest_path, lambda pos, total: prog.update(100*pos/float(total))) print '' def delete_resource(self,package,resource,delete_from_nfs=False): ''' Loading