Beispiel #1
0
 def execute(self):
     while True:
         last_match_seq_num = self.__get_last_match_seq_num()
         try:
             matches = api.get_matches_seq(last_match_seq_num)
             last_match = None
             for match in matches['matches']:
                 accounts_ids = [p.get('account_id') for p in match['players'] if p.get('account_id', -1)]
                 tasks.download_match_if_interested(match['match_id'], match['match_seq_num'], accounts_ids)
                 LAST_MATCH_SEQ_NUM.set_value(match['match_seq_num'])
                 last_match = match
             len_matches = len(matches['matches'])
             LOGGER.info('last match id: ' + str(last_match['match_id']) + ' seq num: ' + str(last_match_seq_num) +
                         ' matches retrieved: ' + str(len_matches))
             if len_matches < 70:
                 time.sleep(4)
         except Exception, e:
             print e
             LOGGER.exception(e)
             if e.message == 'Error retrieving match data.' or \
                     (hasattr(e, 'msg') and e.msg == 'Error retrieving match data.'):
                 LAST_MATCH_SEQ_NUM.set_value(long(last_match_seq_num) + 1)
Beispiel #2
0
 def __get_last_match_seq_num(self):
     last_match_seq_num = LAST_MATCH_SEQ_NUM.value()
     if last_match_seq_num is None:
         LAST_MATCH_SEQ_NUM.set_value(api.get_match_history(None)['matches'][0]['match_seq_num'])
         last_match_seq_num = LAST_MATCH_SEQ_NUM.value()
     return last_match_seq_num