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
|
||||
"""
|
||||
from alive_progress import alive_bar
|
||||
with alive_bar(4) as bar:
|
||||
bar.text("Reading provider file...")
|
||||
try:
|
||||
with open("provider") as file:
|
||||
prov = file.read()
|
||||
except Exception:
|
||||
prov = "tiny.cc"
|
||||
bar()
|
||||
bar.text("Setting up instance...")
|
||||
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)
|
||||
try:
|
||||
with open("provider") as file:
|
||||
prov = file.read()
|
||||
except Exception:
|
||||
prov = "tiny.cc"
|
||||
datums = URL(provider=prov) #create instance
|
||||
datums.GetURL((1,25)) #get a random url with a length from 1 to 6
|
||||
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
|
||||
datums.WriteFile() #write to json file
|
||||
|
||||
main = wrapper
|
||||
if __name__ == "__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.)")
|
||||
while True:
|
||||
try:
|
||||
open("sotp")
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print("sotpping")
|
||||
sys.exit(0)
|
||||
try:
|
||||
URLs.main()
|
||||
except URLs.NonexistentUrl as ename:
|
||||
print("NonexistentUrl - %s"%ename)
|
||||
except Exception as ename:
|
||||
print(f"Error - {ename}")
|
||||
with alive_bar() as bar:
|
||||
while True:
|
||||
try:
|
||||
open("sotp")
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print("sotpping")
|
||||
sys.exit(0)
|
||||
try:
|
||||
URLs.main()
|
||||
except URLs.NonexistentUrl as ename:
|
||||
print("NonexistentUrl - %s"%ename)
|
||||
except Exception as ename:
|
||||
print(f"Error - {ename}")
|
||||
bar()
|
||||
|
|
Loading…
Reference in New Issue