1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/update.py

97 lines
2.8 KiB
Python
Raw Normal View History

2017-10-10 21:30:06 +00:00
import db
import errors
import time
# Stop updating if Ctrl-C is pressed
try:
# Update Steam
print("STEAM")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.Steam).all():
2017-10-10 21:30:06 +00:00
print(f"Updating {user.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-10 21:30:06 +00:00
# Update Rocket League
print("ROCKET LEAGUE")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.RocketLeague).all():
2017-10-10 21:30:06 +00:00
print(f"Updating {user.steam.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-10 21:30:06 +00:00
# Update Dota 2
print("DOTA 2")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.Dota).all():
2017-10-10 21:30:06 +00:00
print(f"Updating {user.steam.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-10 21:30:06 +00:00
# Update League of Legends
print("LEAGUE OF LEGENDS")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.LeagueOfLegends).all():
2017-10-10 21:30:06 +00:00
print(f"Updating {user.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-10 21:30:06 +00:00
# Update Osu!
print("OSU!")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.Osu).all():
2017-10-10 21:30:06 +00:00
print(f"Updating {user.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-17 18:49:28 +00:00
# Update Overwatch
print("OVERWATCH")
2017-10-25 09:09:06 +00:00
for user in db.session.query(db.Overwatch).all():
2017-10-17 18:49:28 +00:00
print(f"Updating {user.royal.username}", end="\t\t", flush=True)
try:
user.update()
except errors.RequestError:
print("Request Error")
except errors.NotFoundError:
print("Not Found Error (?)")
else:
print("OK")
finally:
2017-10-25 09:09:06 +00:00
time.sleep(0.5)
2017-10-10 21:30:06 +00:00
except KeyboardInterrupt:
pass
finally:
print("Committing...\t\t")
2017-10-25 09:09:06 +00:00
db.session.commit()
print("OK")
db.session.close()