def test_depset() -> None: """Test call to try this stuff out...""" if bool(False): print('running test_depset()...') def doit() -> None: from ba._error import DependencyError depset = DependencySet(Dependency(TestClass)) try: depset.resolve() except DependencyError as exc: for dep in exc.deps: if dep.cls is AssetPackage: print('MISSING ASSET PACKAGE', dep.config) else: raise Exception('unknown dependency error for ' + str(dep.cls)) except Exception as exc: print('DependencySet resolve failed with exc type:', type(exc)) if depset.resolved: depset.load() testobj = depset.root # instance = testclass(123) print("INSTANTIATED ROOT:", testobj) doit() # To test this, add prints on __del__ for stuff used above; # everything should be dead at this point if we have no cycles. print('everything should be cleaned up...') _ba.quit()
def refreshLeaderboard(self): global leaderboard global top200 _t200 = {} lboard = mystats.get_all_stats() leaderboard = lboard try: entries = [(a['scores'], a['kills'], a['deaths'], a['games'], a['name'], a['aid'], a['last_seen']) for a in lboard.values()] except: print( "stats reset is required , please clear out stats.json records , or download fresh stats.json from github" ) import _ba _ba.quit() entries.sort(reverse=True) rank = 0 for entry in entries: rank += 1 if rank > 201: break _t200[entry[5]] = { "rank": rank, "scores": int(entry[0]), "games": int(entry[3]), "kills": int(entry[1]), "deaths": int(entry[2]), "name_html": entry[4], "last_seen": entry[6] } top200 = _t200
def _check_activity_death(cls, activity_ref: ReferenceType[Activity], counter: List[int]) -> None: """Sanity check to make sure an Activity was destroyed properly. Receives a weakref to a ba.Activity which should have torn itself down due to no longer being referenced anywhere. Will complain and/or print debugging info if the Activity still exists. """ try: import gc import types activity = activity_ref() print('ERROR: Activity is not dying when expected:', activity, '(warning ' + str(counter[0] + 1) + ')') print('This means something is still strong-referencing it.') counter[0] += 1 # FIXME: Running the code below shows us references but winds up # keeping the object alive; need to figure out why. # For now we just print refs if the count gets to 3, and then we # kill the app at 4 so it doesn't matter anyway. if counter[0] == 3: print('Activity references for', activity, ':') refs = list(gc.get_referrers(activity)) i = 1 for ref in refs: if isinstance(ref, types.FrameType): continue print(' reference', i, ':', ref) i += 1 if counter[0] == 4: print('Killing app due to stuck activity... :-(') _ba.quit() except Exception: from ba import _error _error.print_exception('exception on _check_activity_death:')
def do_quit() -> None: _ba.quit()
def restart_callback(playerdata: PlayerData, args): _ba.quit()