本文整理汇总了Python中twistedcaldav.timezones.TimezoneCache类的典型用法代码示例。如果您正苦于以下问题:Python TimezoneCache类的具体用法?Python TimezoneCache怎么用?Python TimezoneCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimezoneCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_calendar_query_bogus_timezone_id
def test_calendar_query_bogus_timezone_id(self):
"""
Partial retrieval of events by time range.
(CalDAV-access-09, section 7.6.1)
"""
TimezoneCache.create()
self.addCleanup(TimezoneCache.clear)
calendar_properties = (
davxml.GETETag(),
caldavxml.CalendarData(),
)
query_timerange = caldavxml.TimeRange(
start="%04d1001T000000Z" % (DateTime.getToday().getYear(),),
end="%04d1101T000000Z" % (DateTime.getToday().getYear(),),
)
query = caldavxml.CalendarQuery(
davxml.PropertyContainer(*calendar_properties),
caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
query_timerange,
name="VEVENT",
),
name="VCALENDAR",
),
),
caldavxml.TimeZoneID.fromString("bogus"),
)
result = yield self.calendar_query(query, got_xml=None, expected_code=responsecode.FORBIDDEN)
self.assertTrue("valid-timezone" in result)
示例2: test_copyPackage_Concurrency
def test_copyPackage_Concurrency(self):
"""
Test that concurrent copying of the tz package works.
"""
self.patch(config, "UsePackageTimezones", False)
TimezoneCache.clear()
ex = [None, None]
def _try(n):
try:
TimezoneCache.create()
except:
f = Failure()
ex[n] = str(f)
t1 = threading.Thread(target=_try, args=(0,))
t2 = threading.Thread(target=_try, args=(1,))
t1.start()
t2.start()
t1.join()
t2.join()
self.assertTrue(ex[0] is None, msg=ex[0])
self.assertTrue(ex[1] is None, msg=ex[1])
self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
示例3: __init__
def __init__(self, store, options, output, reactor, config):
super(PodMigrationService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
self.config = config
TimezoneCache.create()
示例4: __init__
def __init__(self, store, options, reactor, config):
super(ImporterService, self).__init__(store)
self.options = options
self.reactor = reactor
self.config = config
self._directory = self.store.directoryService()
TimezoneCache.create()
示例5: _calendarTimezoneUpgrade_setup
def _calendarTimezoneUpgrade_setup(self):
TimezoneCache.create()
self.addCleanup(TimezoneCache.clear)
tz1 = Component(None, pycalendar=readVTZ("Etc/GMT+1"))
tz2 = Component(None, pycalendar=readVTZ("Etc/GMT+2"))
tz3 = Component(None, pycalendar=readVTZ("Etc/GMT+3"))
# Share user01 calendar with user03
calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
home3 = yield self.homeUnderTest(name="user03")
shared_name = yield calendar.shareWith(home3, _BIND_MODE_WRITE)
user_details = (
("user01", "calendar_1", tz1),
("user02", "calendar_1", tz2),
("user03", "calendar_1", None),
("user03", shared_name, tz3),
)
# Set dead properties on calendars
for user, calname, tz in user_details:
calendar = (yield self.calendarUnderTest(name=calname, home=user))
if tz:
calendar.properties()[PropertyName.fromElement(caldavxml.CalendarTimeZone)] = caldavxml.CalendarTimeZone.fromString(str(tz))
# Force data version to previous
home = (yield self.homeUnderTest(name=user))
ch = home._homeSchema
yield Update(
{ch.DATAVERSION: 4},
Where=ch.RESOURCE_ID == home._resourceID,
).on(self.transactionUnderTest())
yield self.commit()
for user, calname, tz in user_details:
calendar = (yield self.calendarUnderTest(name=calname, home=user))
self.assertEqual(calendar.getTimezone(), None)
self.assertEqual(PropertyName.fromElement(caldavxml.CalendarTimeZone) in calendar.properties(), tz is not None)
yield self.commit()
# Create "fake" entry for non-existent share
txn = self.transactionUnderTest()
calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
rp = schema.RESOURCE_PROPERTY
yield Insert(
{
rp.RESOURCE_ID: calendar._resourceID,
rp.NAME: PropertyName.fromElement(caldavxml.CalendarTimeZone).toString(),
rp.VALUE: caldavxml.CalendarTimeZone.fromString(str(tz3)).toxml(),
rp.VIEWER_UID: "user04",
}
).on(txn)
yield self.commit()
returnValue(user_details)
示例6: testRead
def testRead(self):
xmlfile = self.mktemp()
db1 = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db1.createNewDatabase()
self.assertTrue(os.path.exists(xmlfile))
db2 = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db2.readDatabase()
self.assertEqual(db1.dtstamp, db2.dtstamp)
self.assertEqual(len(db1.timezones), len(db2.timezones))
示例7: test_truncatedDec
def test_truncatedDec(self):
"""
Properties in components
"""
TimezoneCache.create("")
TimezoneCache.clear()
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
)
示例8: test_truncatedApr
def test_truncatedApr(self):
"""
Custom VTZ with truncated standard time - 2006. Daylight 2007 OK.
"""
TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
示例9: test_truncatedDec
def test_truncatedDec(self):
"""
Custom VTZ valid from 2007. Daylight 2007 OK.
"""
TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
)
示例10: test_truncatedApr
def test_truncatedApr(self):
"""
Properties in components
"""
TimezoneCache.create("")
TimezoneCache.clear()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
示例11: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
Properties in components
"""
oldtzid = getTzid("America/New_York")
try:
registerTzid("America/New_York", None)
tzcache = TimezoneCache()
tzcache.register()
self.doTest(
"TruncatedApr01.ics",
datetime.datetime(2007, 04, 01, 16, 0, 0, tzinfo=utc),
datetime.datetime(2007, 04, 01, 17, 0, 0, tzinfo=utc),
)
示例12: __init__
def __init__(self, records, populator, parameters, reactor, server,
principalPathTemplate, serializationPath, workerIndex=0, workerCount=1):
self._records = records
self.populator = populator
self.reactor = reactor
self.server = server
self.principalPathTemplate = principalPathTemplate
self.serializationPath = serializationPath
self._pop = self.populator.populate(parameters)
self._user = 0
self._stopped = False
self.workerIndex = workerIndex
self.workerCount = workerCount
self.clients = []
TimezoneCache.create()
示例13: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
Properties in components
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
)
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
)
示例14: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
VTZ loaded from std timezone DB. 2007 OK.
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
)
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
)
示例15: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
VTZ loaded from std timezone DB. 2007 OK.
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
DateTime(2007, 04, 01, 16, 0, 0, Timezone.UTCTimezone),
DateTime(2007, 04, 01, 17, 0, 0, Timezone.UTCTimezone),
)
self.doTest(
"TruncatedDec10.ics",
DateTime(2007, 12, 10, 17, 0, 0, Timezone.UTCTimezone),
DateTime(2007, 12, 10, 18, 0, 0, Timezone.UTCTimezone),
)