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

Bot fails to start: UnicodeEncodeError 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) #3963

Closed
sunnytrail opened this issue Aug 15, 2016 · 2 comments

Comments

@sunnytrail
Copy link

Expected Behavior

Bot is able to start.

Actual Behavior

Bot fails to start.

The names of some monsters are specified by Japanese characters. I'm not sure but it might cause this error.

Your config.json (remove your credentials and any other private info)

{
    "auth_service": "google",
    "username": "xxx",
    "password": "xxx",
    "location": "xxx,xxx",
    "gmapkey": "xxx",
    "tasks": [
      {
        "type": "HandleSoftBan"
      },
      {
        "type": "CollectLevelUpReward"
      },
      {
        "type": "IncubateEggs",
        "config": {
          "longer_eggs_first": true
        }
      },
      {
        "type": "NicknamePokemon",
        "config": {
           "nickname_template": "{name:.8s}_{iv_pct}"
        }
      },
      {
        "type": "TransferPokemon"
      },
      {
        "type": "EvolvePokemon",
        "config": {
            "evolve_all": "none",
            "first_evolve_by": "iv",
            "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" : 110 },
            "Greatball":       { "keep" : 150 },
            "Ultraball":       { "keep" : 150 },
            "Potion":         { "keep" : 20 },
            "Super Potion":   { "keep" : 30 },
            "Hyper Potion":   { "keep" : 40 },
            "Revive":         { "keep" : 40 },
            "Razz Berry":     { "keep" : 120 }
          }
        }
      },
      {
        "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"},

      "// Example of always catching Rattata:": {},
      "// Rattata": { "always_catch" : true },

      "// Legendary pokemons (Goes under S-Tier)": {},
      "Lapras": { "always_catch": true },
      "Moltres": { "always_catch": true },
      "Zapdos": { "always_catch": true },
      "Articuno": { "always_catch": true },

      "// always catch": {},
      "Charmander": { "always_catch": true },
      "Squirtle": { "always_catch": true },
      "Pikachu": { "always_catch": true },
      "Eevee": { "always_catch": true },
      "Dragonite": { "always_catch": true },
      "Dragonair": { "always_catch": true },
      "Dratini": { "always_catch": true },

      "// never catch": {},
      "Caterpie": {"never_catch": true},
      "Weedle": {"never_catch": true},
      "Pidgey": {"never_catch": true},
      "Rattata": {"never_catch": true},
      "Psyduck": {"never_catch": true},
      "Slowpoke": {"never_catch": true}
    },
    "release": {
      "any": {"keep_best_iv": 2, "logic": "or"},
      "Exeggcutor": { "never_release" : true },
      "Gyarados": { "never_release" : true },
      "Lapras": { "never_release" : true },
      "Vaporeon": { "never_release" : true },
      "Jolteon": { "never_release" : true },
      "Flareon": { "never_release" : true },
      "Snorlax": { "never_release" : true },
      "Dragonite": { "never_release" : true },
      "// any": {"keep_best_cp": 2, "keep_best_iv": 2, "logic": "or"},
      "// any": {"release_below_cp": 0, "release_below_iv": 0, "logic": "or"},
      "// Example of always releasing Rattata:": {},
      "// Rattata": {"always_release": true},
      "// Example of keeping 3 stronger (based on CP) Pidgey:": {},
      "// Pidgey": {"keep_best_cp": 3},
      "// Example of keeping 2 stronger (based on IV) Zubat:": {},
      "// Zubat": {"keep_best_iv": 2},
      "// Also, it is working with any": {},
      "// any": {"keep_best_iv": 3},
      "// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
      "// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3}
    },
    "vips" : {
         "Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
        "any": {"catch_above_cp": 1200, "catch_above_iv": 0.9, "logic": "or" },
        "Lapras": {},
        "Moltres": {},
        "Zapdos": {},
        "Articuno": {},

        "// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
        "Mewtwo": {},
        "Dragonite": {},
        "Snorlax": {},
        "// Mew evolves to Mewtwo": {},
        "Mew": {},
        "Arcanine": {},
        "Vaporeon": {},
        "Gyarados": {},
        "Exeggutor": {},
        "Muk": {},
        "Weezing": {},
        "Flareon": {}

    }
}

