Delete helper_func/progress_bar.py as part of folder deletion for helper_func/
Browse files- helper_func/progress_bar.py +0 -81
helper_func/progress_bar.py
DELETED
|
@@ -1,81 +0,0 @@
|
|
| 1 |
-
import time
|
| 2 |
-
import math
|
| 3 |
-
|
| 4 |
-
async def progress_bar(current, total, text, message, start):
|
| 5 |
-
now = time.time()
|
| 6 |
-
diff = now-start
|
| 7 |
-
if round(diff % 10) == 0 or current == total:
|
| 8 |
-
percentage = current*100/total
|
| 9 |
-
speed = current/diff
|
| 10 |
-
elapsed_time = round(diff)*1000
|
| 11 |
-
eta = round((total-current)/speed)*1000
|
| 12 |
-
|
| 13 |
-
# Format times for display
|
| 14 |
-
elapsed_time_formatted = TimeFormatter(elapsed_time)
|
| 15 |
-
eta_formatted = TimeFormatter(eta) # Just show remaining time
|
| 16 |
-
|
| 17 |
-
# Improved progress message with emojis and better formatting
|
| 18 |
-
if "Downloading" in text:
|
| 19 |
-
status = "📥 <b>Downloading File</b>"
|
| 20 |
-
elif "Uploading" in text:
|
| 21 |
-
status = "📤 <b>Uploading File</b>"
|
| 22 |
-
else:
|
| 23 |
-
status = "📝 <b>Processing File</b>"
|
| 24 |
-
|
| 25 |
-
progress = "{}\n\n".format(status)
|
| 26 |
-
progress += "📊 Size: {} of {}\n".format(
|
| 27 |
-
humanbytes(current),
|
| 28 |
-
humanbytes(total)
|
| 29 |
-
)
|
| 30 |
-
progress += "⚡ Speed: {}/s\n".format(
|
| 31 |
-
humanbytes(speed)
|
| 32 |
-
)
|
| 33 |
-
progress += "⏱️ Time Elapsed: {}\n".format(
|
| 34 |
-
elapsed_time_formatted if elapsed_time_formatted != '' else "0s"
|
| 35 |
-
)
|
| 36 |
-
progress += "⏳ ETA: {}\n".format(
|
| 37 |
-
eta_formatted if eta_formatted != '' else "0s"
|
| 38 |
-
)
|
| 39 |
-
progress += "📈 Progress: {:.1f}%".format(percentage)
|
| 40 |
-
|
| 41 |
-
try:
|
| 42 |
-
await message.edit(
|
| 43 |
-
text=progress
|
| 44 |
-
)
|
| 45 |
-
except:
|
| 46 |
-
pass
|
| 47 |
-
|
| 48 |
-
def humanbytes(size):
|
| 49 |
-
"""Convert size in bytes to human readable format"""
|
| 50 |
-
if not size:
|
| 51 |
-
return ""
|
| 52 |
-
# Define unit names
|
| 53 |
-
units = ('B', 'KB', 'MB', 'GB', 'TB')
|
| 54 |
-
# Convert to human readable format
|
| 55 |
-
for unit in units:
|
| 56 |
-
if size < 1024.0:
|
| 57 |
-
return "{:.2f} {}".format(size, unit)
|
| 58 |
-
size /= 1024.0
|
| 59 |
-
return "{:.2f} PB".format(size)
|
| 60 |
-
|
| 61 |
-
def TimeFormatter(milliseconds: int) -> str:
|
| 62 |
-
"""Format milliseconds to readable time string"""
|
| 63 |
-
seconds, milliseconds = divmod(int(milliseconds), 1000)
|
| 64 |
-
minutes, seconds = divmod(seconds, 60)
|
| 65 |
-
hours, minutes = divmod(minutes, 60)
|
| 66 |
-
days, hours = divmod(hours, 24)
|
| 67 |
-
|
| 68 |
-
# Only show relevant units
|
| 69 |
-
parts = []
|
| 70 |
-
if days > 0:
|
| 71 |
-
parts.append(f"{days}d")
|
| 72 |
-
if hours > 0:
|
| 73 |
-
parts.append(f"{hours}h")
|
| 74 |
-
if minutes > 0:
|
| 75 |
-
parts.append(f"{minutes}m")
|
| 76 |
-
if seconds > 0:
|
| 77 |
-
parts.append(f"{seconds}s")
|
| 78 |
-
if milliseconds > 0 and not parts: # Only show ms if no larger unit exists
|
| 79 |
-
parts.append(f"{milliseconds}ms")
|
| 80 |
-
|
| 81 |
-
return " ".join(parts) if parts else "0s"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|