Advertisement
raiyanshadow

downloadsimulator.py

Feb 6th, 2022
1,319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.18 KB | None | 0 0
  1. import sys, time, speedtest, math, random, os
  2.  
  3. speed = speedtest.Speedtest()
  4. down =  float("{:.2f}".format((speed.download() / 10e5) / 8))
  5. print("cmd enter: ")
  6. a = input()
  7. b = a.split()
  8. d = b[-1]
  9. e = random.uniform(1024, 10240)
  10. f = float("{:.4f}".format(e))
  11. dtime = f / down
  12. extracttime = dtime/8.32
  13. validtime = dtime/20.88
  14. installtime = dtime/4.21
  15.  
  16. print("You are downloading the script", d,"(",f,"MBs at",down," MB/s)\nPress Y or N to confirm: ")
  17.  
  18. c = input()
  19.  
  20. if c == 'Y' or c == 'y':
  21.     print("Initiating download", end = "", flush=True)
  22.     time.sleep(1)
  23.     for i in range(3):
  24.         print(".", end = "", flush=True)
  25.         time.sleep(1)
  26. elif c == 'N' or c == 'n':
  27.     print("Command cancelled", end = "", flush=True)
  28.     time.sleep(1)
  29.     for i in range(3):
  30.         print(".", end = "", flush=True)
  31.         time.sleep(1)
  32. else:
  33.     raise Exception("~~--> user input: "+ c +" \n~~-->error.InvalidKeystroke() raise: [Errno 1923]")
  34.     exit()
  35.  
  36. #animation = ["10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
  37. animation = ["[■□□□□□□□□□]","[■■□□□□□□□□]", "[■■■□□□□□□□]", "[■■■■□□□□□□]", "[■■■■■□□□□□]", "[■■■■■■□□□□]", "[■■■■■■■□□□]", "[■■■■■■■■□□]", "[■■■■■■■■■□]", "[■■■■■■■■■■]"]
  38.  
  39. for i in range(len(animation)):
  40.     time.sleep(float(extracttime/10))
  41.     sys.stdout.write("\rExtracting packages: " + animation[i % len(animation)])
  42.     sys.stdout.flush()
  43. print()
  44. for i in range(len(animation)):
  45.     time.sleep(float(validtime/10))
  46.     sys.stdout.write("\rValidating package tokens: " + animation[i % len(animation)])
  47.     sys.stdout.flush()
  48. print()
  49. for i in range(len(animation)):
  50.     time.sleep(float(dtime/10))
  51.     sys.stdout.write("\rDownloading: " + animation[i % len(animation)])
  52.     sys.stdout.flush()
  53. print()
  54. for i in range(len(animation)):
  55.     time.sleep(float(installtime/10))
  56.     sys.stdout.write("\rFinalizing installation: " + animation[i % len(animation)])
  57.     sys.stdout.flush()
  58.    
  59. print("\nInstallation of script " + d +" complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement