Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Progress Finished Question
#31
Media player? Media editor?

But I was getting confused, but think I've tightened it up some. This time, I am sure the checksums match. It may not be pretty and least resource intensive, but it works:

import os

def copyFunc(source, destination):
    with open(source, 'rb') as f1, open(destination, 'wb') as f2:
        full_size = os.stat(source).st_size
        full = 0
        increment = 10485760
        while full < full_size:
            chunk = f1.read(increment)
            full += increment
            calc = full
            if calc + increment > full_size:
                calc += full_size - full
            f2.write(chunk)
            print(round(calc / full_size * 100, 1), '%\r')

one = '397.64-desktop.exe'
two = 'C:\\Users\Mark\Downloads\Ordenador\driver.exe'

copyFunc(one, two)
A problem is that it prints 100% twice. I have to fix that...
Reply
#32
print(round(calc / full_size * 100, 1), '%', end='\r')
victor at Jerry in ~
↪ sha1sum '/media/storage/Download/Video/Etcher-Portable-1.3.1-x64.exe'
aea0b63b9bc0881662dd47b036a5f1324f5a6ed3 /media/storage/Download/Video/Etcher-Portable-1.3.1-x64.exe
victor at Jerry in ~
↪ sha1sum '/tmp/Etcher-Portable-1.3.1-x64.exe'
aea0b63b9bc0881662dd47b036a5f1324f5a6ed3 /tmp/Etcher-Portable-1.3.1-x64.exe
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#33
Alright then, thanks again for the help @wavic, it's much appreciated. I'm going to take a day or two to play with the code, see what comes of it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Process finished with exit code 137 (interrupted by signal 9: SIGKILL) erdemath 2 9,600 Apr-18-2022, 08:40 PM
Last Post: erdemath
  Progress bar bnadir55 1 1,848 Apr-11-2022, 01:52 PM
Last Post: deanhystad
  Using .hdf5 files only once they are finished writing pyhill00 7 2,828 Nov-25-2021, 06:01 PM
Last Post: pyhill00
  How to check if a file has finished being written leocsmith 2 7,895 Apr-14-2021, 04:21 PM
Last Post: perfringo
  Progress Indicator for Xmodem 0.4.6 KenHorse 1 1,993 Jan-30-2021, 07:12 PM
Last Post: bowlofred
  process finished with exit code -1073741819 (0xC0000005) GMCobraz 8 5,488 Sep-01-2020, 08:19 AM
Last Post: GMCobraz
  How to stop Xmodem after bin file transfer was finished shaya2103 0 2,536 Nov-27-2019, 04:33 PM
Last Post: shaya2103
  How can I add a progress bar for my software? aquerci 8 3,831 Nov-16-2019, 04:20 PM
Last Post: aquerci
  wget progress bar anasrocks 1 4,753 Jun-06-2019, 03:12 PM
Last Post: heiner55
  Process finished with exit code -107374819 (0xC0000375) mrazko 2 8,509 Apr-05-2019, 12:46 PM
Last Post: mrazko

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020