nncli

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

commit 906145b47bd3b079887c535f0f8d540e9990a642
parent e166ededa96667ad3c3d29caba46513ea39897f7
Author: Eric Davis <edavis@insanum.com>
Date:   Wed, 20 Aug 2014 12:36:05 -0700

new trigger to force sync worker to sync now and not wait for timeout

Diffstat:
Msimplenote_cli/notes_db.py | 11++++++++++-
Msimplenote_cli/sncli.py | 10++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/simplenote_cli/notes_db.py b/simplenote_cli/notes_db.py @@ -28,6 +28,7 @@ def __init__(self, config, log, update_view): self.last_sync = 0 # set to zero to trigger a full sync self.sync_lock = threading.Lock() + self.go_cond = threading.Condition() # create db dir if it does not exist if not os.path.exists(self.config.get_config('db_path')): @@ -611,7 +612,15 @@ def sync_now(self, do_server_sync=True): def sync_worker(self, do_server_sync): time.sleep(1) # give some time to wait for GUI initialization self.log('Sync worker: started') + self.sync_now(do_server_sync) while True: + self.go_cond.acquire() + self.go_cond.wait(15) self.sync_now(do_server_sync) - time.sleep(5) + self.go_cond.release() + + def sync_worker_go(self): + self.go_cond.acquire() + self.go_cond.notify() + self.go_cond.release() diff --git a/simplenote_cli/sncli.py b/simplenote_cli/sncli.py @@ -290,6 +290,7 @@ def trash_note_callback(self, key, yes): self.view_titles.update_note_title() self.gui_update_status_bar() + self.ndb.sync_worker_go() def restore_note_callback(self, key, yes): if not yes: @@ -302,6 +303,7 @@ def restore_note_callback(self, key, yes): self.view_note.update_note_view() self.gui_update_status_bar() + self.ndb.sync_worker_go() def gui_yes_no_input(self, args, yes_no): self.gui_footer_input_clear() @@ -351,6 +353,7 @@ def gui_tags_input(self, args, tags): self.view_note.update_note_view() self.gui_update_status_bar() + self.ndb.sync_worker_go() def gui_pipe_input(self, args, cmd): self.gui_footer_input_clear() @@ -386,6 +389,7 @@ def gui_frame_keypress(self, size, key): elif key == self.config.get_keybind('sync'): self.ndb.last_sync = 0 + self.ndb.sync_worker_go() elif key == self.config.get_keybind('view_log'): self.view_log.update_log() @@ -587,6 +591,7 @@ def gui_frame_keypress(self, size, key): self.log(u'New note created') self.ndb.create_note(content) self.gui_update_view() + self.ndb.sync_worker_go() elif key == self.config.get_keybind('edit_note') or \ key == self.config.get_keybind('view_note_ext') or \ @@ -628,6 +633,7 @@ def gui_frame_keypress(self, size, key): lb.update_note_title() else: # self.gui_body_get().__class__ == view_note.ViewNote: lb.update_note_view() + self.ndb.sync_worker_go() else: self.log(u'Note unchanged') @@ -711,6 +717,8 @@ def gui_frame_keypress(self, size, key): if self.gui_body_get().__class__ == view_titles.ViewTitles: lb.update_note_title() + self.ndb.sync_worker_go() + elif key == self.config.get_keybind('note_markdown'): if self.gui_body_get().__class__ != view_titles.ViewTitles and \ self.gui_body_get().__class__ != view_note.ViewNote: @@ -733,6 +741,8 @@ def gui_frame_keypress(self, size, key): if self.gui_body_get().__class__ == view_titles.ViewTitles: lb.update_note_title() + self.ndb.sync_worker_go() + elif key == self.config.get_keybind('note_tags'): if self.gui_body_get().__class__ != view_titles.ViewTitles and \ self.gui_body_get().__class__ != view_note.ViewNote: