Есть некий код, задача которого копировать файл из пункта *А* в пункт *Б*, вместе с этим выводить в консоли progressbar виду:
(скопировано кб) / (всего кб)
Скрипт готовился как часть для иного скрипта, задача которого - рекурсивное копирование файлов.
Вообщем буду рад любой конструктивной критике и разумным советам.
Заранее благодарен.
import os.path import shutil import threading ctrl_c = "/home/lov3catch/Lama.avi" ctrl_v = "/home/lov3catch/test_copy" def copy_file(my_file, my_file_dst): try: if os.path.getsize(my_file) != os.path.getsize(os.path.join(my_file_dst, os.path.basename(my_file))): shutil.copy(my_file, my_file_dst) except OSError as e: print e.strerror shutil.copy(my_file, my_file_dst) def copiing(): th = threading.Thread(name='th3', target=copy_file, kwargs={'my_file': ctrl_c, 'my_file_dst': ctrl_v}) th.start() def progressbar(same_def): same_def() while True: os.system('clear') print os.path.getsize(os.path.join(ctrl_v, os.path.basename(ctrl_c))),"/",os.path.getsize(ctrl_c) if os.path.getsize(ctrl_c) == os.path.getsize(os.path.join(ctrl_v, os.path.basename(ctrl_c))) : break th = threading.Thread(name='th4', target=progressbar, kwargs={'same_def':copiing}) th.start()