-
Notifications
You must be signed in to change notification settings - Fork 4
/
gymlist.py
57 lines (49 loc) · 1.99 KB
/
gymlist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import asyncio
import logging
from accounts3 import AsyncAccountManager
from argparser import std_config, add_system_id, setup_default_app, add_use_account_db, add_search_rest
from behaviours import beh_do_process_single_gmo_gym
from geofence import get_geofences
from geography import step_position
from getmapobjects import find_gym, inrange_gyms
from gymdbsql import all_gyms
from mapelement_tools import add_altitudes
from mapelements import GymElement
from pogoservice import TravelTime2
from workers import wrap_account
parser = std_config("gymscanner")
add_search_rest(parser)
add_system_id(parser)
add_use_account_db(parser)
args = parser.parse_args()
args.system_id="dev-test"
loop = asyncio.get_event_loop()
setup_default_app(args, loop)
log = logging.getLogger(__name__)
queue = []
allgyms = all_gyms()
fences = get_geofences("geofence.txt", ["OsloInnenforRing3"])
filtered = fences.filter_map_elements(allgyms)
add_altitudes(filtered, args.gmaps_key)
elements = GymElement.from_db_rows(filtered)
async def start():
missing_name = [x for x in elements if not x.name]
if len(missing_name) > 0:
account_manager = await AsyncAccountManager.create_standard(args, loop)
account = await account_manager.get_account()
worker = wrap_account(account, account_manager)
travel_time = worker.getlayer(TravelTime2)
travel_time.use_fast_speed()
for missing in missing_name:
gym_pos= step_position(missing.coords, -1, 1)
map_objects = worker.do_get_map_objects(gym_pos)
gyms = inrange_gyms(map_objects, gym_pos)
fort = find_gym(gyms, missing.id)
if fort:
beh_do_process_single_gmo_gym(worker, fort, gym_pos)
else:
log.info("Gym {} not found in real map data".format(str(missing)))
log.info("Gym names updated, re-run")
exit(-1)
for elem in elements:
print("{};{};{};{}".format(elem.name, elem.as_map_link(), elem.coords[0], elem.coords[1]))