Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'bot' referenced before assignment #2598

Closed
elicwhite opened this issue Aug 4, 2016 · 12 comments
Closed

Comments

@elicwhite
Copy link
Contributor

https://app.getsentry.com/pokemongof/pokemongo-bot/issues/147423678/

UnboundLocalError: local variable 'bot' referenced before assignment
  File "pokecli.py", line 490, in <module>
    main()
  File "pokecli.py", line 125, in main
    report_summary(bot)

UnboundLocalError: local variable 'bot' referenced before assignment
@hexablob
Copy link

hexablob commented Aug 5, 2016

Same problem here.
python pokecli.py -cf config.json works in command-line, but same command through PHP, returns ;

2016-08-05 09:11:02,463 [requests.packages.urllib3.connectionpool] [INFO] Starting new HTTP connection (1): www.google-analytics.com
Traceback (most recent call last):
  File "/home/www/pokemongoup/app/Libraries/PokemonGo-Bot/pokecli.py", line 495, in <module>
    main()
  File "/home/www/pokemongoup/app/Libraries/PokemonGo-Bot/pokecli.py", line 128, in main
    if bot:
UnboundLocalError: local variable 'bot' referenced before assignment

Both runs goes through the same OS. One by root (cli), other by www-data.

OS : Debian 8
Can you something about @TheSavior ? would save my life.

@aasensiog
Copy link

Same error on MAC OS X

@sknutseen
Copy link

anyone know how to fix this?

@lt-kraken
Copy link

lt-kraken commented Aug 5, 2016

Having the same issue.


Turned out I had an error in my config.json, fixed the error and the bot started working again :)

@EvilSupahFly
Copy link

EvilSupahFly commented Aug 5, 2016

I'm getting this error now. What was the error in your config.json? Mine looks OK to me, but I am clearly missing something, and not sure what to look for.

I ran my config.json through http://jsonlint.com/ and it says it's valid, but I still get the error.

@lt-kraken
Copy link

I had a missing comma on the 'any' line, example:

"release": {
      "any": { "keep_best_iv": 1, "release_below_iv": 0.9, "release_below_cp": 300, "logic": "or" }

      "// Legendary pokemons (Goes under S-Tier)": {},
      "Lapras": { "release_below_cp": 1041, "release_below_iv": 0.8, "logic": "and" },
      "Moltres": { "release_below_cp": 1132, "release_below_iv": 0.8, "logic": "and" },
      "Zapdos": { "release_below_cp": 1087, "release_below_iv": 0.8, "logic": "and" },
      "Articuno": { "release_below_cp": 1039, "release_below_iv": 0.8, "logic": "and" }
}

@EvilSupahFly
Copy link

EvilSupahFly commented Aug 5, 2016

Here's what I have. http://jsonlint.com/ says it's fine, but obviously not:

{
    "auth_service":"google",
    "username":"[email protected]",
    "password":"my-password",
    "location":"9 Main Street, St. Catharines, ON",
    "gmapkey":"my-map-key",
    "tasks":[
        {
            "type":"HandleSoftBan"
        },
        {
            "type":"CollectLevelUpReward"
        },
        {
            "type":"IncubateEggs",
            "config":{
                "longer_eggs_first":true
            }
        },
        {
            "type":"TransferPokemon"
        },
        {
            "type":"EvolvePokemon",
            "config":{
                "evolve_all":"none",
                "first_evolve_by":"cp",
                "evolve_above_cp":500,
                "evolve_above_iv":0.8,
                "logic":"or",
                "evolve_speed":20,
                "use_lucky_egg":false
            }
        },
        {
            "type":"RecycleItems",
            "config":{
                "item_filter":{
                    "Pokeball":{
                        "keep":100
                    },
                    "Potion":{
                        "keep":10
                    },
                    "Super Potion":{
                        "keep":20
                    },
                    "Hyper Potion":{
                        "keep":30
                    },
                    "Revive":{
                        "keep":30
                    },
                    "Razz Berry":{
                        "keep":100
                    }
                }
            }
        },
        {
            "type":"CatchVisiblePokemon"
        },
        {
            "type":"CatchLuredPokemon"
        },
        {
            "type":"SpinFort"
        },
        {
            "type":"MoveToFort",
            "config":{
                "lure_attraction":true,
                "lure_max_distance":2000
            }
        },
        {
            "type":"FollowSpiral",
            "config":{
                "diameter":4,
                "step_size":70
            }
        }
    ],
    "map_object_cache_time":5,
    "forts":{
        "avoid_circles":true,
        "max_circle_size":50
    },
    "websocket_server":false,
    "walk":4.14,
    "action_wait_min":1,
    "action_wait_max":4,
    "debug":false,
    "test":false,
    "health_record":true,
    "location_cache":true,
    "distance_unit":"km",
    "reconnecting_timeout":15,
    "evolve_captured":"NONE",
    "catch_randomize_reticle_factor":1.0,
    "catch_randomize_spin_factor":1.0,
    "catch":{
        "any":{
            "catch_above_cp":99,
            "catch_above_iv":0.8,
            "logic":"or"
        },
        "Eevee":{
            "always_catch":true
        }
    },
    "release":{
        "any":{
            "release_below_cp":0,
            "release_below_iv":0,
            "logic":"or"
        }
    },
    "vips":{
        "any":{
            "catch_above_cp":1200,
            "catch_above_iv":0.9,
            "logic":"or"
        },
        "Lapras":{

        },
        "Moltres":{

        },
        "Zapdos":{

        },
        "Articuno":{

        },
        "Mewtwo":{

        },
        "Dragonite":{

        },
        "Snorlax":{

        },
        "Mew":{

        },
        "Arcanine":{

        },
        "Vaporeon":{

        },
        "Gyarados":{

        },
        "Exeggutor":{

        },
        "Muk":{

        },
        "Weezing":{

        },
        "Flareon":{

        }
    }
}

@EvilSupahFly
Copy link

Running dev commit 90e5628 with Python 2.7.10 on Ubuntu Linux 15.10 x64

@lt-kraken
Copy link

lt-kraken commented Aug 5, 2016

Could try to delete these pokemon with empty settings, such as Flareon. Might be that the bot checks if a pokemon name is provided, and if so, checks its settings... which you haven't defined :)

@elicwhite
Copy link
Contributor Author

This error occurs when something keeps the bot from starting up, which causes an exception, and in the exception handler we read from the bot variable which isn't defined yet (because we failed to construct it). Any failures related to the config is just part of it failing to construct but unrelated to the real issue.

@EvilSupahFly
Copy link

Actually, it was because I had Google Analytics blocked in /etc/hosts as a
potential ad/tracking server

On Aug 5, 2016 16:00, "Eli White" [email protected] wrote:

This error occurs when something keeps the bot from starting up, which
causes an exception, and in the exception handler we read from the bot
variable which isn't defined yet (because we failed to construct it). Any
failures related to the config is just part of it failing to construct but
unrelated to the real issue.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#2598 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADIPzgHyXzXGA0RDBLpnKfDLre9rBTMyks5qc5ZSgaJpZM4Jc-PY
.

@hexablob
Copy link

hexablob commented Aug 5, 2016

@EvilSupahFly Don't think its related to the real issue. Mine is occuring when i execute the bot from PHP. When I use it in command-line, it works perfectly.

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

No branches or pull requests

7 participants