Пример #1
0
    def testPropfind(self):
        """
        Test of the propfind methods. (This is sort of redundant, since
        this is implicitly run by the setup)
        """
        # ResourceType MUST be defined, and SHOULD be returned on a propfind
        # for "allprop" if I have the permission to see it.
        # So, no ResourceType returned seems like a bug in bedework
        if 'nopropfind' in self.server_params:
            raise SkipTest("Skipping propfind test, "
                           "re test suite configuration.  "
                           "Perhaps the caldav server is not adhering to "
                           "the standards")

        # first a raw xml propfind to the root URL
        foo = self.caldav.propfind(
            self.principal.url,
            props='<?xml version="1.0" encoding="UTF-8"?>'
            '<D:propfind xmlns:D="DAV:">'
            '  <D:allprop/>'
            '</D:propfind>')
        assert ('resourcetype' in to_local(foo.raw))

        # next, the internal _query_properties, returning an xml tree ...
        foo2 = self.principal._query_properties([
            dav.Status(),
        ])
        assert ('resourcetype' in to_local(foo.raw))
Пример #2
0
    def testPropfind(self):
        """
        Test of the propfind methods. (This is sort of redundant, since
        this is implicitly run by the setup)
        """
        ## first a raw xml propfind to the root URL
        foo = self.caldav.propfind(self.principal.url, props="""<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D="DAV:">
  <D:allprop/>
        </D:propfind>""")
        assert('resourcetype' in to_local(foo.raw))
        
        ## next, the internal _query_properties, returning an xml tree ...
        foo2 = self.principal._query_properties([dav.Status(),])
        assert('resourcetype' in to_local(foo.raw))
Пример #3
0
Файл: proxy.py Проект: vr/caldav
 def _read_write(self, soc, max_idling=20, local=False):
     iw = [self.connection, soc]
     local_data = ""
     ow = []
     count = 0
     while 1:
         count += 1
         (ins, _, exs) = select.select(iw, ow, iw, 1)
         if exs:
             break
         if ins:
             for i in ins:
                 if i is soc:
                     out = self.connection
                 else:
                     out = soc
                 data = i.recv(8192)
                 if data:
                     if local:
                         local_data += data
                     else:
                         out.send(data)
                     count = 0
         if count == max_idling:
             break
     if local:
         return to_local(local_data)
     return None
Пример #4
0
def fix(event):
    fixed = re.sub('COMPLETED:(\d+)\s', 'COMPLETED:\g<1>T120000Z', to_local(event))
    #The following line fixes a data bug in some Google Calendar events
    fixed = re.sub('CREATED:00001231T000000Z',
                   'CREATED:19700101T000000Z', fixed)
    fixed = re.sub(r"\\+('\")", r"\1", fixed)

    return fixed
Пример #5
0
def fix(event):
    fixed = re.sub('COMPLETED:(\d+)\s', 'COMPLETED:\g<1>T120000Z',
                   to_local(event))
    # The following line fixes a data bug in some Google Calendar events
    fixed = re.sub('CREATED:00001231T000000Z',
                   'CREATED:19700101T000000Z', fixed)
    fixed = re.sub(r"\\+('\")", r"\1", fixed)

    return fixed
Пример #6
0
    def testPropfind(self):
        """
        Test of the propfind methods. (This is sort of redundant, since
        this is implicitly run by the setup)
        """
        ## first a raw xml propfind to the root URL
        foo = self.caldav.propfind(
            self.principal.url,
            props="""<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D="DAV:">
  <D:allprop/>
        </D:propfind>""")
        assert ('resourcetype' in to_local(foo.raw))

        ## next, the internal _query_properties, returning an xml tree ...
        foo2 = self.principal._query_properties([
            dav.Status(),
        ])
        assert ('resourcetype' in to_local(foo.raw))
Пример #7
0
def fix(event):
    """This function receives some ical as it's given from the server, checks for 
    breakages with the standard, and attempts to fix up known issues:

    1) COMPLETED MUST be a datetime in UTC according to the RFC, but sometimes 
    a date is given. (Google Calendar?)

    2) The RFC does not specify any range restrictions on the dates,
    but clearly it doesn't make sense with a CREATED-timestamp that is
    centuries or decades before RFC2445 was published in 1998.
    Apparently some calendar servers generate nonsensical CREATED
    timestamps while other calendar servers can't handle CREATED
    timestamps prior to 1970.  Probably it would make more sense to
    drop the CREATED line completely rather than moving it from the
    end of year 0AD to the beginning of year 1970. (Google Calendar)

    3) iCloud apparently duplicates the DTSTAMP property sometimes -
    keep the first DTSTAMP encountered (arguably the DTSTAMP with earliest value
    should be kept).
    """
    ## TODO: add ^ before COMPLETED and CREATED?
    ## 1) Add a random time if completed is given as date
    fixed = re.sub('COMPLETED:(\d+)\s', 'COMPLETED:\g<1>T120000Z',
                   to_local(event))

    ## 2) CREATED timestamps prior to epoch does not make sense,
    ## change from year 0001 to epoch.
    fixed = re.sub('CREATED:00001231T000000Z',
                   'CREATED:19700101T000000Z', fixed)
    fixed = re.sub(r"\\+('\")", r"\1", fixed)

    fixed2 = ""

    ## OPTIMIZATION TODO: use list and join rather than concatination
    ## remove duplication of DTSTAMP
    for line in fixed.strip().split('\n'):
        if line.startswith('BEGIN:V'):
            cnt = 0
        if line.startswith('DTSTAMP:'):
            if not cnt:
                fixed2 += line + "\n"
            cnt += 1
        else:
            fixed2 += line + "\n"

    return fixed2
Пример #8
0
 def _read_write(self, soc, max_idling=20, local=False):
     iw = [self.connection, soc]
     local_data = ""
     ow = []
     count = 0
     while 1:
         count += 1
         (ins, _, exs) = select.select(iw, ow, iw, 1)
         if exs: break
         if ins:
             for i in ins:
                 if i is soc: out = self.connection
                 else: out = soc
                 data = i.recv(8192)
                 if data:
                     if local: local_data += data
                     else: out.send(data)
                     count = 0
         if count == max_idling: break
     if local: return to_local(local_data)
     return None