FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fake Search: Get Pokemon data from code instead of Niantic servers by TomSirgedas · Pull Request #2023 · RocketMap/RocketMap · GitHub

Fake Search: Get Pokemon data from code instead of Niantic servers - #2023

Open
TomSirgedas wants to merge 2 commits into
RocketMap:developfrom
TomSirgedas:fake_search
Open

Fake Search: Get Pokemon data from code instead of Niantic servers#2023
TomSirgedas wants to merge 2 commits into
RocketMap:developfrom
TomSirgedas:fake_search

Conversation

TomSirgedas commented May 9, 2017
edited
Loading

Copy link
Copy Markdown

Edit: I don't expect to merge this as-is. I just wanted to share some code that was useful for me.
Update: Should be merge-able now

This PR lets you get Pokemon data from code instead of Niantic servers.

The code can be run with very few "real" inputs, just your Google API key.

How to run the code:
runserver.py -cf config/config.ini.example -k GMAPS_KEY -l 42.7,-84.5 -fss ./pogom/sample_fake_scripts/simpleDitto.py

This is the included example code, which generates Dittoes in a simple pattern:

def go(args):
    count = 0
    while True:
        time.sleep(3)
        fake_pokemon_objects = [{'pokemon_id': 132, # ditto
                                 'disappear_time': datetime.utcnow() + timedelta(seconds=15),
                                 'latitude': args.position[0],
                                 'longitude': args.position[1] + count*.0002}]
        count += 1
        args.add_pokemon(fake_pokemon_objects)

This is what the result looks like on http://localhost:5000/:

And in GIF format (13MB):
https://content.screencast.com/users/Tom/folders/Snagit/media/a1d73d1c-4c35-4916-883d-3723f7f03a4c/05.08.2017-22.10.GIF

TomSirgedas force-pushed the fake_search branch 2 times, most recently from 2771757 to 9fea941 Compare May 9, 2017 03:34
Comment thread runserver.py
search_thread = Thread(target=search_overseer_thread,
name='search-overseer', args=argset)
fake_pokemon_mode = True
if fake_pokemon_mode:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This always yields True, so you can practically throw away the else-block (and the whole if/else statement).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think that you need to add another command line switch for this as right now it only fakes data

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I agree, it's not integrated well right now. I just wanted a "self-documented" way to show how to switch the fake mode on/off.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

updated!

Copy link
Copy Markdown
Contributor

I don't really get what this PR does. So basically if this gets merged the map is completely useless because it will only run in fake search mode.

I assume that this PR wants to introduce some sort of debug/testing/demo mode to let RocketMap show Pokemon on a map without actual API requests (even fake ones). That might be in fact helpful for frontend developers but at least make it optional please. ;-)

Sk00DaT commented May 9, 2017

Copy link
Copy Markdown

This is an AWESOME pr if it does what i need it to .... would be awesome to fake any data off pokemons to test new code ....... IE we could of used this for form and im sure in future thier will be other new things

Copy link
Copy Markdown
Contributor

Nice idea but needs some love.
I don't now if it is needed to be part of the searcher code, just a script under the test folder could do the same.
Also adding proper support to push all pokemon data would be great add_fake_pokemon only takes some data.
The test data should be customizable, maybe passing the name of a script to import or something like that, ditto test as an example is great but I think that it is a need being able to create your custom test scripts without modifying the version controlled code.

Comment thread pogom/fakeSearcher.py Outdated
}

if pokemon:
db_updates_queue.put((Pokemon, pokemon))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

for a real fake, there needs to be the data for the webhook too. So users jump out of their chair when they see the 100% Mewtwo from PokeAlarm.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, this code doesn't handle webhooks, pokestops, gyms, etc, since I didn't need those. But, I wanted to share my work in case it was useful for others.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I updated the code to be merge-able, but there's no webhook support. I hope that's OK.

Copy link
Copy Markdown
Author

Thanks for the feedback guys!

This code was useful for myself, and I just wanted to share. It's not in a merge-able state for sure. I'm not sure how to do that, but @friscoMad has good ideas.

