nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 8a25e0bdf88e1f8e169c5680c5786ef24b5bb23e
parent 7c31503b0177d8f4473483f8d472fbd28dc76b3f
Author: Samuel Walladge <samuel@swalladge.id.au>
Date:   Sat, 28 May 2016 00:13:28 +0930

fix while loop never executing (only first request for block of 100 notes ever happened) - should help with #24

Diffstat:
Msimplenote_cli/simplenote.py | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/simplenote_cli/simplenote.py b/simplenote_cli/simplenote.py @@ -231,9 +231,8 @@ def get_note_list(self, since=None, tags=[]): """ # initialize data status = 0 - ret = [] - response = {} notes = { "data" : [] } + json_data = {} # get the note index params = {'auth': self.get_token(), @@ -248,15 +247,19 @@ def get_note_list(self, since=None, tags=[]): #logging.debug('REQUEST: ' + self.INDX_URL+params) res = requests.get(self.INDX_URL, params=params) #logging.debug('RESPONSE OK: ' + str(res)) - notes["data"].extend(res.json()["data"]) + # TODO: check response code (here and below in loop) + json_data = res.json() + notes["data"].extend(json_data["data"]) except IOError: + # TODO: catch requests exceptions - http://docs.python-requests.org/en/master/user/quickstart/#errors-and-exceptions status = -1 + # get additional notes if bookmark was set in response - while "mark" in response: + while "mark" in json_data: params = {'auth': self.get_token(), 'email': self.username, - 'mark': response['mark'], + 'mark': json_data['mark'], 'length': NOTE_FETCH_LENGTH } if since is not None: @@ -266,8 +269,9 @@ def get_note_list(self, since=None, tags=[]): try: #logging.debug('REQUEST: ' + self.INDX_URL+params) res = requests.get(self.INDX_URL, params=params) + json_data = res.json() #logging.debug('RESPONSE OK: ' + str(response)) - notes["data"].extend(res.json()["data"]) + notes["data"].extend(json_data["data"]) except IOError: status = -1