aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/caldav/calcurse-caldav.py
diff options
context:
space:
mode:
authorvxid <maxime.treca@gmail.com>2019-03-05 10:54:23 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-03-12 09:08:22 +0100
commitccdd3391f3304219b5c90f29eb9a7b83f37a4362 (patch)
tree39f514b6374f8d02cb8792b5534cb0dd7f1bcfcd /contrib/caldav/calcurse-caldav.py
parent528368932ceb05fec10638062ca56d6772f21040 (diff)
downloadcalcurse-ccdd3391f3304219b5c90f29eb9a7b83f37a4362.tar.gz
calcurse-ccdd3391f3304219b5c90f29eb9a7b83f37a4362.zip
calcurse-caldav: add custom data directory support
Added the --datadir flag to calcurse-caldav which enables to specify a custom calcurse data directory similarly to the -D flag in calcurse. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/caldav/calcurse-caldav.py')
-rwxr-xr-xcontrib/caldav/calcurse-caldav.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py
index 68d964c..7b9b56c 100755
--- a/contrib/caldav/calcurse-caldav.py
+++ b/contrib/caldav/calcurse-caldav.py
@@ -36,6 +36,11 @@ def die(msg):
sys.exit(msgfmt(msg, "error: "))
+def check_dir(dir):
+ if not os.path.isdir(dir):
+ die("invalid directory: {0}".format(dir))
+
+
def die_atnode(msg, node):
if debug:
msg += '\n\n'
@@ -55,7 +60,7 @@ def calcurse_wipe():
if dry_run:
return
- command = [calcurse, '-F', '--filter-hash=XXX']
+ command = calcurse + ['-F', '--filter-hash=XXX']
if debug:
print('Running command: {}'.format(command))
@@ -64,8 +69,7 @@ def calcurse_wipe():
def calcurse_import(icaldata):
- command = [
- calcurse,
+ command = calcurse + [
'-i', '-',
'--dump-imported',
'-q',
@@ -84,8 +88,7 @@ def calcurse_import(icaldata):
def calcurse_export(objhash):
- command = [
- calcurse,
+ command = calcurse + [
'-xical',
'--export-uid',
'--filter-hash=' + objhash
@@ -99,8 +102,7 @@ def calcurse_export(objhash):
def calcurse_hashset():
- command = [
- calcurse,
+ command = calcurse + [
'-G',
'--filter-type', sync_filter,
'--format-apt=%(hash)\\n',
@@ -118,7 +120,7 @@ def calcurse_hashset():
def calcurse_remove(objhash):
- command = [calcurse, '-F', '--filter-hash=!' + objhash]
+ command = calcurse + ['-F', '--filter-hash=!' + objhash]
if debug:
print('Running command: {}'.format(command))
@@ -127,7 +129,7 @@ def calcurse_remove(objhash):
def calcurse_version():
- command = [calcurse, '--version']
+ command = calcurse + ['--version']
if debug:
print('Running command: {}'.format(command))
@@ -521,6 +523,9 @@ parser.add_argument('--init', action='store', dest='init', default=None,
parser.add_argument('--config', action='store', dest='configfn',
default=configfn,
help='path to the calcurse-caldav configuration')
+parser.add_argument('--datadir', action='store', dest='datadir',
+ default=None,
+ help='path to the calcurse data directory')
parser.add_argument('--lockfile', action='store', dest='lockfn',
default=lockfn,
help='path to the calcurse-caldav lock file')
@@ -546,6 +551,7 @@ init = args.init is not None
configfn = args.configfn
lockfn = args.lockfn
syncdbfn = args.syncdbfn
+datadir = args.datadir
hookdir = args.hookdir
authcode = args.authcode
verbose = args.verbose
@@ -576,9 +582,13 @@ else:
https = True
if config.has_option('General', 'Binary'):
- calcurse = config.get('General', 'Binary')
+ calcurse = [config.get('General', 'Binary')]
else:
- calcurse = 'calcurse'
+ calcurse = ['calcurse']
+
+if datadir:
+ check_dir(datadir)
+ calcurse += ['-D', datadir]
if config.has_option('General', 'DryRun'):
dry_run = config.getboolean('General', 'DryRun')