nncli

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

commit fb58581b652746ec10fe9bd9c4babdffa52a67ad
parent c5bb932afc29b9956c6b2f3dee526183fadc53fa
Author: Eric Davis <edavis@insanum.com>
Date:   Tue,  8 Jul 2014 17:30:57 -0700

simplified 'since time' for getting index list
added some debug logs

Diffstat:
Msimplenote.py | 20++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/simplenote.py b/simplenote.py @@ -208,7 +208,7 @@ def get_note_list(self, since=None, tags=[]): is returned. Arguments: - - since=YYYY-MM-DD string: only return notes modified + - since=time.time() epoch stamp: only return notes modified since this date - tags=[] list of tags as string: return notes that have at least one of these tags @@ -231,16 +231,14 @@ def get_note_list(self, since=None, tags=[]): params = 'auth=%s&email=%s&length=%s' % (self.get_token(), self.username, NOTE_FETCH_LENGTH) if since is not None: - try: - sinceUT = time.mktime(datetime.datetime.strptime(since, "%Y-%m-%d").timetuple()) - params += '&since=%s' % sinceUT - except ValueError: - pass + params += '&since=%s' % since # perform initial HTTP request try: + #logging.debug('REQUEST: ' + INDX_URL+params) request = Request(INDX_URL+params) response = json.loads(urllib2.urlopen(request).read()) + #logging.debug('RESPONSE OK: ' + str(response)) notes["data"].extend(response["data"]) except IOError: status = -1 @@ -250,16 +248,14 @@ def get_note_list(self, since=None, tags=[]): vals = (self.get_token(), self.username, response["mark"], NOTE_FETCH_LENGTH) params = 'auth=%s&email=%s&mark=%s&length=%s' % vals if since is not None: - try: - sinceUT = time.mktime(datetime.datetime.strptime(since, "%Y-%m-%d").timetuple()) - params += '&since=%s' % sinceUT - except ValueError: - pass + params += '&since=%s' % since # perform the actual HTTP request try: + #logging.debug('REQUEST: ' + INDX_URL+params) request = Request(INDX_URL+params) response = json.loads(urllib2.urlopen(request).read()) + #logging.debug('RESPONSE OK: ' + str(response)) notes["data"].extend(response["data"]) except IOError: status = -1 @@ -316,6 +312,7 @@ def delete_note(self, note_id): params = '/%s?auth=%s&email=%s' % (str(note_id), self.get_token(), self.username) + #logging.debug('REQUEST DELETE: ' + DATA_URL+params) request = Request(url=DATA_URL+params, method='DELETE') try: urllib2.urlopen(request) @@ -340,4 +337,3 @@ def get_method(self): return urllib2.Request.get_method(self) -