Ejemplo n.º 1
0
def configc():
    """
    Gets the settings for the Google Maps via REST
    """
    from app import conf
    config = conf()
    zoom = conf().get('ZOOM')

    p = flask.request.url.split("?")[1].replace("p=", "").split(",")
    if len(p) == 2:
        x, y = p
    elif len(p) == 3:
        x, y, zoom = p

        # 古いver対応
        if "z" in zoom:
            zoom = 18
    else:
        x = config.get('LAT')
        y = config.get('LON')

    center = {
        'lat': x,
        'lng': y,
        'zoom': int(zoom),
        'identifier': "fullmap"
    }
    return json.dumps(center)
Ejemplo n.º 2
0
def config():
    """ Gets the settings for the Google Maps via REST"""
    from app import conf
    config = conf()
    origin_lat = conf().get('LAT')
    origin_lon = conf().get('LON')
    zoom = conf().get('ZOOM')
    center = {
        'lat': origin_lat,
        'lng': origin_lon,
        'zoom': zoom,
        'identifier': "fullmap"
    }
    return json.dumps(center)
Ejemplo n.º 3
0
def raremap():
    # clear_stale_pokemons()
    from app import conf
    key = get_google_map_api(conf())
    fullmap, fullmap_js = get_map()
    config = conf()
    zoom = conf().get('ZOOM')
    return render_template(
            'rare_fullmap.html',
            key=key,
            zoom=zoom,
            GOOGLEMAPS_KEY=key,
            fullmap=fullmap,
            fullmap_js=fullmap_js,
            auto_refresh=conf().get('AUTO_REFRESH'))
Ejemplo n.º 4
0
def fullmap(is_sp):
    # clear_stale_pokemons()
    from app import conf
    key = get_google_map_api(conf())
    fullmap, fullmap_js = get_map()
    config = conf()
    zoom = config.get('ZOOM')
    is_local = config.get('IS_LOCAL')
    is_maintenance = config.get('IS_MAINTENANCE')
    return render_template(
            'example_fullmap.html',
            key=key,
            zoom=zoom,
            GOOGLEMAPS_KEY=key,
            is_maintenance=is_maintenance,
            fullmap=fullmap,
            fullmap_js=fullmap_js,
            is_local=is_local,
            auto_refresh=conf().get('AUTO_REFRESH'),
            is_sp=is_sp,
    )
Ejemplo n.º 5
0
    def decorated_function(*args, **kwargs):
        """
        Viewにアクセス制限を掛けるデコレータ
        """
        if "credential" not in flask.request.url:
            return "Required Credential"

        from app import conf
        if conf()['CREDENTIAL'] not in flask.request.url:
            return "Wrong Credential Code"
        r = f(*args, **kwargs)
        return r
Ejemplo n.º 6
0
def get_client(point):
    key = "redis_client:{}".format(str(point))
    if not hasattr(tls_kvs, key):
        from app import conf
        config = conf()
        host = _get_redis_host(config, point)
        port = config.get('REDIS_PORT')
        db = point
        assert host, host
        assert port, port
        # print("redis db is {}: host:{} port:{}".format(db, host, port))
        setattr(tls_kvs, key, redis.Redis(host=host, port=port, db=db))
    return getattr(tls_kvs, key)
Ejemplo n.º 7
0
def get_map():
    from app import conf
    config = conf()
    origin_lat = config.get('LAT')
    origin_lon = config.get('LON')
    key = get_google_map_api(config)
    fullmap = Map(
        identifier="fullmap2",
        style='height:100%;width:100%;top:0;left:0;position:absolute;z-index:200;',
        lat=origin_lat,
        lng=origin_lon,
        markers=get_pokemarkers(),
        zoom='20')
    fullmap_js = Markup(
            fullmap.render(
                    'googlemaps/gmapjs.html',
                    gmap=fullmap,
                    DEFAULT_ICON=DEFAULT_ICON,
                    GOOGLEMAPS_KEY=key
            )
    )
    return fullmap, fullmap_js
Ejemplo n.º 8
0
    def get_from_url(cls, site):
        """
        urlからダウンロードする
        :param site: Site
        :return: list[cls]
        """
        response = requests.get(site.subjects_url)
        assert (response.status_code == 200), response.text

        # parse
        data = list(response.text.split('\n'))

        # generate Subject
        r = []
        for line in data:
            try:
                _ = cls(site, line)
                r.append(_)
            except:
                pass

        # 投稿数でsubjectをフィルタリング
        limit = conf().get('SCRAPING_LIMIT')
        return [_r for _r in r if _r.count_res >= limit]
Ejemplo n.º 9
0
    def get_from_url(cls, site):
        """
        urlからダウンロードする
        :param site: Site
        :return: list[cls]
        """
        response = requests.get(site.subjects_url)
        assert (response.status_code == 200), response.text

        # parse
        data = list(response.text.split('\n'))

        # generate Subject
        r = []
        for line in data:
            try:
                _ = cls(site, line)
                r.append(_)
            except:
                pass

        # 投稿数でsubjectをフィルタリング
        limit = conf().get('SCRAPING_LIMIT')
        return [_r for _r in r if _r.count_res >= limit]
Ejemplo n.º 10
0
 def config(self):
     from app import conf
     return conf()
