Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

gnsync failing to sync: 'Unexpected args type: <type 'unicode'>' #92

Open
josswright opened this issue May 10, 2018 · 3 comments
Open
Labels
unicode_issue issues related to unicode / utf-8 encoding

Comments

@josswright
Copy link

I had, until about two weeks ago, a working setup with gnsync happily syncing my notes in two directions.

Now, for whatever reason, I'm getting a silent failure to download or sync my notebooks when using gnsync. I can access notes in geeknote itself.

EVERNOTE_DEV_TOKEN=<scrubbed> gnsync --path <path_to_notes> -a --format markdown --download-only

...was previously working, but now I get the following in my logfile:

2018-05-10 20:33:27,900 : Syncing notebook Research
2018-05-10 20:33:27,907 : Sync Start
2018-05-10 20:33:28,190 : Unexpected args type: <type 'unicode'>. Expect list or dict
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/geeknote/gnsync.py", line 53, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/geeknote/gnsync.py", line 464, in _get_notes
    keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name))
  File "/usr/lib/python2.7/site-packages/geeknote/tools.py", line 53, in strip
    "%s. Expect list or dict" % type(data))
Exception: Unexpected args type: <type 'unicode'>. Expect list or dict
2018-05-10 20:33:28,191 : 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/geeknote/gnsync.py", line 53, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/geeknote/gnsync.py", line 211, in sync
    for n in notes:
TypeError: 'NoneType' object is not iterable

This happens for all my notebooks. I've tried clearing out the directory and starting fresh, but the same error occurs whether there are existing files or whether the directory is empty.

For reference, I'm running the latest git checkout installed on Arch via the geeknote-improved-git PKGBUILD.

@josswright
Copy link
Author

I've been playing around with this this evening, and I've noticed two things. They may be the same issue, or they may be unrelated.

The first is that when I manually sync notebooks rather than using -a, I can get downloads to work for most notes. For a good few notes, though, I'm getting the following error:
gnsync wrapper 55 : 'ascii' codec can't encode character u'\xa0' in position 122: ordinal not in range(128)
(https://stackoverflow.com/questions/10993612/python-removing-xa0-from-string seems that it may be relevant here, especially with the mention of using unicodedata.normalize("NFKD", unicode_str))

The other odd behaviour I seem to be getting is that even though the sync 'fails', it still creates a directory for each notebook. However, in addition to my actual notebooks, it also creates a notebook called notes which is then synced in future. I'm not sure if this is something hardcoded somewhere by mistake.

As I said, these may be separate issues, but as they all seem wrapped up together in how I'm using gnsync.

@josswright
Copy link
Author

Still getting this error. Does anyone else see this? Any ideas?

@josswright
Copy link
Author

After being tipped off by issue #94, I've had a play and seem to have got this working again. As with #94, it seems to be another common python unicode/str issue.

I'll make a pull request when I get a chance, but briefly:

In gnsync.py I changed line 383 from
content = Editor.ENMLtoText(note.content, self.imageOptions)
to
content = Editor.ENMLtoText(note.content.encode('utf-8'), self.imageOptions)

and line 464 from
keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name))
to
keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name.encode('utf-8')))

That is now getting me a full sync of my notes that seems to work in both directions, although I haven't had a chance to test it fully yet.

@jeffkowalski jeffkowalski added the unicode_issue issues related to unicode / utf-8 encoding label Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
unicode_issue issues related to unicode / utf-8 encoding
Projects
None yet
Development

No branches or pull requests

2 participants