PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

UnboundLocalError: local variable 'bot' referenced before assignment

Open elicwhite opened this issue 10 years ago • 12 comments

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

elicwhite avatar Aug 04 '16 18:08 elicwhite

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.

hexablob avatar Aug 05 '16 07:08 hexablob

Same error on MAC OS X

aasensiog avatar Aug 05 '16 07:08 aasensiog

anyone know how to fix this?

sknutseen avatar Aug 05 '16 15:08 sknutseen

Having the same issue.


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

lt-kraken avatar Aug 05 '16 17:08 lt-kraken

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.

EvilSupahFly avatar Aug 05 '16 18:08 EvilSupahFly

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" }
}

lt-kraken avatar Aug 05 '16 19:08 lt-kraken

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 avatar Aug 05 '16 19:08 EvilSupahFly

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

EvilSupahFly avatar Aug 05 '16 19:08 EvilSupahFly

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 :)

lt-kraken avatar Aug 05 '16 19:08 lt-kraken

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.

elicwhite avatar Aug 05 '16 20:08 elicwhite

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 https://github.com/PokemonGoF/PokemonGo-Bot/issues/2598#issuecomment-237948311, or mute the thread https://github.com/notifications/unsubscribe-auth/ADIPzgHyXzXGA0RDBLpnKfDLre9rBTMyks5qc5ZSgaJpZM4Jc-PY .

EvilSupahFly avatar Aug 05 '16 20:08 EvilSupahFly

@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.

hexablob avatar Aug 05 '16 20:08 hexablob