summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2018-10-20 23:08:33 +0200
committerGitHub <noreply@github.com>2018-10-20 23:08:33 +0200
commit82dd7c180775125ccf0fb6e133022e4bac1d8fe5 (patch)
tree3b4728cd46a67f1ce62876c521845c49ccd4452d
parent067aaaaf0fe5e732f42c56714a4e9e83349d5364 (diff)
parent4e2d51a4ea8bbc9a4308771cedf33f39cd66c3e9 (diff)
downloadcalendar-cli-82dd7c180775125ccf0fb6e133022e4bac1d8fe5.zip
Merge pull request #48 from phavekes/master
Several fixes
-rwxr-xr-xcalendar-cli.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index d3c444f..8c01e14 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"
@@ -139,11 +140,24 @@ 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)
+ """
+ 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):
"""
@@ -440,7 +454,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
@@ -863,6 +877,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)