coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 138 forks source link

The script does not like special characters #29

Closed schneuwlym closed 8 years ago

schneuwlym commented 8 years ago

myfitnesspal crashes if there are special characters in the output:

ERROR:myfitnesspal.cmdline:'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/cmdline.py", line 46, in main
    COMMANDS[args.command[0]]['function'](args, *extra)
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/commands.py", line 125, in day
    print('* {entry.name}'.format(entry=entry))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/local/bin/myfitnesspal", line 9, in <module>
    load_entry_point('myfitnesspal==1.8.0', 'console_scripts', 'myfitnesspal')()
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/cmdline.py", line 46, in main
    COMMANDS[args.command[0]]['function'](args, *extra)
  File "/usr/local/lib/python2.7/dist-packages/myfitnesspal/commands.py", line 125, in day
    print('* {entry.name}'.format(entry=entry))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)

Unfortunately there are many special characters in Swiss-German :-). Therefore the tool does only export one day of the last 14...

coddingtonbear commented 8 years ago

Nice catch, @schneuwlym; I'll have a look at this soon!

coddingtonbear commented 8 years ago

Fixed via 9cb1afa81594631a606d66c4c02804474640cf79, and released as part of 1.8.1.

Thanks again for finding this!