summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Havekes <p.havekes@avans.nl>2018-10-19 11:40:23 +0200
committerPeter Havekes <p.havekes@avans.nl>2018-10-19 11:40:23 +0200
commit35b8c04f6a1261d0641f3f19a999030ffbfe8e65 (patch)
tree2de59540dce6615b4f5d558aeada7a885546bfe6
parent067aaaaf0fe5e732f42c56714a4e9e83349d5364 (diff)
downloadcalendar-cli-35b8c04f6a1261d0641f3f19a999030ffbfe8e65.zip
Catch some errors in _calendar_addics.
-rwxr-xr-xcalendar-cli.py20
1 files 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):
"""