From 35b8c04f6a1261d0641f3f19a999030ffbfe8e65 Mon Sep 17 00:00:00 2001
From: Peter Havekes
Date: Fri, 19 Oct 2018 11:40:23 +0200
Subject: Catch some errors in _calendar_addics.
---
calendar-cli.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/calendar-cli.py b/calendar-cli.py
index d3c444f..4bfc8bf 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -139,11 +139,21 @@ def _calendar_addics(caldav_conn, ics, uid, args):
raise ValueError("Nothing to do/invalid option combination for 'calendar add'-mode; either both --icalendar and --nocaldav should be set, or none of them")
return
- c = find_calendar(caldav_conn, args)
- if re.search(r'^METHOD:[A-Z]+[\r\n]+',ics,flags=re.MULTILINE) and args.ignoremethod:
- ics = re.sub(r'^METHOD:[A-Z]+[\r\n]+', '', ics, flags=re.MULTILINE)
- print ("METHOD property found and ignored")
- c.add_event(ics)
+ try:
+ c = find_calendar(caldav_conn, args)
+ if re.search(r'^METHOD:[A-Z]+[\r\n]+',ics,flags=re.MULTILINE) and args.ignoremethod:
+ ics = re.sub(r'^METHOD:[A-Z]+[\r\n]+', '', ics, flags=re.MULTILINE)
+ print ("METHOD property found and ignored")
+ c.add_event(ics)
+ except caldav.lib.error.AuthorizationError as e:
+ print("Error logging in");
+ sys.exit(2)
+ except caldav.lib.error.PutError as e:
+ if "200 OK" in str(e):
+ print("Duplicate")
+ else:
+ raise e
+
def calendar_addics(caldav_conn, args):
"""
--
cgit v1.2.3
From 920244b202efbacc3ad80ad3db86a5f0d35db28b Mon Sep 17 00:00:00 2001
From: Peter Havekes
Date: Fri, 19 Oct 2018 11:43:41 +0200
Subject: raise instead of raise e
---
calendar-cli.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/calendar-cli.py b/calendar-cli.py
index 4bfc8bf..a71a77c 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -152,7 +152,7 @@ def _calendar_addics(caldav_conn, ics, uid, args):
if "200 OK" in str(e):
print("Duplicate")
else:
- raise e
+ raise
def calendar_addics(caldav_conn, args):
--
cgit v1.2.3
From 2afae21b2bfe0186d6ea29f20185de43d9e24a3d Mon Sep 17 00:00:00 2001
From: Peter Havekes
Date: Fri, 19 Oct 2018 11:44:30 +0200
Subject: clean ical data for output utf-8
---
calendar-cli.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/calendar-cli.py b/calendar-cli.py
index a71a77c..60fb11c 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -450,7 +450,7 @@ def calendar_agenda(caldav_conn, args):
events = []
if args.icalendar:
for ical in events_:
- print(ical.data)
+ print(ical.data).encode('utf-8').strip()
else:
## flatten. A recurring event may be a list of events.
## jeez ... zimbra and DaviCal does completely different things here
--
cgit v1.2.3
From 3ab3e115c2a8592edb2065464d4c603103fc814b Mon Sep 17 00:00:00 2001
From: Peter Havekes
Date: Fri, 19 Oct 2018 11:47:51 +0200
Subject: Disable SSL warning
---
calendar-cli.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/calendar-cli.py b/calendar-cli.py
index 60fb11c..08a48c4 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -33,6 +33,7 @@ import os
import logging
import sys
import re
+import urllib3
__version__ = "0.11.0"
__author__ = "Tobias Brox"
@@ -873,6 +874,9 @@ def main():
caldav_conn = caldav_connect(args)
else:
caldav_conn = None
+
+ if args.ssl_verify_cert == 'no':
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
ret = args.func(caldav_conn, args)
--
cgit v1.2.3
From 4e2d51a4ea8bbc9a4308771cedf33f39cd66c3e9 Mon Sep 17 00:00:00 2001
From: Peter Havekes
Date: Fri, 19 Oct 2018 11:54:15 +0200
Subject: Disable except that needs more checking
---
calendar-cli.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/calendar-cli.py b/calendar-cli.py
index 08a48c4..8c01e14 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -149,12 +149,15 @@ def _calendar_addics(caldav_conn, ics, uid, args):
except caldav.lib.error.AuthorizationError as e:
print("Error logging in");
sys.exit(2)
+ """
+ Peter Havekes: This needs more checking. It works for me when connecting to O365
+
except caldav.lib.error.PutError as e:
if "200 OK" in str(e):
print("Duplicate")
else:
raise
-
+ """
def calendar_addics(caldav_conn, args):
"""
--
cgit v1.2.3