mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-03 21:37:05 +00:00 
			
		
		
		
	Added convert_bytes function to show correctly FTP upload progress
This commit is contained in:
		@@ -6,6 +6,21 @@ import ftplib
 | 
			
		||||
 | 
			
		||||
transferred=0
 | 
			
		||||
 | 
			
		||||
def convert_bytes(n):
 | 
			
		||||
	K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
 | 
			
		||||
	if   n >= P:
 | 
			
		||||
		return '%.2fPb' % (float(n) / T)
 | 
			
		||||
	elif   n >= T:
 | 
			
		||||
		return '%.2fTb' % (float(n) / T)
 | 
			
		||||
	elif n >= G:
 | 
			
		||||
		return '%.2fGb' % (float(n) / G)
 | 
			
		||||
	elif n >= M:
 | 
			
		||||
		return '%.2fMb' % (float(n) / M)
 | 
			
		||||
	elif n >= K:
 | 
			
		||||
		return '%.2fKb' % (float(n) / K)
 | 
			
		||||
	else:
 | 
			
		||||
		return '%d' % n
 | 
			
		||||
 | 
			
		||||
def callback(progress):
 | 
			
		||||
	global transferred
 | 
			
		||||
	transferred = transferred+len(progress)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user