nncli

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

commit 49c6ee1ae675a46a508cf9da4b4f0c3048d042f0
parent 7f2d0e1f5d0a0e19180c414dc1d9f810387b31f9
Author: Eric Davis <edavis@insanum.com>
Date:   Sun, 29 Jun 2014 15:31:24 -0700

use subprocess for spawning external pager

Diffstat:
Msncli.py | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 -import os, sys, re, signal, time, datetime, logging +import os, sys, re, signal, time, datetime, logging, subprocess import copy, json, urwid, datetime, tempfile import utils from config import Config @@ -258,7 +258,7 @@ def set_status_message(frame, msg): frame.contents['footer'] = ( t, None ) frame.alarm = sncli_loop.set_alarm_at(time.time() + 5, remove_status_message, - frame); + frame) def tempfile_name(): if self.tempfile: @@ -407,8 +407,8 @@ def update_note_titles(self, search_string): filter_notes(search_string) self.listbox = urwid.ListBox(urwid.SimpleFocusListWalker(list_get_note_titles())) self.listbox.keypress = self.note_title_listbox_keypress - self.contents['body'] = ( self.listbox, None ); - self.contents['footer'] = ( None, None ); + self.contents['body'] = ( self.listbox, None ) + self.contents['footer'] = ( None, None ) self.update_status() if len(self.listbox.body.positions()) == 0: set_status_message(self, 'No notes found!') @@ -470,21 +470,18 @@ def note_title_listbox_keypress(self, size, key): if not pager and os.environ['PAGER']: pager = os.environ['PAGER'] if not pager: - # XXX bottom status message no external pager configured + set_status_message(self, "No pager configured!") return - # XXX bottom status message showing pager string - saveb = self.contents['body'][0] saveh = self.contents['header'][0] #savef = self.contents['footer'][0] tempfile_create(list_get_note_json(self.listbox.focus_position)) try: - os.system(pager + u' ' + tempfile_name()) - except OSError, e: - # XXX bottom status message pager error - raise + subprocess.check_call(pager + u' ' + tempfile_name(), shell=True) + except Exception, e: + set_status_message(self, "Pager error: " + str(e)) # XXX check if modified, if so update it tempfile_delete()