def print_scouts(lines, state, scouts): def scout_line(current_line, s): if have_proxies(): return line_tmpl.format(current_line, s.username, s.proxy, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) else: return line_tmpl.format(current_line, s.username, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) len_username = str( reduce(lambda l1, l2: max(l1, l2), map(lambda s: len(s.username), scouts))) len_num = str(len(str(len(scouts)))) if have_proxies(): line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:25} | {:10} | {:5} | {:14} | {}' lines.append( line_tmpl.format('#', 'Scout', 'Proxy', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) else: line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:10} | {:5} | {:14} | {}' lines.append( line_tmpl.format('#', 'Scout', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) return print_lines(lines, scout_line, scouts, 4, state)
def print_scouts(lines, state, scouts): def scout_line(current_line, s): warn = s.player_state.get('warn') warn_str = '' if warn is None else ('Yes' if warn else 'No') active = 'Yes' if s.active else 'No' if have_proxies(): return line_tmpl.format(current_line, s.username, s.proxy_url, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) else: return line_tmpl.format(current_line, s.username, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) len_username = str( reduce(lambda l1, l2: max(l1, l2), map(lambda s: len(s.username), scouts))) len_num = str(len(str(len(scouts)))) if have_proxies(): line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:25} | {:4} | {:6} | {:10} | {:5} | {:14} | {}' lines.append( line_tmpl.format('#', 'Scout', 'Proxy', 'Warn', 'Active', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) else: line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:4} | {:6} | {:10} | {:5} | {:14} | {}' lines.append( line_tmpl.format('#', 'Scout', 'Warn', 'Active', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) return print_lines(lines, scout_line, scouts, 4, state)
def print_scouts(lines, state, scouts): def scout_line(current_line, s): warn = s.player_state.get('warn') warn_str = '' if warn is None else ('Yes' if warn else 'No') active = 'Yes' if s.active else 'No' if s.uses_proxy(): return line_tmpl.format(current_line, s.username, s.proxy_url, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) else: return line_tmpl.format(current_line, s.username, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) len_username = str(reduce(lambda l1, l2: max(l1, l2), map(lambda s: len(s.username), scouts))) len_num = str(len(str(len(scouts)))) if have_proxies(): line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:25} | {:4} | {:6} | {:10} | {:5} | {:14} | {}' lines.append( line_tmpl.format('#', 'Scout', 'Proxy', 'Warn', 'Active', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) else: line_tmpl = u'{:' + len_num + '} | {:' + len_username + '} | {:4} | {:6} | {:10} | {:5} | {:14} | {}' lines.append(line_tmpl.format('#', 'Scout', 'Warn', 'Active', 'Encounters', 'Enc/h', 'Last Encounter', 'Message')) return print_lines(lines, scout_line, scouts, 4, state)
def __init__(self, auth, username, password, job_queue): self.auth = auth self.username = username self.password = password self.job_queue = job_queue # Stats self.last_request = None self.previous_encounter = None self.last_msg = "" self.total_encounters = 0 # Things needed for requests self.inventory_timestamp = None # Collects the last few pauses between encounters to measure a "encounters per hour" value self.past_pauses = deque() self.encounters_per_hour = float(0) # instantiate pgoapi self.api = PGoApi() self.api.activate_hash_server(cfg_get('hash_key')) if have_proxies(): self.proxy = get_new_proxy() self.log_info("Using Proxy: {}".format(self.proxy)) self.api.set_proxy({ 'http': self.proxy, 'https': self.proxy })
def scout_line(current_line, s): if have_proxies(): return line_tmpl.format(current_line, s.username, s.proxy, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) else: return line_tmpl.format(current_line, s.username, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg)
def scout_line(current_line, s): warn = s.player_state.get('warn') warn_str = '' if warn is None else ('Yes' if warn else 'No') active = 'Yes' if s.active else 'No' if have_proxies(): return line_tmpl.format(current_line, s.username, s.proxy_url, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg) else: return line_tmpl.format(current_line, s.username, warn_str, active, s.total_encounters, "{:5.1f}".format(s.encounters_per_hour), hr_tstamp(s.previous_encounter), s.last_msg)