Esempio n. 1
0
    def __init__(self, stomp_connection,
                 tellme,
                 destination,
                 db_connection):
        BasicEngine.__init__(self,
                             stomp_connection,
                             tellme,
                             destination,
                             db_connection)

        # Create teams
        logger.info('creating teams...')
        self.create_team('paulproteus')
        self.create_team('jalonso')
Esempio n. 2
0
    def rpc_admin_event(self, event, team_id=None, ref=None, *params):
        """
        Handle a custom administrative action event
        """
        if team_id is not None:
            team_state = self.team_states.get(team_id, None)
            team_found = team_state is not None
        else:
            team_state = None
            team_found = None

        if event == 'raw_unlock':
            assert team_found, "Team must be found"
            team_state.unlock(*params)
        elif event == 'raw_relock':
            assert team_found, "Team must be found"
            team_state.relock(*params)
        elif event == 'save':
            return self.save_team_states()
        elif event == 'delay_start':
            assert len(params) == 1, "Need a start time in epoch ms"
            self.schedule_hunt(params[0])
        elif event == 'preview_all_team_status':
            return self.calculate_all_team_statuses()
        elif event == 'do_unlock':
            team_state = self.team_states[team_id]
            team_state.unlock_by_urls_not_refs(params)
        elif event == 'time_unlock':
            for team_id in self.team_states:
                state = self.team_states[team_id]
                state.perform_a_time_unlock()
        elif event == 'set_options':
            # Uses: team_id, Params: earned_options, timed_options
            team_state.earned_options = params[0]
            team_state.timed_options = params[1]
            self.announce_update('team',
                    self.rpc_get_team_state_report(team_id))
            self.save_team_states()
        elif event == 'create_team':
            # User: team_id, Params: fullname, default_callback,
            # [earned_options, [timed_options]]
            assert team_state is None, "Team must not already exist"
            self.create_team(team_id)
            team_state = self.team_states[team_id]
            if len(params) >= 3:
                team_state.earned_options = params[2]
            if len(params) == 4:
                team_state.timed_options = params[3]
            team_state.set_data(fullname=params[0],
                                default_callback=params[1],
                                team_id=team_id)
        else:
            return BasicEngine.rpc_admin_event(self, event, team_id, ref, *params)
Esempio n. 3
0
    def __init__(self, stomp_connection,
                 tellme,
                 destination,
                 db_connection,
                 db_name):
        BasicEngine.__init__(self,
                             stomp_connection,
                             tellme,
                             destination,
                             db_connection,
                             db_name)

        # Jason's code has us provide a hunt_ctx.
        # The only thing I can think to put here is the hunt start time.
        # but maybe even that's not needed.

        # self.team_states is a dict mapping from team_id to some
        # internal concept of what the team state is.
        # It is created by the parent class.

        # Create teams
        logger.info('creating teams...')
        self.create_teams_from_json_list(json.load(
                open(os.path.join(HERE, 'team-snapshot.json'))))