Steps to Reproduce

2016-08-15 10:38:47,935 [ cli] [INFO] PokemonGO Bot v1.0
2016-08-15 10:38:47,936 [ cli] [INFO] No config argument specified, checking for /configs/config.json
2016-08-15 10:38:47,939 [ cli] [WARNING] The evolve_captured argument is no longer supported. Please use the EvolvePokemon task instead
2016-08-15 10:38:47,940 [ cli] [INFO] Configuration initialized
2016-08-15 10:38:47,940 [pokemongo_bot.health_record.bot_event] [INFO] Health check is enabled. For more information:
2016-08-15 10:38:47,940 [pokemongo_bot.health_record.bot_event] [INFO] https://github.com/PokemonGoF/PokemonGo-Bot/tree/dev#analytics
2016-08-15 10:38:47,945 [requests.packages.urllib3.connectionpool] [INFO] Starting new HTTP connection (1): www.google-analytics.com
2016-08-15 10:38:48,039 [PokemonGoBot] [INFO] [set_start_location] Setting start location.
2016-08-15 10:38:48,048 [PokemonGoBot] [INFO] [x] Coordinates found in passed in location, not geocoding.
2016-08-15 10:38:48,049 [PokemonGoBot] [INFO] [location_found] Location found: xxx, xxx (xxx,xxx, 0.0)
2016-08-15 10:38:48,049 [PokemonGoBot] [INFO] [position_update] Now at (xxx, xxx, 0)
2016-08-15 10:38:48,049 [PokemonGoBot] [INFO] [login_started] Login procedure started.
2016-08-15 10:38:50,020 [PokemonGoBot] [INFO] [login_successful] Login successful.
2016-08-15 10:38:52,387 [PokemonGoBot] [INFO]
2016-08-15 10:38:52,387 [PokemonGoBot] [INFO] --- sunnyfortune ---
2016-08-15 10:38:52,387 [PokemonGoBot] [INFO] Level: 24 (Next Level: 69740 XP) (Total: 640260 XP)
2016-08-15 10:38:52,387 [PokemonGoBot] [INFO] Pokemon Captured: 1688 | Pokestops Visited: 1917
2016-08-15 10:38:52,388 [PokemonGoBot] [INFO] Pokemon Bag: 194/250
2016-08-15 10:38:52,389 [PokemonGoBot] [INFO] Items: 689/700
2016-08-15 10:38:52,389 [PokemonGoBot] [INFO] Stardust: 247878 | Pokecoins: 70
2016-08-15 10:38:52,389 [PokemonGoBot] [INFO] PokeBalls: 96 | GreatBalls: 154 | UltraBalls: 150 | MasterBalls: 0
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO] RazzBerries: 124 | BlukBerries: 0 | NanabBerries: 0
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO] LuckyEgg: 6 | Incubator: 8 | TroyDisk: 11
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO] Potion: 23 | SuperPotion: 30 | HyperPotion: 41 | MaxPotion: 0
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO] Incense: 4 | IncenseSpicy: 0 | IncenseCool: 0
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO] Revive: 40 | MaxRevive: 0
2016-08-15 10:38:52,390 [PokemonGoBot] [INFO]
2016-08-15 10:38:52,391 [PokemonGoBot] [INFO] Found encrypt.so! Platform: linux2 Encrypt.so directory: /home/sunny/project/PokemonGo-Bot
2016-08-15 10:38:52,391 [PokemonGoBot] [INFO]
2016-08-15 10:38:53,321 [PokemonGoBot] [INFO] [bot_start] Starting bot...
2016-08-15 10:38:53,637 [CollectLevelUpReward] [INFO] [level_up_reward] Received level up reward: []
2016-08-15 10:38:53,638 [IncubateEggs] [INFO] [next_egg_incubates] Next egg incubates in 0.13 km
2016-08-15 10:38:56,931 [ cli] [INFO]
2016-08-15 10:38:56,931 [ cli] [INFO] Ran for 0:00:09
2016-08-15 10:38:56,932 [ cli] [INFO] Total XP Earned: 0 Average: 0.00/h
2016-08-15 10:38:56,932 [ cli] [INFO] Travelled 0.00km
2016-08-15 10:38:56,932 [ cli] [INFO] Visited 0 stops
2016-08-15 10:38:56,932 [ cli] [INFO] Encountered 0 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before
2016-08-15 10:38:56,932 [ cli] [INFO] Threw 0 pokeballs
2016-08-15 10:38:56,933 [ cli] [INFO] Earned 0 Stardust
2016-08-15 10:38:56,933 [ cli] [INFO]
2016-08-15 10:38:56,933 [ cli] [INFO] Highest CP Pokemon:
2016-08-15 10:38:56,933 [ cli] [INFO] Most Perfect Pokemon:
Traceback (most recent call last):
File "pokecli.py", line 578, in
main()
File "pokecli.py", line 103, in main
bot.tick()
File "/home/sunny/project/PokemonGo-Bot/pokemongo_bot/init.py", line 482, in tick
if worker.work() == WorkerResult.RUNNING:
File "/home/sunny/project/PokemonGo-Bot/pokemongo_bot/cell_workers/nickname_pokemon.py", line 204, in work
self._nickname_pokemon(pokemon)
File "/home/sunny/project/PokemonGo-Bot/pokemongo_bot/cell_workers/nickname_pokemon.py", line 271, in _nickname_pokemon
data={'old_name': old_nickname, 'current_name': new_nickname}
File "/home/sunny/project/PokemonGo-Bot/pokemongo_bot/base_task.py", line 28, in emit_event
data=data
File "/home/sunny/project/PokemonGo-Bot/pokemongo_bot/event_manager.py", line 61, in emit
formatted_msg = formatted.format(*_data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
2016-08-15 10:38:56,954 [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 "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/raven/transport/threaded.py", line 174, in send_sync
super(ThreadedHTTPTransport, self).send(data, headers)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send
ca_certs=self.ca_certs,
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/raven/utils/http.py", line 66, in urlopen
return opener.open(url, data, timeout)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/future/backports/urllib/request.py", line 494, in open
response = self._open(req, data)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/future/backports/urllib/request.py", line 512, in _open
'_open', req)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/future/backports/urllib/request.py", line 466, in _call_chain
result = func(_args)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open
return self.do_open(ValidHTTPSConnection, req)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/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 "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/httplib.py", line 1057, in request
self._send_request(method, url, body, headers)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/httplib.py", line 1097, in _send_request
self.endheaders(body)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/lib/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/home/sunny/.pyenv/versions/anaconda2-2.5.0/envs/poke/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-15 10:38:56,958 [sentry.errors.uncaught] [ERROR] [u"UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)", u' File "pokecli.py", line 578, in ', u' File "pokecli.py", line 103, in main', u' File "pokemongo_bot/init.py", line 482, in tick', u' File "pokemongo_bot/cell_workers/nickname_pokemon.py", line 204, in work', u' File "pokemongo_bot/cell_workers/nickname_pokemon.py", line 271, in _nickname_pokemon', u' File "pokemongo_bot/base_task.py", line 28, in emit_event', u' File "pokemongo_bot/event_manager.py", line 61, in emit']

Other Information

OS:ubuntu 14.04 LTS
Git Commit: 5c9cdb5
Python Version: Python 2.7.12 :: Continuum Analytics, Inc.

@k4n30
Copy link
Contributor

k4n30 commented Aug 15, 2016

@sunnytrail This was fixed 6 hours ago in the dev branch. If you don't want to switch to dev, then I suggest you disable the NicknamePokemon task until it's merged into the master branch.

I'm going to leave this issue open until the merge with master is made, after which you will be notified and this issue will be closed

@sunnytrail
Copy link
Author

I switched to the dev branch, and I found that the nickname task worked well. I'm waiting it's merged into the master branch. Thank you.

@k4n30 k4n30 closed this as completed Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants