From b293b1829d1380ad04c69510559d44fe300eb501 Mon Sep 17 00:00:00 2001 From: Si Yong Kim Date: Mon, 23 Sep 2019 23:01:11 -0700 Subject: calcurse-caldav: handle objects with status code 404 Display a warning if any of the events reported by the server cannot be found instead of bailing out. Addresses GitHub issue #137 and #245. Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'contrib/caldav') diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 009a443..d247f80 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -442,6 +442,16 @@ def pull_objects(hrefs_missing, hrefs_modified, conn, syncdb, etagdict): die_atnode('Missing href.', node) href = hrefnode.text + statusnode = node.find("./D:status", namespaces=nsmap) + if statusnode is not None: + status = re.match(r'HTTP.*(\d\d\d)', statusnode.text) + if status is None: + die_atnode('Could not parse status.', node) + statuscode = status.group(1) + if statuscode == '404': + print('Skipping missing item: {}'.format(href)) + continue + etagnode = node.find("./D:propstat/D:prop/D:getetag", namespaces=nsmap) if etagnode is None: die_atnode('Missing ETag.', node) -- cgit v1.2.3-70-g09d2