kevin-funderburg/alfred-microsoft-onenote-navigator

Great script.. is it possible to update to python3

cczhong11 opened this issue · 2 comments

I liked this workflow, but it is written in python2. I experienced errors when I open my notebook.

I understand it is a big work to transfer 2 to 3, and I have tried myself and failed since it has so many parts need to change...

getNotebooks.py:145: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if p["Name"] == q:
21:18:05 workflow.py:2075 ERROR    'ascii' codec can't decode byte 0xe7 in position 9: ordinal not in range(128)
Traceback (most recent call last):
  File "/Users/tczhong/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.0BF61655-5EDD-4468-91F3-BB18C6155E57/workflow/workflow.py", line 2068, in run
    func(self)
  File "getNotebooks.py", line 150, in main
    wf.add_item('No section ' + q + 'was found', icon=ICON_WARNING)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 9: ordinal not in range(128)

What I did to fix this was by adding these two lines in getNotebooks.py

reload(sys)
sys.setdefaultencoding('utf8')

so by default, Alfred-Workflow purposefully uses python 2 because it's the version that comes on macOS, so while I agree it would be nice to use it with python 3, in order for everyone to be able to use it without having to install anything else, it's generally recommended to keep workflows on python 2. Check out the docs here http://www.deanishe.net/alfred-workflow/supported-versions.html#python-versions