Reputation: 19329
While copying large data files over network drives:
cmd=None
if sys.platform.startswith("darwin"): cmd=['cp', source, dest]
elif sys.platform.startswith("win"): cmd=['xcopy', source, dest, '/K/O/X']
if cmd: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
I wonder if there's a way to hook to started process to get feedback: such as a network transfer data rate... any suggestions?
Upvotes: 0
Views: 150
Reputation: 3709
I am not sure what the "feedback" means but you can get the current status of copy by using multithreading.
You can have one thread who keeps doing
du -h file_name
This link has more info - https://unix.stackexchange.com/questions/66795/how-to-check-progress-of-running-cp
Upvotes: 0
Reputation: 28
This should do what you want it to :)
if cmd:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
result = proc.communicate()[0]
print result
this should do what you want.
Upvotes: 1