Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvpy v2.0.0 doesn't work offline #191

Closed
yuuki0xff opened this issue Oct 2, 2019 · 2 comments
Closed

nvpy v2.0.0 doesn't work offline #191

yuuki0xff opened this issue Oct 2, 2019 · 2 comments
Assignees
Labels

Comments

@yuuki0xff
Copy link
Collaborator

2019-10-02 04:58:52,738 - DEBUG - nvpy logging initialized
2019-10-02 04:58:52,738 - DEBUG - config read from ['/home/yuuki/.nvpy.cfg']
2019-10-02 04:58:53,453 - DEBUG - Starting full sync.
2019-10-02 04:58:53,464 - DEBUG - Retrieving full note list from server, could take a while.
2019-10-02 04:58:53,468 - ERROR - Traceback (most recent call last):
  File "/home/yuuki/.local/lib/python3.7/site-packages/nvpy/notes_db.py", line 793, in sync_full_unthreaded
    nl = self.simplenote.get_note_list(data=False)
  File "/home/yuuki/.local/lib/python3.7/site-packages/simplenote/simplenote.py", line 273, in get_note_list
    response = urllib2.urlopen(request)
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1285, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1221, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object
@yuuki0xff
Copy link
Collaborator Author

Caused by a bug in the simplenote library.

>>> import simplenote
>>> sn = simplenote.Simplenote('foo', 'bar')
>>> sn.get_token() is None
True

>>> import urllib.request
>>> req = urllib.request.Request('https://github.com')
>>> req.add_header('foo', None)
>>> urllib.request.urlopen(req)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1285, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1221, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object

@yuuki0xff
Copy link
Collaborator Author

Added workaround code in a20dc63.

yuuki0xff added a commit to yuuki0xff/simplenote.py that referenced this issue Oct 3, 2019
Simplenote.authenticate() and get_token() usually return a str.  When
offline, these methods return None.  The get_note(), update_note(), etc.
do not consider for this behavior.  Therefore, None will be set to http
header, and TypeError will occur when sending a request.

Related: cpbotha/nvpy#191

BROKEN CHANGE:

authenticate() and get_token() no longer catch the IOError,
BadStatusLine and part of HTTPError errors.
yuuki0xff added a commit to yuuki0xff/simplenote.py that referenced this issue Oct 18, 2019
Simplenote.authenticate() and get_token() usually return a str.  When
offline, these methods return None.  The get_note(), update_note(), etc.
do not consider for this behavior.  Therefore, None will be set to http
header, and TypeError will occur when sending a request.

Related: cpbotha/nvpy#191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant