本文整理汇总了Python中pgoapi.utilities.get_cell_ids方法的典型用法代码示例。如果您正苦于以下问题:Python utilities.get_cell_ids方法的具体用法?Python utilities.get_cell_ids怎么用?Python utilities.get_cell_ids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgoapi.utilities
的用法示例。
在下文中一共展示了utilities.get_cell_ids方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_close_cells
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def find_close_cells(self, lat, lng):
cellid = get_cell_ids(lat, lng)
timestamp = [0, ] * len(cellid)
response_dict = self.get_map_objects(lat, lng, timestamp, cellid)
map_objects = response_dict.get(
'responses', {}
).get('GET_MAP_OBJECTS', {})
status = map_objects.get('status', None)
map_cells = []
if status and status == 1:
map_cells = map_objects['map_cells']
position = (lat, lng, 0)
map_cells.sort(
key=lambda x: distance(
lat,
lng,
x['forts'][0]['latitude'],
x['forts'][0]['longitude']) if x.get('forts', []) else 1e6
)
return map_cells
示例2: req_get_map_objects
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def req_get_map_objects(self):
"""Scans current account location."""
# Make sure that we don't hammer with GMO requests
diff = self._last_gmo + self.cfg['scan_delay'] - time.time()
if diff > 0:
time.sleep(diff)
# Jitter if wanted
if self.cfg['jitter_gmo']:
lat, lng = jitter_location(self.latitude, self.longitude)
else:
lat, lng = self.latitude, self.longitude
cell_ids = get_cell_ids(lat, lng)
timestamps = [0, ] * len(cell_ids)
responses = self.perform_request(
lambda req: req.get_map_objects(latitude=f2i(lat),
longitude=f2i(lng),
since_timestamp_ms=timestamps,
cell_id=cell_ids),
get_inbox=True
)
self._last_gmo = self._last_request
return responses
示例3: scan
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def scan(self):
ScanMetrics.NUM_STEPS = len(self.scan_config.COVER)
log.info("Starting scan of {} locations".format(ScanMetrics.NUM_STEPS))
for i, next_pos in enumerate(self.next_position()):
log.debug('Scanning step {:d} of {:d}.'.format(i, ScanMetrics.NUM_STEPS))
log.debug('Scan location is {:f}, {:f}'.format(next_pos[0], next_pos[1]))
# TODO: Add error throttle
cell_ids = get_cell_ids(next_pos[0], next_pos[1], radius=70)
timestamps = [0, ] * len(cell_ids)
self.api.get_map_objects(
latitude=f2i(next_pos[0]),
longitude=f2i(next_pos[1]),
cell_id=cell_ids,
since_timestamp_ms=timestamps,
position=next_pos,
callback=Scanner.callback)
while not self.api.is_work_queue_empty():
# Location change
if self.scan_config.RESTART:
log.info("Restarting scan")
self.api.empty_work_queue()
else:
time.sleep(2)
#self.api.wait_until_done() # Work queue empty != work done
示例4: _get_cell_id_from_latlong
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def _get_cell_id_from_latlong(self, radius=1000):
# type: (Optional[int]) -> List[str]
position_lat, position_lng, _ = self.api_wrapper.get_position()
cells = get_cell_ids(position_lat, position_lng, radius)
if self.config['debug']:
self._log('Cells:', color='yellow')
self._log('Origin: {},{}'.format(position_lat, position_lng), color='yellow')
for cell in cells:
cell_id = CellId(cell)
lat_lng = cell_id.to_lat_lng()
self._log('Cell : {},{}'.format(lat_lng.lat().degrees, lat_lng.lng().degrees), color='yellow')
return cells
示例5: get_map_objects
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def get_map_objects(self):
time.sleep(1)
cell_id = utilities.get_cell_ids(self.lat, self.lng)
timestamp = [0, ] * len(cell_id)
map_dict = self.api.get_map_objects(
latitude = self.lat,
longitude = self.lng,
since_timestamp_ms = timestamp,
cell_id = cell_id
)
map_objects = map_dict.get(
'responses', {}
).get('GET_MAP_OBJECTS', {})
status = map_objects.get('status', None)
map_cells = []
if status and status == 1:
map_cells = map_objects['map_cells']
map_cells.sort(
key=lambda x: gpxpy.geo.haversine_distance(
self.lat,
self.lng,
x['forts'][0]['latitude'],
x['forts'][0]['longitude']
) if x.get('forts', []) else 1e6
)
return map_cells
示例6: send_map_request
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def send_map_request (self, user, position):
try:
cell_ids = util.get_cell_ids(position[0], position[1])
user._last_call = time.time()
timestamps = [0,] * len(cell_ids)
return user.get_map_objects(
latitude=util.f2i(position[0]),
longitude=util.f2i(position[1]),
since_timestamp_ms=timestamps,
cell_id=cell_ids
)
except ServerSideAccessForbiddenException as e:
logging.info("User {} or IP might be banned, attempting recovery...".format(user._data["username"]))
with self._lock:
now = time.time()
if now - self._last_vpn_retry >= self._delay_between_vpn_retries:
self._last_vpn_retry = now
if self._num_vpn_retries < self._max_vpn_retries_before_switch:
logging.info("Restarting vpn ({} times so far)".format(self._num_vpn_retries))
subprocess.call([self._restart_vpn_file])
self._num_vpn_retries += 1
else:
logging.info("Restarted vpn too many times. Switching to a different vpn now")
subprocess.call([self._switch_vpn_file])
self._num_vpn_retries = 0
# we can hold the lock for a bit during re-auth since there's
# no point in retrying in other threads in the meantime
self.auth_users()
except Exception as e:
logging.info("Uncaught exception when downloading map: {}".format(e))
return False
示例7: scan
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def scan(self):
ScanMetrics.NUM_STEPS = len(self.scan_config.COVER)
log.info("Starting scan of {} locations".format(ScanMetrics.NUM_STEPS))
for i, next_pos in enumerate(self.next_position()):
log.debug('Scanning step {:d} of {:d}.'.format(i, ScanMetrics.NUM_STEPS))
log.debug('Scan location is {:f}, {:f}'.format(next_pos[0], next_pos[1]))
time.sleep(args.delay/1000.0)
# TODO: Add error throttle
cell_ids = get_cell_ids(next_pos[0], next_pos[1], radius=70)
timestamps = [0, ] * len(cell_ids)
self.api.get_map_objects(
latitude=f2i(next_pos[0]),
longitude=f2i(next_pos[1]),
cell_id=cell_ids,
since_timestamp_ms=timestamps,
position=next_pos,
callback=Scanner.callback)
self.api.download_remote_config_version(position=next_pos, platform = 1, app_version = 5500, callback=Scanner.callback2)
while not self.api.is_work_queue_empty():
# Location change
if self.scan_config.RESTART:
log.info("Restarting scan")
self.api.empty_work_queue()
else:
time.sleep(2)
#self.api.wait_until_done() # Work queue empty != work done
示例8: main
# 需要导入模块: from pgoapi import utilities [as 别名]
# 或者: from pgoapi.utilities import get_cell_ids [as 别名]
def main():
# log settings
# log format
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
# log level for http request class
logging.getLogger("requests").setLevel(logging.WARNING)
# log level for main pgoapi class
logging.getLogger("pgoapi").setLevel(logging.INFO)
# log level for internal pgoapi class
logging.getLogger("rpc_api").setLevel(logging.INFO)
config = init_config()
if not config:
return
if config.debug:
logging.getLogger("requests").setLevel(logging.DEBUG)
logging.getLogger("pgoapi").setLevel(logging.DEBUG)
logging.getLogger("rpc_api").setLevel(logging.DEBUG)
# instantiate pgoapi
api = pgoapi.PGoApi()
# parse position
position = util.get_pos_by_name(config.location)
if not position:
log.error('Your given location could not be found by name')
return
elif config.test:
return
# set player position on the earth
api.set_position(*position)
# new authentication initialitation
api.set_authentication(provider = config.auth_service, username = config.username, password = config.password)
# provide the path for your encrypt dll
api.activate_signature("encrypt.dll")
# print get maps object
cell_ids = util.get_cell_ids(position[0], position[1])
timestamps = [0,] * len(cell_ids)
response_dict = api.get_map_objects(latitude =position[0], longitude = position[1], since_timestamp_ms = timestamps, cell_id = cell_ids)
print('Response dictionary (get_player): \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict)))