nncli

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

commit dc4f0e07853a5429ccbf500095f10310c3ca716c
parent df7f392492a3419ff37d31ab51f6cbec2f338b4a
Author: Eric Davis <edavis@insanum.com>
Date:   Sun, 13 Jul 2014 21:53:02 -0700

fixed a crash when creating a note via the command line

Diffstat:
Mnotes_db.py | 15+++++++++------
Msncli.py | 14+++++++-------
2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/notes_db.py b/notes_db.py @@ -470,7 +470,7 @@ def sync_notes(self, server_sync=True, full_sync=True): if local_key != k: # if local_key was a different key it should be deleted local_deletes[local_key] = True - local_updates[local_key] = False + del local_updates[local_key] self.log('Synced note to server (key={0})'.format(local_key)) else: @@ -592,14 +592,17 @@ def verify_all_saved(self): self.sync_lock.release() return all_saved + def sync_now(self, do_server_sync=True): + self.sync_lock.acquire() + self.sync_notes(server_sync=do_server_sync, + full_sync=True if not self.last_sync else False) + self.sync_lock.release() + # sync worker thread... - def sync_worker(self, do_sync): + def sync_worker(self, do_server_sync): time.sleep(1) # give some time to wait for GUI initialization self.log('Sync worker: started') while True: - self.sync_lock.acquire() - self.sync_notes(server_sync=do_sync, - full_sync=True if not self.last_sync else False) - self.sync_lock.release() + self.sync_now(do_server_sync) time.sleep(5) diff --git a/sncli.py b/sncli.py @@ -12,11 +12,11 @@ class sncli: - def __init__(self, do_sync, verbose=False): - self.config = Config() - self.do_sync = do_sync - self.verbose = verbose - self.do_gui = False + def __init__(self, do_server_sync, verbose=False): + self.config = Config() + self.do_server_sync = do_server_sync + self.verbose = verbose + self.do_gui = False if not os.path.exists(self.config.get_config('db_path')): os.mkdir(self.config.get_config('db_path')) @@ -42,7 +42,7 @@ def __init__(self, do_sync, verbose=False): sys.exit(1) def sync_notes(self): - self.ndb.sync_notes(self.do_sync) + self.ndb.sync_now(self.do_server_sync) def get_editor(self): editor = self.config.get_config('editor') @@ -667,7 +667,7 @@ def gui(self, key): self.log_lock = threading.Lock() self.thread_sync = threading.Thread(target=self.ndb.sync_worker, - args=[self.do_sync]) + args=[self.do_server_sync]) self.thread_sync.setDaemon(True) self.view_titles = \