summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pykolab/xml/__init__.py3
-rw-r--r--pykolab/xml/utils.py19
-rw-r--r--wallace/module_resources.py31
3 files changed, 30 insertions, 23 deletions
diff --git a/pykolab/xml/__init__.py b/pykolab/xml/__init__.py
index db12a33..5ca2837 100644
--- a/pykolab/xml/__init__.py
+++ b/pykolab/xml/__init__.py
@@ -10,6 +10,8 @@ from event import InvalidEventDateError
from event import event_from_ical
from event import event_from_string
+from utils import to_dt
+
__all__ = [
"Attendee",
"Contact",
@@ -17,6 +19,7 @@ __all__ = [
"Event",
"event_from_ical",
"event_from_string",
+ "to_dt",
]
errors = [
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
new file mode 100644
index 0000000..0959c80
--- /dev/null
+++ b/pykolab/xml/utils.py
@@ -0,0 +1,19 @@
+import datetime
+import pytz
+
+def to_dt(dt):
+ """
+ Convert a naive date or datetime to a tz-aware datetime.
+ """
+
+ if type(dt) == 'datetime.date' or not hasattr(dt, 'hour'):
+ dt = datetime.datetime(dt.year, dt.month, dt.day, 0, 0, 0, 0)
+
+ else:
+ if dt.tzinfo == None:
+ return dt.replace(tzinfo=pytz.utc)
+ else:
+
+ return dt
+
+
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index 492b817..c5b145f 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -21,6 +21,7 @@ import datetime
import icalendar
import json
import os
+import pytz
import random
import tempfile
import time
@@ -41,6 +42,7 @@ from pykolab.conf import Conf
from pykolab.imap import IMAP
from pykolab.xml import event_from_ical
from pykolab.xml import event_from_string
+from pykolab.xml import to_dt
from pykolab.translate import _
log = pykolab.getLogger('pykolab.wallace')
@@ -231,31 +233,12 @@ def execute(*args, **kw):
event = pykolab.xml.event_from_string(payload)
for itip in itip_events:
- _es = event.get_start()
- _is = itip['start'].dt
+ _es = to_dt(event.get_start())
+ _is = to_dt(itip['start'].dt)
- if type(_es) == 'datetime.date' or not hasattr(_es, 'hour'):
- _es = datetime.datetime(
- _es.year, _es.month, _es.day, 0, 0, 0
- )
-
- if type(_is) == 'datetime.date' or not hasattr(_is, 'hour'):
- _is = datetime.datetime(
- _is.year, _is.month, _is.day, 0, 0, 0
- )
-
- _ee = event.get_end()
- _ie = itip['end'].dt
+ _ee = to_dt(event.get_end())
+ _ie = to_dt(itip['end'].dt)
- if type(_ee) == 'datetime.date' or not hasattr(_ee, 'hour'):
- _ee = datetime.datetime(
- _ee.year, _ee.month, _ee.day, 0, 0, 0
- )
-
- if type(_ie) == 'datetime.date' or not hasattr(_ie, 'hour'):
- _ie = datetime.datetime(
- _ie.year, _ie.month, _ie.day, 0, 0, 0
- )
if _es < _is:
if _es <= _ie:
@@ -360,6 +343,7 @@ def execute(*args, **kw):
level=9
)
+ imap.imap.m.setacl(resources[resource]['kolabtargetfolder'], "cyrus-admin", "lrswipkxtecda")
imap.imap.m.append(
resources[resource]['kolabtargetfolder'],
None,
@@ -395,6 +379,7 @@ def execute(*args, **kw):
level=9
)
+ imap.imap.m.setacl(_target_resource['kolabtargetfolder'], "cyrus-admin", "lrswipkxtecda")
imap.imap.m.append(
_target_resource['kolabtargetfolder'],
None,