text
stringlengths
1
93.6k
cached_jobs.append(num)
post_result(result, True, isblackout, istestrun) # True = is monitoring mode
return which, cached_battles, cached_jobs, battle_wins, battle_losses, battle_draws, splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches, job_successes, job_failures, foundany
def monitor_battles(which, secs, isblackout, istestrun, skipprefetch):
'''Monitors SplatNet endpoint(s) for changes (new results) and uploads them (-M flag).'''
if DEBUG:
print(f"* monitoring mode start - calling fetch_json() w/ which={which}")
# ! fetch from online - no 'specific' = should all be within 'latest'
cached_battles, cached_jobs = fetch_json(which, separate=True, numbers_only=True, printout=True, skipprefetch=skipprefetch)
if DEBUG:
print("* got battle numbers")
cached_battles.reverse()
cached_jobs.reverse()
# counters
battle_wins, battle_losses, battle_draws = [0]*3 # init all to 0
splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches = [0]*4
job_successes, job_failures = [0]*2
mins = str(round(float(secs)/60.0, 2))
mins = mins[:-2] if mins[-2:] == ".0" else mins
print(f"Waiting for new {utils.set_noun(which)}... (checking every {mins} minute{'s' if mins != '1' else ''})")
try:
while True:
for i in range(secs, -1, -1):
sys.stdout.write(f"Press Ctrl+C to exit. {i} ")
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\r")
print("Checking for new results...", end='\r')
input_params = [
which,
cached_battles, cached_jobs,
battle_wins, battle_losses, battle_draws,
splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches,
job_successes, job_failures,
isblackout, istestrun
]
which, cached_battles, cached_jobs, battle_wins, battle_losses, battle_draws, splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches, job_successes, job_failures, foundany=check_for_new_results(*input_params)
except KeyboardInterrupt:
print(f"\n\nChecking to see if there are unuploaded {utils.set_noun(which)} before exiting...")
input_params = [
which,
cached_battles, cached_jobs,
battle_wins, battle_losses, battle_draws,
splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches,
job_successes, job_failures,
isblackout, istestrun
]
which, cached_battles, cached_jobs, battle_wins, battle_losses, battle_draws, splatfest_wins, splatfest_losses, splatfest_draws, mirror_matches, job_successes, job_failures, foundany=check_for_new_results(*input_params)
noun = utils.set_noun(which)
if foundany:
print(f"Successfully uploaded remaining {noun}.")
else:
print(f"No remaining {noun} found.")
print("\n== SESSION REPORT ==")
if which in ("ink", "both"):
if battle_draws == 0:
print(f"Battles: {battle_wins} win{'' if battle_wins == 1 else 's'} and " \
f"{battle_losses} loss{'' if battle_losses == 1 else 'es'}.")
else:
print(f"Battles: {battle_wins} win{'' if battle_wins == 1 else 's'}, " \
f"{battle_losses} loss{'' if battle_losses == 1 else 'es'}, and " \
f"{battle_draws} draw{'' if battle_draws == 1 else 's'}.")
if splatfest_wins + splatfest_losses + splatfest_draws > 0:
if splatfest_draws == 0:
print(f"Splatfest: {splatfest_wins} win{'' if splatfest_wins == 1 else 's'} and " \
f"{splatfest_losses} loss{'' if splatfest_losses == 1 else 'es'} against the other Splatfest teams.")
else:
print(f"Splatfest: {splatfest_wins} win{'' if splatfest_wins == 1 else 's'}, " \
f"{splatfest_losses} loss{'' if splatfest_losses == 1 else 'es'}, and " \
f"{splatfest_draws} draw{'' if splatfest_draws == 1 else 's'} against the other Splatfest teams.")
print(f"{mirror_matches} mirror match{'' if mirror_matches == 1 else 'es'} against your Splatfest team.")
if which in ("salmon", "both"):
print(f"Salmon Run: {job_successes} success{'' if job_successes == 1 else 'es'} and " \
f"{job_failures} failure{'' if job_failures == 1 else 's'}.")
print("Bye!")
class SquidProgress:
'''Displays an animation of a squid swimming while waiting. :)'''
def __init__(self):
self.count = 0