From 8466717f063a3c99297f24851c96a72c095b1739 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 25 Aug 2018 08:53:21 +0200 Subject: calcurse-caldav: print executed commands in debug mode Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 41 ++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index c880c3e..29ac328 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -54,7 +54,13 @@ def calcurse_wipe(): print('Removing all local calcurse objects...') if dry_run: return - subprocess.call([calcurse, '-F', '--filter-hash=XXX']) + + command = [calcurse, '-F', '--filter-hash=XXX'] + + if debug: + print('Running command: {}'.format(command)) + + subprocess.call(command) def calcurse_import(icaldata): @@ -71,13 +77,25 @@ def calcurse_import(icaldata): '--format-todo=%(hash)\\n' ] + if debug: + print('Running command: {}'.format(command)) + p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE) return p.communicate(icaldata.encode('utf-8'))[0].decode('utf-8').rstrip() def calcurse_export(objhash): - p = subprocess.Popen([calcurse, '-x', 'ical', '--export-uid', - '--filter-hash=' + objhash], stdout=subprocess.PIPE) + command = [ + calcurse, + '-x', 'ical', + '--export-uid', + '--filter-hash=' + objhash + ] + + if debug: + print('Running command: {}'.format(command)) + + p = subprocess.Popen(command, stdout=subprocess.PIPE) return p.communicate()[0].decode('utf-8').rstrip() @@ -93,16 +111,29 @@ def calcurse_hashset(): '--format-todo=%(hash)\\n' ] + if debug: + print('Running command: {}'.format(command)) + p = subprocess.Popen(command, stdout=subprocess.PIPE) return set(p.communicate()[0].decode('utf-8').rstrip().splitlines()) def calcurse_remove(objhash): - subprocess.call([calcurse, '-F', '--filter-hash=!' + objhash]) + command = [calcurse, '-F', '--filter-hash=!' + objhash] + + if debug: + print('Running command: {}'.format(command)) + + subprocess.call(command) def calcurse_version(): - p = subprocess.Popen([calcurse, '--version'], stdout=subprocess.PIPE) + command = [calcurse, '--version'] + + if debug: + print('Running command: {}'.format(command)) + + p = subprocess.Popen(command, stdout=subprocess.PIPE) m = re.match(r'calcurse ([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9]+)-)?', p.communicate()[0].decode('utf-8')) if not m: -- cgit v1.2.3-70-g09d2