343334 commented May 9, 2017

Copy link
Copy Markdown
Contributor

Well looks like it has great potential to be used as a standalone server for multiple remote mysql servers where this map could accept incoming webhooks - and then display that data.

Copy link
Copy Markdown
Contributor

@343334 how about replication? :-D

343334 commented May 10, 2017

Copy link
Copy Markdown
Contributor

@aRengo Why should we depend on a mysql db any more than we need to? Most users tend to use the webhook features already so if RM had a way to run as a standalone server that accepts incomings POSTS to display the markers that would allow many local neighborhood scanners to team up together without much extra work as replication requires a lot of extra knowledge and configurations. With a standalone server to handle this on its own all it would require is users to add another webhook and than prob set the firewall to only allow incoming connections from other scanner ips on that port if they wish to team up. Much more user friendly and in theory should be less load than pulling data from mysql.

Copy link
Copy Markdown
Author

Hey @sebastienvercammen , any chance this could be merged? Please let me know if there's no chance or if there's something that you want. I think it opens up some possibilities, like collaborative maps (great idea, @343334 !)

SkOODaT commented May 20, 2017
edited
Loading

Copy link
Copy Markdown

i really like this feature for testing... any possibility it could be adapted to send the pokemon to webhooks too, ie again unown formatting, im trying to set this up currently and it would be of great help to be able to fake a spawn and/or an alert too
Works perfect tho....
Thank you

TomSirgedas and others added 2 commits May 22, 2017 21:58
generate fake dittoes in a basic pattern, as an example
new command-line parameter `-fss` specifies a script file that provides search data
updated docs
added some error checking

Copy link
Copy Markdown
Author

@SkOODaT
an attempt at supporting webhooks, let me know if this works or not:
TomSirgedas#2
for unowns, your script can provide 'form': 26 (in addition to the usual 'pokemon_id': 201, etc)

Copy link
Copy Markdown
Member

@TomSirgedas Sorry for the late reply, somehow the notification for your ping got lost and I've been swamped with shadowban/API work.

Yes, this definitely has a use case and will be merged if implemented properly. However, as it is, we can't merge yet.

This needs to be a completely stand-alone mode, separate from the main codebase, similar to how -mock does its thing. I'm not sure if -fss has any use for any other "fake search script" implementation than a single fake implementation that covers all use cases.

I understand the client/server example that you've added, but what are the advantages of this (more complex) implementation versus a single mock data mode that randomly adds Pokémon (customizable amount) of all types (start at Pokémon 1, increment, modulo to reset) with a single toggle rather than separate scripts?

Just curious about your thoughts. :)

Copy link
Copy Markdown
Author

Some use cases:

  • Want to test front end, just need some random pokemon
  • Want to test front end, lots of pokemon to stress test
  • Want to test front end, special scenarios, like showing unown with the proper letter, or doing something special for ultra-rares, etc.
  • Draw a pattern on the map using pokemon (silly)
  • Collaborative map -- your script would grab pokemon from multiple inputs
  • Make a map from a Discord feed. This was my project (with blessing from the admin). I needed the Discord scraper to be in a different process than RocketMap, so the client.py/listener.py was useful for me.
  • I'm sure there are more ideas!

Like frisco said:

The test data should be customizable, maybe passing the name of a script to import or something like that, ditto test as an example is great but I think that it is a need being able to create your custom test scripts without modifying the version controlled code.

So, re: "I'm not sure if -fss has any use for any other "fake search script" implementation than a single fake implementation that covers all use cases.", I think it's valuable to specify a script!

I'm not sure what "completely stand-alone mode, separate from the main codebase" means exactly. I want to use the existing database, classes, etc. Changes to the main code path are minimal, just checking if "fake_search_script" mode is on. (Though it seems that fake_pokemon_mode = True if fake_pokemon_mode: is still in the code, instead of checking the config variable :/)

Copy link
Copy Markdown
Author

@sebastienvercammen (bump)

Copy link
Copy Markdown
Contributor

I wouldn't have thought it, but this had use now, with broken hash servers.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL