当前位置: 首页>>代码示例>>Python>>正文


Python PyCalendarDateTime.getNowUTC方法代码示例

本文整理汇总了Python中pycalendar.datetime.PyCalendarDateTime.getNowUTC方法的典型用法代码示例。如果您正苦于以下问题:Python PyCalendarDateTime.getNowUTC方法的具体用法?Python PyCalendarDateTime.getNowUTC怎么用?Python PyCalendarDateTime.getNowUTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycalendar.datetime.PyCalendarDateTime的用法示例。


在下文中一共展示了PyCalendarDateTime.getNowUTC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _addEvent

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def _addEvent(self):
        if not self._client.started:
            return succeed(None)

        calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")

        while calendars:
            calendar = self.random.choice(calendars)
            calendars.remove(calendar)

            # Copy the template event and fill in some of its fields
            # to make a new event to create on the calendar.
            vcalendar = self._eventTemplate.duplicate()
            vevent = vcalendar.mainComponent()
            uid = str(uuid4())
            dtstart = self._eventStartDistribution.sample()
            dtend = dtstart + PyCalendarDuration(seconds=self._eventDurationDistribution.sample())
            vevent.replaceProperty(Property("CREATED", PyCalendarDateTime.getNowUTC()))
            vevent.replaceProperty(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
            vevent.replaceProperty(Property("DTSTART", dtstart))
            vevent.replaceProperty(Property("DTEND", dtend))
            vevent.replaceProperty(Property("UID", uid))

            rrule = self._recurrenceDistribution.sample()
            if rrule is not None:
                vevent.addProperty(Property(None, None, None, pycalendar=rrule))

            href = '%s%s.ics' % (calendar.url, uid)
            d = self._client.addEvent(href, vcalendar)
            return self._newOperation("create", d)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:profiles.py

示例2: _invite

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def _invite(self):
        """
        Try to add a new event, or perhaps remove an
        existing attendee from an event.

        @return: C{None} if there are no events to play with,
            otherwise a L{Deferred} which fires when the attendee
            change has been made.
        """

        if not self._client.started:
            return succeed(None)

        # Find calendars which are eligible for invites
        calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")

        while calendars:
            # Pick one at random from which to try to create an event
            # to modify.
            calendar = self.random.choice(calendars)
            calendars.remove(calendar)

            # Copy the template event and fill in some of its fields
            # to make a new event to create on the calendar.
            vcalendar = self._eventTemplate.duplicate()
            vevent = vcalendar.mainComponent()
            uid = str(uuid4())
            dtstart = self._eventStartDistribution.sample()
            dtend = dtstart + PyCalendarDuration(seconds=self._eventDurationDistribution.sample())
            vevent.replaceProperty(Property("CREATED", PyCalendarDateTime.getNowUTC()))
            vevent.replaceProperty(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
            vevent.replaceProperty(Property("DTSTART", dtstart))
            vevent.replaceProperty(Property("DTEND", dtend))
            vevent.replaceProperty(Property("UID", uid))

            rrule = self._recurrenceDistribution.sample()
            if rrule is not None:
                vevent.addProperty(Property(None, None, None, pycalendar=rrule))

            vevent.addProperty(self._client._makeSelfOrganizer())
            vevent.addProperty(self._client._makeSelfAttendee())

            attendees = list(vevent.properties('ATTENDEE'))
            for _ignore in range(int(self._inviteeCountDistribution.sample())):
                try:
                    self._addAttendee(vevent, attendees)
                except CannotAddAttendee:
                    self._failedOperation("invite", "Cannot add attendee")
                    return succeed(None)

            href = '%s%s.ics' % (calendar.url, uid)
            d = self._client.addInvite(href, vcalendar)
            return self._newOperation("invite", d)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:55,代码来源:profiles.py

示例3: __init__

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def __init__(self, threshold, past):
        """
        @param threshold: the size in bytes that will trigger a split
        @type threshold: C{int}
        @param past: number of days in the past where the split will occur
        @type past: C{int}

        """
        self.threshold = threshold
        self.past = PyCalendarDateTime.getNowUTC()
        self.past.setHHMMSS(0, 0, 0)
        self.past.offsetDay(-past)
        self.now = PyCalendarDateTime.getNowUTC()
        self.now.setHHMMSS(0, 0, 0)
        self.now.offsetDay(-1)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:17,代码来源:icalsplitter.py

示例4: _transferAttendeeData

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def _transferAttendeeData(self, serverComponent, clientComponent, declines):

        # We are skipping this check now - instead we let the server data override the broken client data
        # First check validity of date-time related properties and get removed components which are declines
        self._checkInvalidChanges(serverComponent, clientComponent, declines)

        # Now look for items to transfer from one to the other.
        # We care about the ATTENDEE's PARTSTAT, TRANSP, VALARMS, X-APPLE-NEEDS-REPLY,
        # DTSTAMP, LAST-MODIFIED, COMPLETED, and ATTACH's referring to a dropbox

        replyNeeded = False

        # ATTENDEE/PARTSTAT/RSVP
        serverAttendee = serverComponent.getAttendeeProperty((self.attendee,))
        clientAttendee = clientComponent.getAttendeeProperty((self.attendee,))

        # Possible case where one ATTENDEE prop is missing - this happens with a "fake" master sometimes
        if serverAttendee is None or clientAttendee is None:
            log.error("ATTENDEE for user making an attendee change is missing: %s" % (self.attendee,))
            return False, False

        if serverAttendee.parameterValue("PARTSTAT", "NEEDS-ACTION") != clientAttendee.parameterValue("PARTSTAT", "NEEDS-ACTION"):
            serverAttendee.setParameter("PARTSTAT", clientAttendee.parameterValue("PARTSTAT", "NEEDS-ACTION"))

            # If PARTSTAT was changed by the attendee, add a timestamp if needed
            if config.Scheduling.Options.TimestampAttendeePartStatChanges:
                serverAttendee.setParameter("X-CALENDARSERVER-DTSTAMP", PyCalendarDateTime.getNowUTC().getText())

            replyNeeded = True

        if serverAttendee.parameterValue("RSVP", "FALSE") != clientAttendee.parameterValue("RSVP", "FALSE"):
            if clientAttendee.parameterValue("RSVP", "FALSE") == "FALSE":
                try:
                    serverAttendee.removeParameter("RSVP")
                except KeyError:
                    pass
            else:
                serverAttendee.setParameter("RSVP", "TRUE")

        # Transfer these properties from the client data
        replyNeeded |= self._transferProperty("X-CALENDARSERVER-PRIVATE-COMMENT", serverComponent, clientComponent)
        self._transferProperty("TRANSP", serverComponent, clientComponent)
        self._transferProperty("DTSTAMP", serverComponent, clientComponent)
        self._transferProperty("LAST-MODIFIED", serverComponent, clientComponent)
        self._transferProperty("COMPLETED", serverComponent, clientComponent)
        for pname in config.Scheduling.CalDAV.PerAttendeeProperties:
            self._transferProperty(pname, serverComponent, clientComponent)

        # Dropbox - this now never returns false
        if config.EnableDropBox:
            self._transferDropBoxData(serverComponent, clientComponent)

        # Handle VALARMs
        serverComponent.removeAlarms()
        for comp in clientComponent.subcomponents():
            if comp.name() == "VALARM":
                serverComponent.addComponent(comp)

        return True, replyNeeded
开发者ID:anemitz,项目名称:calendarserver,代码行数:61,代码来源:icaldiff.py

示例5: createNewDatabase

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def createNewDatabase(self):
        """
        Create a new DB xml file from scratch by scanning zoneinfo.
        """

        self.dtstamp = PyCalendarDateTime.getNowUTC().getXMLText()
        self._scanTZs("")
        self._dumpTZs()
开发者ID:anemitz,项目名称:calendarserver,代码行数:10,代码来源:timezonestdservice.py

示例6: doRequest

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def doRequest(self):
        """
        Execute the actual HTTP request.
        """

        now = PyCalendarDateTime.getNowUTC()
        href = joinURL(self.sessions[0].calendarHref, "put.ics")
        self.sessions[0].writeData(URL(path=href), ICAL % (now.getYear() + 1,), "text/calendar")
开发者ID:anemitz,项目名称:calendarserver,代码行数:10,代码来源:put.py

示例7: doCapabilities

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def doCapabilities(self, request):
        """
        Return a list of all timezones known to the server.
        """

        # Determine min/max date-time for iSchedule
        now = PyCalendarDateTime.getNowUTC()
        minDateTime = PyCalendarDateTime(now.getYear(), 1, 1, 0, 0, 0, PyCalendarTimezone(utc=True))
        minDateTime.offsetYear(-1)
        maxDateTime = PyCalendarDateTime(now.getYear(), 1, 1, 0, 0, 0, PyCalendarTimezone(utc=True))
        maxDateTime.offsetYear(10)

        result = ischedulexml.QueryResult(

            ischedulexml.Capabilities(
                ischedulexml.Version.fromString(config.Scheduling.iSchedule.SerialNumber),
                ischedulexml.Versions(
                    ischedulexml.Version.fromString("1.0"),
                ),
                ischedulexml.SchedulingMessages(
                    ischedulexml.Component(
                        ischedulexml.Method(name="REQUEST"),
                        ischedulexml.Method(name="CANCEL"),
                        ischedulexml.Method(name="REPLY"),
                        name="VEVENT"
                    ),
                    ischedulexml.Component(
                        ischedulexml.Method(name="REQUEST"),
                        ischedulexml.Method(name="CANCEL"),
                        ischedulexml.Method(name="REPLY"),
                        name="VTODO"
                    ),
                    ischedulexml.Component(
                        ischedulexml.Method(name="REQUEST"),
                        name="VFREEBUSY"
                    ),
                ),
                ischedulexml.CalendarDataTypes(
                    ischedulexml.CalendarDataType(**{
                            "content-type": "text/calendar",
                            "version": "2.0",
                    }),
                ),
                ischedulexml.Attachments(
                    ischedulexml.External(),
                ),
                ischedulexml.MaxContentLength.fromString(config.MaxResourceSize),
                ischedulexml.MinDateTime.fromString(minDateTime.getText()),
                ischedulexml.MaxDateTime.fromString(maxDateTime.getText()),
                ischedulexml.MaxInstances.fromString(config.MaxAllowedInstances),
                ischedulexml.MaxRecipients.fromString(config.MaxAttendeesPerInstance),
                ischedulexml.Administrator.fromString(request.unparseURL(params="", querystring="", fragment="")),
            ),
        )
        response = XMLResponse(responsecode.OK, result)
        response.headers.addRawHeader(ISCHEDULE_CAPABILITIES, str(config.Scheduling.iSchedule.SerialNumber))
        return response
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:59,代码来源:resource.py

示例8: _purgeUID

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def _purgeUID(self, uid):

        if self.when is None:
            self.when = PyCalendarDateTime.getNowUTC()

        # Does the record exist?
        record = self.directory.recordWithUID(uid)
        if record is None:
            # The user has already been removed from the directory service.  We
            # need to fashion a temporary, fake record

            # FIXME: probably want a more elegant way to accomplish this,
            # since it requires the aggregate directory to examine these first:
            record = DirectoryRecord(self.directory, "users", uid, shortNames=(uid,), enabledForCalendaring=True)
            self.directory._tmpRecords["shortNames"][uid] = record
            self.directory._tmpRecords["uids"][uid] = record

        # Override augments settings for this record
        record.enabled = True
        record.enabledForCalendaring = True
        record.enabledForAddressBooks = True

        cua = "urn:uuid:%s" % (uid,)

        principalCollection = self.directory.principalCollection
        principal = principalCollection.principalForRecord(record)

        # See if calendar home is provisioned
        txn = self.store.newTransaction()
        storeCalHome = (yield txn.calendarHomeWithUID(uid))
        calHomeProvisioned = storeCalHome is not None

        # If in "completely" mode, unshare collections, remove notifications
        if calHomeProvisioned and self.completely:
            yield self._cleanHome(txn, storeCalHome)

        yield txn.commit()

        count = 0
        assignments = []

        if calHomeProvisioned:
            count = (yield self._cancelEvents(txn, uid, cua))

        # Remove empty calendar collections (and calendar home if no more
        # calendars)
        yield self._removeCalendarHome(uid)

        # Remove VCards
        count += (yield self._removeAddressbookHome(uid))

        if self.proxies and not self.dryrun:
            if self.verbose:
                print("Deleting any proxy assignments")
            assignments = (yield self._purgeProxyAssignments(principal))

        returnValue((count, assignments))
开发者ID:anemitz,项目名称:calendarserver,代码行数:59,代码来源:purge.py

示例9: updateDatabase

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
 def updateDatabase(self):
     """
     Update existing DB info by comparing md5's.
     """
     self.dtstamp = PyCalendarDateTime.getNowUTC().getXMLText()
     self.changeCount = 0
     self.changed = set()
     self._scanTZs("", checkIfChanged=True)
     if self.changeCount:
         self._dumpTZs()
开发者ID:anemitz,项目名称:calendarserver,代码行数:12,代码来源:timezonestdservice.py

示例10: prepare

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
 def prepare(self):
     """
     Do some setup prior to the real request.
     """
     # Add resources to create required number of changes
     self.start = PyCalendarDateTime.getNowUTC()
     self.start.setHHMMSS(12, 0, 0)
     self.end = self.start.duplicate()
     self.end.offsetHours(1)
     for i in range(self.count):
         href = joinURL(self.sessions[0].calendarHref, "tr-query-%d.ics" % (i + 1,))
         self.sessions[0].writeData(URL(path=href), ICAL % (self.start.getText(), i + 1,), "text/calendar")
开发者ID:anemitz,项目名称:calendarserver,代码行数:14,代码来源:query.py

示例11: buildFreeBusyResult

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
def buildFreeBusyResult(fbinfo, timerange, organizer=None, attendee=None, uid=None, method=None, event_details=None):
    """
    Generate a VCALENDAR object containing a single VFREEBUSY that is the
    aggregate of the free busy info passed in.

    @param fbinfo:        the array of busy periods to use.
    @param timerange:     the L{TimeRange} for the query.
    @param organizer:     the L{Property} for the Organizer of the free busy request, or None.
    @param attendee:      the L{Property} for the Attendee responding to the free busy request, or None.
    @param uid:           the UID value from the free busy request.
    @param method:        the METHOD property value to insert.
    @param event_details: VEVENT components to add.
    @return:              the L{Component} containing the calendar data.
    """

    # Merge overlapping time ranges in each fb info section
    normalizePeriodList(fbinfo[0])
    normalizePeriodList(fbinfo[1])
    normalizePeriodList(fbinfo[2])

    # Now build a new calendar object with the free busy info we have
    fbcalendar = Component("VCALENDAR")
    fbcalendar.addProperty(Property("VERSION", "2.0"))
    fbcalendar.addProperty(Property("PRODID", iCalendarProductID))
    if method:
        fbcalendar.addProperty(Property("METHOD", method))
    fb = Component("VFREEBUSY")
    fbcalendar.addComponent(fb)
    if organizer is not None:
        fb.addProperty(organizer)
    if attendee is not None:
        fb.addProperty(attendee)
    fb.addProperty(Property("DTSTART", timerange.start))
    fb.addProperty(Property("DTEND", timerange.end))
    fb.addProperty(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
    if len(fbinfo[0]) != 0:
        fb.addProperty(Property("FREEBUSY", fbinfo[0], {"FBTYPE": "BUSY"}))
    if len(fbinfo[1]) != 0:
        fb.addProperty(Property("FREEBUSY", fbinfo[1], {"FBTYPE": "BUSY-TENTATIVE"}))
    if len(fbinfo[2]) != 0:
        fb.addProperty(Property("FREEBUSY", fbinfo[2], {"FBTYPE": "BUSY-UNAVAILABLE"}))
    if uid is not None:
        fb.addProperty(Property("UID", uid))
    else:
        uid = str(uuid.uuid4())
        fb.addProperty(Property("UID", uid))

    if event_details:
        for vevent in event_details:
            fbcalendar.addComponent(vevent)

    return fbcalendar
开发者ID:anemitz,项目名称:calendarserver,代码行数:54,代码来源:freebusy.py

示例12: ensureEvents

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def ensureEvents(self, session, calendarhref, n):
        """
        Make sure the required number of events are present in the calendar.

        @param n: number of events
        @type n: C{int}
        """
        now = PyCalendarDateTime.getNowUTC()
        for i in range(n - self.currentCount):
            index = self.currentCount + i + 1
            href = joinURL(calendarhref, "%d.ics" % (index,))
            session.writeData(URL(path=href), ICAL % (now.getYear() + 1, index,), "text/calendar")

        self.currentCount = n
开发者ID:anemitz,项目名称:calendarserver,代码行数:16,代码来源:sqlusage.py

示例13: prepare

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def prepare(self):
        """
        Do some setup prior to the real request.
        """
        if not self.full:
            # Get current sync token
            results, _ignore_bad = self.sessions[0].getProperties(URL(path=self.sessions[0].calendarHref), (davxml.sync_token,))
            self.synctoken = results[davxml.sync_token]

            # Add resources to create required number of changes
            now = PyCalendarDateTime.getNowUTC()
            for i in range(self.count):
                href = joinURL(self.sessions[0].calendarHref, "sync-collection-%d.ics" % (i + 1,))
                self.sessions[0].writeData(URL(path=href), ICAL % (now.getYear() + 1, i + 1,), "text/calendar")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:sync.py

示例14: doRequest

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def doRequest(self):
        """
        Execute the actual HTTP request.
        """

        # Invite as user02
        now = PyCalendarDateTime.getNowUTC()
        href = joinURL(self.sessions[1].calendarHref, "organizer.ics")
        attendees = "\r\n".join(["ATTENDEE:mailto:[email protected]"] + [ATTENDEE % (ctr + 3,) for ctr in range(self.count - 1)])
        self.sessions[1].writeData(
            URL(path=href),
            ICAL.format(year=now.getYear() + 1, count=self.count, attendees=attendees),
            "text/calendar",
        )
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:invite.py

示例15: _addTask

# 需要导入模块: from pycalendar.datetime import PyCalendarDateTime [as 别名]
# 或者: from pycalendar.datetime.PyCalendarDateTime import getNowUTC [as 别名]
    def _addTask(self):
        if not self._client.started:
            return succeed(None)

        calendars = self._calendarsOfType(caldavxml.calendar, "VTODO")

        while calendars:
            calendar = self.random.choice(calendars)
            calendars.remove(calendar)

            # Copy the template task and fill in some of its fields
            # to make a new task to create on the calendar.
            vcalendar = self._taskTemplate.duplicate()
            vtodo = vcalendar.mainComponent()
            uid = str(uuid4())
            due = self._taskStartDistribution.sample()
            vtodo.replaceProperty(Property("CREATED", PyCalendarDateTime.getNowUTC()))
            vtodo.replaceProperty(Property("DTSTAMP", PyCalendarDateTime.getNowUTC()))
            vtodo.replaceProperty(Property("DUE", due))
            vtodo.replaceProperty(Property("UID", uid))

            href = '%s%s.ics' % (calendar.url, uid)
            d = self._client.addEvent(href, vcalendar)
            return self._newOperation("create", d)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:26,代码来源:profiles.py


注:本文中的pycalendar.datetime.PyCalendarDateTime.getNowUTC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。