kevin-funderburg / alfred-microsoft-onenote-navigator

Use Alfred to browse through your Microsoft OneNote notebooks, section groups and sections and then jump to them instantly.
Other
69 stars 7 forks source link

Great script.. is it possible to update to python3 #3

Closed cczhong11 closed 5 years ago

cczhong11 commented 5 years ago

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)
shuhu3 commented 5 years ago

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

reload(sys)
sys.setdefaultencoding('utf8')
kevin-funderburg commented 5 years ago

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