better progress bar in wrapper
This commit is contained in:
parent
c74faba092
commit
3e00bf9a05
35
URLs.py
35
URLs.py
|
@ -91,30 +91,17 @@ def wrapper():
|
||||||
"""
|
"""
|
||||||
Example wrapper
|
Example wrapper
|
||||||
"""
|
"""
|
||||||
from alive_progress import alive_bar
|
try:
|
||||||
with alive_bar(4) as bar:
|
with open("provider") as file:
|
||||||
bar.text("Reading provider file...")
|
prov = file.read()
|
||||||
try:
|
except Exception:
|
||||||
with open("provider") as file:
|
prov = "tiny.cc"
|
||||||
prov = file.read()
|
datums = URL(provider=prov) #create instance
|
||||||
except Exception:
|
datums.GetURL((1,25)) #get a random url with a length from 1 to 6
|
||||||
prov = "tiny.cc"
|
print(f"Pinging URL {datums.url}") #you can also modify datums.url, you can use that for tracker stuff (just make a wrapper that changes this variable as necessary instead of running GetURL())
|
||||||
bar()
|
datums.GetDownload() #download the url
|
||||||
bar.text("Setting up instance...")
|
datums.WriteFile() #write to json file
|
||||||
datums = URL(provider=prov) #create instance
|
|
||||||
time.sleep(0.1)
|
|
||||||
bar()
|
|
||||||
bar.text("Getting URL...")
|
|
||||||
datums.GetURL((1,25)) #get a random url with a length from 1 to 6
|
|
||||||
time.sleep(0.1)
|
|
||||||
bar()
|
|
||||||
bar.text("Getting redirect...")
|
|
||||||
print(f"Pinging URL {datums.url}") #you can also modify datums.url, you can use that for tracker stuff (just make a wrapper that changes this variable as necessary instead of running GetURL())
|
|
||||||
datums.GetDownload() #download the url
|
|
||||||
bar()
|
|
||||||
bar.text("Writing to file...")
|
|
||||||
datums.WriteFile() #write to json file
|
|
||||||
time.sleep(0.1)
|
|
||||||
main = wrapper
|
main = wrapper
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
33
wrapper.py
33
wrapper.py
|
@ -1,16 +1,19 @@
|
||||||
import subprocess, URLs
|
from alive_progress import alive_bar
|
||||||
|
import subprocess, URLs, sys
|
||||||
print("Infinitely running the file. (To stop this, add a file called \"sotp\" in the working directory.)")
|
print("Infinitely running the file. (To stop this, add a file called \"sotp\" in the working directory.)")
|
||||||
while True:
|
with alive_bar() as bar:
|
||||||
try:
|
while True:
|
||||||
open("sotp")
|
try:
|
||||||
except Exception:
|
open("sotp")
|
||||||
pass
|
except Exception:
|
||||||
else:
|
pass
|
||||||
print("sotpping")
|
else:
|
||||||
sys.exit(0)
|
print("sotpping")
|
||||||
try:
|
sys.exit(0)
|
||||||
URLs.main()
|
try:
|
||||||
except URLs.NonexistentUrl as ename:
|
URLs.main()
|
||||||
print("NonexistentUrl - %s"%ename)
|
except URLs.NonexistentUrl as ename:
|
||||||
except Exception as ename:
|
print("NonexistentUrl - %s"%ename)
|
||||||
print(f"Error - {ename}")
|
except Exception as ename:
|
||||||
|
print(f"Error - {ename}")
|
||||||
|
bar()
|
||||||
|
|
Loading…
Reference in New Issue