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

TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

Open elicwhite opened this issue 10 years ago • 7 comments

Looks like when the bot is starting up, these fields aren't populated so we get None back. We should return 0 if either of these are None

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

TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
  File "pokecli.py", line 490, in <module>
    main()
  File "pokecli.py", line 95, in main
    report_summary(bot)
  File "pokecli.py", line 136, in report_summary
    logger.info('Total XP Earned: {}  Average: {:.2f}/h'.format(metrics.xp_earned(), metrics.xp_per_hour()))
  File "pokemongo_bot/metrics.py", line 28, in xp_earned
    return self.xp['latest'] - self.xp['start']

TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

elicwhite avatar Aug 04 '16 18:08 elicwhite

I am having this issue. How to we alter the pokecly.py files so that I no longer get this error?

016-08-07 10:19:24,084 [PokemonGoBot] [INFO] 2016-08-07 10:19:24,084 [PokemonGoBot] [INFO] 2016-08-07 10:19:31,577 [ cli] [INFO] 2016-08-07 10:19:31,577 [ cli] [INFO] Ran for 0:00:11 Traceback (most recent call last): File "pokecli.py", line 493, in main() File "pokecli.py", line 127, in main report_summary(bot) File "pokecli.py", line 139, in report_summary logger.info('Total XP Earned: {} Average: {:.2f}/h'.format(metrics.xp_earned(), metrics.xp_per_hour())) File "/Users/trevor/PokemonGo-Bot/pokemongo_bot/metrics.py", line 28, in xp_earned return self.xp['latest'] - self.xp['start'] TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

mooseknuckleking avatar Aug 07 '16 16:08 mooseknuckleking

This is still a problem.

elicwhite avatar Aug 07 '16 17:08 elicwhite

Looks like this happens on first login with a fresh new account. UpdateLiveStats tries to get the XP to display the stats and fails at it. Temporary fix I found is :

  • Disabling the worker
  • Running the bot once, let it catch a Pokemon, spin a Pokestop, do stuff
  • Re-enable the worker
  • Watch it work 👍

johannlejeune avatar Aug 13 '16 00:08 johannlejeune

Can we make this fix?

smfbrooks avatar Aug 14 '16 00:08 smfbrooks

yes this is what needs to be done

but it's not a fix

account just needs to be level 1 before livestats can be enabled

MasterCATZ avatar Aug 16 '16 04:08 MasterCATZ

@MasterCATZ Yes, it's not a fix. If being level 1 is enough to make it work, we could add a level check in update_live_stats._should_display to avoid fetching stats when we're not level 1.

johannlejeune avatar Aug 16 '16 14:08 johannlejeune

#4088

smfbrooks avatar Aug 16 '16 19:08 smfbrooks