How to use unsubscribe_from_event method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

round_stats_functions.py

Source:round_stats_functions.py Github

copy

Full Screen

...292293def get_ranks(data):294 global ranks_done, PLAYERS, actual_players295 if ranks_done:296 g.demo_stats.unsubscribe_from_event("parser_new_tick", get_ranks)297 if game_mode_done:298 g.demo_stats.unsubscribe_from_event("packet_svc_PacketEntities")299 else:300 res_table = g.demo_stats.get_resource_table()301 if not res_table:302 return303 else:304 res_table = res_table.props305 for player in PLAYERS.values():306 if player.userinfo.xuid == 0:307 continue308 if not RANK_STATS.get(player.userinfo.xuid):309 RANK_STATS.update({player.userinfo.xuid: None})310 if RANK_STATS[player.userinfo.xuid] is None:311 key = str(player.userinfo.entity_id).zfill(3)312 connected = res_table["m_bConnected"][key]313 in_team = res_table["m_iTeam"][key]314 if not (in_team == 2 or in_team == 3) or not connected:315 RANK_STATS.pop(player.userinfo.xuid)316 continue317 if connected:318 rank = res_table["m_iCompetitiveRanking"][key]319 RANK_STATS.update({player.userinfo.xuid: rank})320 if len(RANK_STATS) == actual_players:321 ranks_done = True322 for ranks in RANK_STATS.values():323 if ranks is None:324 ranks_done = False325 break326327328def get_game_mode(data):329 global game_mode, PLAYERS, game_mode_done330 gmd = dict()331 if game_mode in (-7, 0, 0.1):332 if g.demo_stats.header.server_name.upper().find("VALVE") == -1:333 game_mode_done = True334 if ranks_done:335 g.demo_stats.unsubscribe_from_event("packet_svc_PacketEntities")336 g.demo_stats.unsubscribe_from_event("parser_new_tick", get_game_mode)337 return338 res_table = g.demo_stats.get_resource_table()339 if res_table and len(PLAYERS) >= actual_players - 1:340 for player in PLAYERS.values():341 game_mode2 = res_table.props["m_iCompetitiveRankType"][str(player.userinfo.entity_id).zfill(3)]342 gmd.update({game_mode2: 1 if not gmd.get(game_mode2) else gmd.get(game_mode2) + 1})343 # if game_mode != -1:344 # g.demo_stats.unsubscribe_from_event("packet_svc_PacketEntities")345 # g.demo_stats.unsubscribe_from_event("parser_new_tick", get_game_mode)346 # break347 # print(gmd)348 for x in sorted(gmd.keys(), reverse=True):349 # print(x, len(PLAYERS.values()))350 game_mode2 = x351 if game_mode2 != 0:352 game_mode = game_mode + game_mode2 * 2 if game_mode2 == 7 else game_mode + game_mode2353 game_mode_done = True354 if ranks_done:355 g.demo_stats.unsubscribe_from_event("packet_svc_PacketEntities")356 g.demo_stats.unsubscribe_from_event("parser_new_tick", get_game_mode)357 else:358 if not match_started:359 g.demo_stats.unsubscribe_from_event("parser_new_tick", get_game_mode)360 g.demo_stats.subscribe_to_event("gevent_begin_new_match", get_game_mode)361 elif match_started:362 game_mode_done = True363 if ranks_done:364 g.demo_stats.unsubscribe_from_event("packet_svc_PacketEntities")365 g.demo_stats.unsubscribe_from_event("parser_new_tick", get_game_mode)366 g.demo_stats.unsubscribe_from_event("gevent_begin_new_match", get_game_mode)367 break368369# first passing > looking for round switch and max players to determine game mode370371372def new_demo_gamemode(data):373 global round_switch, game_mode, max_players, PLAYERS, BOTS, match_started, round_current, actual_players, round_switch_found374 match_started = False375 round_current = 1376 round_switch = 0377 round_switch_found = False378 game_mode = 0379 max_players = 0380 actual_players = 0 ...

Full Screen

Full Screen

dispatch.py

Source:dispatch.py Github

copy

Full Screen

...8 def subscribe_to_event(self, event_class, subscriber):9 entry = EventDispatcherEntry(self, event_class, subscriber)10 self._subscribers.setdefault(event_class, []).append(weakref.ref(entry))11 return entry12 def unsubscribe_from_event(self, event_class, subscriber):13 try:14 self._subscribers[event_class].remove(weakref.ref(subscriber))15 except KeyError:16 pass17 def dispatch_event(self, event):18 try:19 for entry in self._subscribers[event.__class__]:20 if entry():21 entry()._subscriber(event)22 else:23 self._subscribers[event.__class__].remove(entry)24 except KeyError:25 pass26class EventDispatcherEntry(object):...

Full Screen

Full Screen

setsnstopic.py

Source:setsnstopic.py Github

copy

Full Screen

...7 client = boto3.client('inspector')8 if event['RequestType'] == 'Create':9 response_data = client.subscribe_to_event(**params)10 if event['RequestType'] == 'Delete':11 response_data = client.unsubscribe_from_event(**params)12 if event['RequestType'] == 'Update':13 old_params = dict([(k, v) for k, v in event['OldResourceProperties'].items() if k != 'ServiceToken'])14 client.unsubscribe_from_event(**old_params)15 response_data = client.subscribe_to_event(**params)16 print(response_data)17 lambda_response = cr_response.CustomResourceResponse(event, context)18 lambda_response.respond()19 except Exception as e:20 lambda_response.respond_error(e)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful