From 4fff8ae4fe2615c7d966c4b2f73b2a4dbf9c6abf Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 25 Jan 2016 21:02:30 +0100 Subject: calcurse-caldav: Improve version check Make sure that at least a current Git build of calcurse is used. Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'contrib') diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index eb85459..e02a905 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -6,6 +6,7 @@ import configparser import hashlib import http.client import os +import re import ssl import subprocess import sys @@ -63,16 +64,11 @@ def calcurse_remove(objhash): def calcurse_version(): p = subprocess.Popen([calcurse, '--version'], stdout=subprocess.PIPE) - tokens = p.communicate()[0].decode('utf-8').rstrip().split(" ") - - if len(tokens) < 2: - return None - if tokens[0] != 'Calcurse': - return None - tokens = tokens[1].split(".") - if len(tokens) < 2: + m = re.match('Calcurse ([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9]+)-)?', + p.communicate()[0].decode('utf-8')) + if not m: return None - return int(tokens[0]) * 10 + int(tokens[1]) + return tuple(map(int, m.groups(0))) def get_auth_headers(): if not username or not password: @@ -397,8 +393,8 @@ ver = calcurse_version() if ver is None: die('Invalid calcurse binary. Make sure that the file specified in ' + 'the configuration is a valid and up-to-date calcurse binary.') -elif ver < 40: - die('Incompatible calcurse binary detected. Version >=4.0.0 is required ' + +elif ver < (4, 0, 0, 73): + die('Incompatible calcurse binary detected. Version >=4.1.0 is required ' + 'to synchronize with CalDAV servers.') # Create lock file. -- cgit v1.2.3-70-g09d2