utils.py 540 B

123456789101112131415161718192021222324
  1. import asyncio
  2. async def system(command: str):
  3. proc = await asyncio.create_subprocess_shell(command)
  4. await proc.communicate()
  5. def to_hhmmss(secs: int):
  6. hours = secs // 3600
  7. minutes = (secs - (hours * 3600)) // 60
  8. seconds = secs - (hours * 3600) - (minutes * 60)
  9. if minutes < 10:
  10. minutes = f"0{minutes}"
  11. if seconds < 10:
  12. seconds = f"0{seconds}"
  13. if hours < 10:
  14. hours = f"0{hours}"
  15. if hours == 0:
  16. return f"{minutes}:{seconds}"
  17. return f"{hours}:{minutes}:{seconds}"