calcurse-caldav: Improve version check

Make sure that at least a current Git build of calcurse is used.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2016-01-25 21:02:30 +01:00
parent 1a45713d1d
commit 4fff8ae4fe

View File

@ -6,6 +6,7 @@ import configparser
import hashlib import hashlib
import http.client import http.client
import os import os
import re
import ssl import ssl
import subprocess import subprocess
import sys import sys
@ -63,16 +64,11 @@ def calcurse_remove(objhash):
def calcurse_version(): def calcurse_version():
p = subprocess.Popen([calcurse, '--version'], stdout=subprocess.PIPE) p = subprocess.Popen([calcurse, '--version'], stdout=subprocess.PIPE)
tokens = p.communicate()[0].decode('utf-8').rstrip().split(" ") m = re.match('Calcurse ([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9]+)-)?',
p.communicate()[0].decode('utf-8'))
if len(tokens) < 2: if not m:
return None return None
if tokens[0] != 'Calcurse': return tuple(map(int, m.groups(0)))
return None
tokens = tokens[1].split(".")
if len(tokens) < 2:
return None
return int(tokens[0]) * 10 + int(tokens[1])
def get_auth_headers(): def get_auth_headers():
if not username or not password: if not username or not password:
@ -397,8 +393,8 @@ ver = calcurse_version()
if ver is None: if ver is None:
die('Invalid calcurse binary. Make sure that the file specified in ' + die('Invalid calcurse binary. Make sure that the file specified in ' +
'the configuration is a valid and up-to-date calcurse binary.') 'the configuration is a valid and up-to-date calcurse binary.')
elif ver < 40: elif ver < (4, 0, 0, 73):
die('Incompatible calcurse binary detected. Version >=4.0.0 is required ' + die('Incompatible calcurse binary detected. Version >=4.1.0 is required ' +
'to synchronize with CalDAV servers.') 'to synchronize with CalDAV servers.')
# Create lock file. # Create lock file.