Skip to content

Commit

Permalink
fix uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Sep 7, 2020
1 parent f203a75 commit fa1fa01
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
33 changes: 20 additions & 13 deletions tobrot/helper_funcs/display_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async def progress_for_pyrogram(
time_to_completion = round((total - current) / speed) * 1000
estimated_total_time = elapsed_time + time_to_completion

elapsed_time = TimeFormatter(milliseconds=elapsed_time)
estimated_total_time = TimeFormatter(milliseconds=estimated_total_time)
elapsed_time = time_formatter(milliseconds=elapsed_time)
estimated_total_time = time_formatter(milliseconds=estimated_total_time)

progress = "[{0}{1}] \nP: {2}%\n".format(
''.join([FINISHED_PROGRESS_STR for i in range(math.floor(percentage / 5))]),
Expand Down Expand Up @@ -85,14 +85,21 @@ def humanbytes(size):
return str(round(size, 2)) + " " + Dic_powerN[n] + 'B'


def TimeFormatter(milliseconds: int) -> str:
seconds, milliseconds = divmod(int(milliseconds), 1000)
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
tmp = ((str(days) + "d, ") if days else "") + \
((str(hours) + "h, ") if hours else "") + \
((str(minutes) + "m, ") if minutes else "") + \
((str(seconds) + "s, ") if seconds else "") + \
((str(milliseconds) + "ms, ") if milliseconds else "")
return tmp[:-2]
def time_formatter(seconds: int) -> str:
result = ""
v_m = 0
remainder = seconds
r_ange_s = {
"days": (24 * 60 * 60),
"hours": (60 * 60),
"minutes": 60,
"seconds": 1
}
for age in r_ange_s:
divisor = r_ange_s[age]
v_m, remainder = divmod(remainder, divisor)
v_m = int(v_m)
if v_m != 0:
result += f" {v_m} {age} "
return result

4 changes: 2 additions & 2 deletions tobrot/plugins/status_message_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from tobrot.dinmamoc import Commandi
from tobrot.amocmadin import Loilacaztion
from tobrot.helper_funcs.display_progress import (
TimeFormatter,
time_formatter,
humanbytes
)

Expand Down Expand Up @@ -72,7 +72,7 @@ async def status_message_f(client, message):
if msg == "":
msg = Loilacaztion.NO_TOR_STATUS

currentTime = TimeFormatter((time.time() - BOT_START_TIME))
currentTime = time_formatter((time.time() - BOT_START_TIME))
total, used, free = shutil.disk_usage(".")
total = humanbytes(total)
used = humanbytes(used)
Expand Down

0 comments on commit fa1fa01

Please sign in to comment.