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

File "pokecli.py", line 493, in <module> main() File "pokecli.py", line 126, in main if bot:

Open helloitu opened this issue 10 years ago • 14 comments

Expected Behavior

Actual Behavior

2016-08-07 03:36:27,249 [ cli] [INFO] PokemonGO Bot v1.0 Traceback (most recent call last): File "pokecli.py", line 493, in main() File "pokecli.py", line 126, in main if bot: UnboundLocalError: local variable 'bot' referenced before assignment

Steps to Reproduce

Other Information

OS: Git Commit: (run 'git log -n 1 --pretty=format:"%H"' and paste it here) Python Version: (run 'python -V' and paste it here)

helloitu avatar Aug 07 '16 06:08 helloitu

Try with a fresh config.json and edit only the stuff you need at the top of the file. I've had the issue before but have found that it was likely caused because i botched the json file.

ColdSunERA avatar Aug 07 '16 06:08 ColdSunERA

Paste your json file into here:

http://jsonlint.com/

It will show you where you have mis-matched braces. Possible a missing comma or brace.

MikeDX avatar Aug 07 '16 06:08 MikeDX

@MikeDX , solved because "," thx <3

helloitu avatar Aug 07 '16 06:08 helloitu

@MikeDX I actually am having that same problem, and when I used the jsonlint.com it told me that my username is causing a parsing error. Any idea on how to remedy? I've tried using a fresh json.

congochicken avatar Aug 07 '16 07:08 congochicken

Paste the offending part here or on pastebin, I'll see if I can help :)

MikeDX avatar Aug 07 '16 07:08 MikeDX

@MikeDX

The highlighted line is "username": “congochicken @gmail.com”, and the exact error on JSONLint reads

Error: Parse error on line 3: ...ogle", "username": “congochicken @gmail ----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

congochicken avatar Aug 07 '16 08:08 congochicken

i have the same problem error message:

2016-08-07 20:02:16,775 [       cli] [INFO] PokemonGO Bot v1.0
2016-08-07 20:02:16,775 [       cli] [INFO] No config argument specified, checking for /configs/config.json
2016-08-07 20:02:16,776 [       cli] [INFO] Configuration initialized
2016-08-07 20:02:16,776 [pokemongo_bot.health_record.bot_event] [INFO] Health check is enabled. For more logrmation:
2016-08-07 20:02:16,776 [pokemongo_bot.health_record.bot_event] [INFO] https://github.com/PokemonGoF/PokemonGo-Bot/tree/dev#analytics
2016-08-07 20:02:16,782 [requests.packages.urllib3.connectionpool] [INFO] Starting new HTTP connection (1): www.google-analytics.com
Traceback (most recent call last):
  File "pokecli.py", line 499, in <module>
    main()
  File "pokecli.py", line 127, in main
    if bot:
UnboundLocalError: local variable 'bot' referenced before assignment
2016-08-07 20:02:16,822 [sentry.errors] [ERROR] Sentry responded with an error: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (url: https://app.getsentry.com/api/90254/store/)
Traceback (most recent call last):
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/raven/transport/threaded.py", line 174, in send_sync
    super(ThreadedHTTPTransport, self).send(data, headers)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send
    ca_certs=self.ca_certs,
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/raven/utils/http.py", line 66, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 494, in open
    response = self._open(req, data)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 512, in _open
    '_open', req)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open
    return self.do_open(ValidHTTPSConnection, req)
  File "/Users/alex/Dropbox/projects/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 1284, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 895, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128)
2016-08-07 20:02:16,823 [sentry.errors.uncaught] [ERROR] [u"UnboundLocalError: local variable 'bot' referenced before assignment", u'  File "pokecli.py", line 499, in <module>', u'  File "pokecli.py", line 127, in main']
Process crashed with exit code 1.  Respawning..

jsonlint says it's valid:

{
    "auth_service": "google",
    "username": "xxx",
    "password": "xxx",
    "location": "xxx",
    "gmapkey": "xxx",
    "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.16,
    "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": 0, "catch_above_iv": 0, "logic": "or"}
    },
    "release": {
      "Eevee": {"keep_best_iv": 20},
      "Weedle": {"keep_best_iv": 50},
      "Rattata": {"keep_best_iv": 50},
      "Golbat": {"keep_best_iv": 1},
      "Kakuna": {"keep_best_iv": 1},
      "Pidgeot": {"keep_best_iv": 1},
      "Pidgeotto": {"keep_best_iv": 1},
      "Pidgey": {"keep_best_iv": 50},
      "Zubat": {"keep_best_iv": 50},
      "Raticate": {"keep_best_iv": 1},
      "any": {"keep_best_iv": 3}
    },
    "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": {},
      "Pikachu": {},
      "Flareon": {}
    }
}

commit: 85f7607c6fbc7e4b13dc370877f01f45c5e241af os x 10.11.4

DmitryStolyarow avatar Aug 07 '16 08:08 DmitryStolyarow

That is bizarre.

If I paste that json, and put in your email, it validates.

Probably worth mentioning you dont need the @gmail.com bit in the username anyway (I've never used it)

MikeDX avatar Aug 07 '16 08:08 MikeDX

@MikeDX Thanks for the help anyways. It's so strange, even just the word by itself results in a parse error on json

congochicken avatar Aug 07 '16 08:08 congochicken

Using the following json seems to work:

{
    "auth_service": "google",
    "username": "congochicken",
    "password": "xxx",
    "location": "xxx",
    "gmapkey": "xxx",
    "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.16,
    "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": 0,
            "catch_above_iv": 0,
            "logic": "or"
        }
    },
    "release": {
        "Eevee": {
            "keep_best_iv": 20
        },
        "Weedle": {
            "keep_best_iv": 50
        },
        "Rattata": {
            "keep_best_iv": 50
        },
        "Golbat": {
            "keep_best_iv": 1
        },
        "Kakuna": {
            "keep_best_iv": 1
        },
        "Pidgeot": {
            "keep_best_iv": 1
        },
        "Pidgeotto": {
            "keep_best_iv": 1
        },
        "Pidgey": {
            "keep_best_iv": 50
        },
        "Zubat": {
            "keep_best_iv": 50
        },
        "Raticate": {
            "keep_best_iv": 1
        },
        "any": {
            "keep_best_iv": 3
        }
    },
    "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": {},
        "Pikachu": {},
        "Flareon": {}
    }
}

Well I say work. it validates...

MikeDX avatar Aug 07 '16 08:08 MikeDX

setting health_record to false solved the problem. hope it will help someone cheers

DmitryStolyarow avatar Aug 07 '16 08:08 DmitryStolyarow

@MikeDX Not sure what you changed but you're my hero regardless. Have a great night, if we ever meet I'll buy you a drink.

congochicken avatar Aug 07 '16 08:08 congochicken

Hey @MikeDX ! I'm also having the same issue, with every entry into the username field resulting in a parsing error on JSONLINT and causing the same Unbound Error output. If you could assist me the way you did above that would be awesome. If relevant: OSX El Capitan b5b3e7048b4d28f8fa5984dc92c54745db82f75f Python 2.7.12

fglo11 avatar Aug 07 '16 20:08 fglo11

@fglo11 Can you try using the json I pasted above and replacing congochicken with your username?

Also what are you using to edit the files? Maybe your text editor is doing something strange to the quotes.

MikeDX avatar Aug 07 '16 21:08 MikeDX