Ejemplo n.º 11
0
def main():
    full_path = os.path.realpath(__file__)
    (path, filename) = os.path.split(full_path)

    args = get_args(worker=True)
    locale = conf()

    print('[+] Locale is ' + args.locale)
    pokemonsJSON = json.load(
        open(path + '/locales/pokemon.' + args.locale + '.json'))

    if args.debug:
        global DEBUG
        DEBUG = True
        print '[!] DEBUG mode on'

    # only get location for first run
    if not (FLOAT_LAT and FLOAT_LONG):
        print('[+] Getting initial location')
        print(args.location)
        retrying_set_location(args.location)

    if args.auto_refresh:
        global auto_refresh
        auto_refresh = int(args.auto_refresh) * 1000

    if args.ampm_clock:
    	global is_ampm_clock
    	is_ampm_clock = True

    api_endpoint, access_token, profile_response = login(args)

    clear_stale_pokemons()

    steplimit = int(args.step_limit)

    ignore = []
    only = []
    if args.ignore:
        ignore = [i.lower().strip() for i in args.ignore.split(',')]
    elif args.only:
        only = [i.lower().strip() for i in args.only.split(',')]

    pos = 1
    x = 0
    y = 0
    dx = 0
    dy = -1
    steplimit2 = steplimit**2
    for step in range(steplimit2):
        #starting at 0 index
        debug('looping: step {} of {}'.format((step+1), steplimit**2))
        #debug('steplimit: {} x: {} y: {} pos: {} dx: {} dy {}'.format(steplimit2, x, y, pos, dx, dy))
        # Scan location math
        if -steplimit2 / 2 < x <= steplimit2 / 2 and -steplimit2 / 2 < y <= steplimit2 / 2:
            set_location_coords(x * 0.0025 + origin_lat, y * 0.0025 + origin_lon, 0)
        if x == y or x < 0 and x == -y or x > 0 and x == 1 - y:
            (dx, dy) = (-dy, dx)

        (x, y) = (x + dx, y + dy)

        process_step(args, api_endpoint, access_token, profile_response,
                     pokemonsJSON, ignore, only)

        print('Completed: ' + str(
            ((step+1) + pos * .25 - .25) / (steplimit2) * 100) + '%')

    global NEXT_LAT, NEXT_LONG
    if (NEXT_LAT and NEXT_LONG and
            (NEXT_LAT != FLOAT_LAT or NEXT_LONG != FLOAT_LONG)):
        print('Update to next location %f, %f' % (NEXT_LAT, NEXT_LONG))
        set_location_coords(NEXT_LAT, NEXT_LONG, 0)
        NEXT_LAT = 0
        NEXT_LONG = 0
    else:
        set_location_coords(origin_lat, origin_lon, 0)
Ejemplo n.º 12
0
def update_map(point):
    full_path = os.path.realpath(__file__)
    (path, filename) = os.path.split(full_path)
    from app import conf
    config = conf()
    lat, lon, message = POINTS[point]
    # PokemonGo-Map/locales/pokemon.en.json, maybe en
    locale = config.get("LOCALE")
    location = "{} {}".format(lat, lon)
    step_limit = config["STEP_LIMIT"]

    print('[+] Locale is ' + locale)
    pokemonsJSON = json.load(
        open(path + '/locales/pokemon.' + locale + '.json'))

    global DEBUG
    DEBUG = True
    print '[!] DEBUG mode on'

    # only get location for first run
    print('[+] Getting initial location')
    print(location)
    retrying_set_location(location)

    api_endpoint, access_token, profile_response = login(config, point)

    # 1回3分くらい
    for x in xrange(2):
        if x >= 1:
            time.sleep(10)

        # clear_stale_pokemons()

        ignore = []
        only = []

        pokemon_count = 0
        pos = 1
        x = 0
        y = 0
        dx = 0
        dy = -1
        # steplimit2 = int(step_limit**2 * float(1.5625))
        steplimit2 = 11 * 11
        for step in range(steplimit2):
            debug('looping: step {} of {}'.format((step+1), steplimit2))
            # debug('steplimit: {} x: {} y: {} pos: {} dx: {} dy {}'.format(steplimit2, x, y, pos, dx, dy))
            # Scan location math
            if -steplimit2 / 2 < x <= steplimit2 / 2 and -steplimit2 / 2 < y <= steplimit2 / 2:
                set_location_coords(x * 0.002 + lat, y * 0.002 + lon, 0)
            if x == y or x < 0 and x == -y or x > 0 and x == 1 - y:
                (dx, dy) = (-dy, dx)

            (x, y) = (x + dx, y + dy)

            pokemon_count += process_step(config, api_endpoint, access_token, profile_response,
                                          pokemonsJSON, ignore, only, point)

            print('Completed: ' + str(
                ((step+1) + pos * .2 - .2) / steplimit2 * 100) + '%')
            time.sleep(1)

        # for monitor
        update_pokemon_count(point, pokemon_count)

        # pokemonの数が0のときはアカウント切り替え
        if pokemon_count == 0:
            force_change_account(point)
            raise ValueError, "finish 81 area scan, but pokemon count is ZERO, so.. force switch account"
        else:
            print "total pokemon count is {}".format(pokemon_count)

        global NEXT_LAT, NEXT_LONG
        if (NEXT_LAT and NEXT_LONG and
                (NEXT_LAT != FLOAT_LAT or NEXT_LONG != FLOAT_LONG)):
            print('Update to next location %f, %f' % (NEXT_LAT, NEXT_LONG))
            set_location_coords(NEXT_LAT, NEXT_LONG, 0)
            NEXT_LAT = 0
            NEXT_LONG = 0
        else:
            set_location_coords(origin_lat, origin_lon, 0)
Ejemplo n.º 13
0
 def config(self):
     from app import conf
     return conf()