[CalendarServer-changes] [6635] CalDAVTester/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 15 12:01:00 PST 2010
Revision: 6635
http://trac.macosforge.org/projects/calendarserver/changeset/6635
Author: cdaboo at apple.com
Date: 2010-11-15 12:00:58 -0800 (Mon, 15 Nov 2010)
Log Message:
-----------
Remove the "populate" feature that has not been used in a while and is broken anyway.
Removed Paths:
-------------
CalDAVTester/trunk/scripts/tests/CalDAV/populate.xml
CalDAVTester/trunk/src/account.py
CalDAVTester/trunk/src/populate.py
Deleted: CalDAVTester/trunk/scripts/tests/CalDAV/populate.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/populate.xml 2010-11-15 20:00:30 UTC (rev 6634)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/populate.xml 2010-11-15 20:00:58 UTC (rev 6635)
@@ -1,46 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-
-<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
-
-<!--
- Copyright (c) 2006-2010 Apple Inc. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<populate>
- <description>Populate a TwistedCalDAV server with user accounts.</description>
- <path>/Users/</path>
-
- <account count='1'>
- <name>User-1.10</name>
- <calendars>
- <name>calendar</name>
- <datasource count='1' mode='all'>Resource/CalDAV/Populate/</datasource>
- </calendars>
- </account>
- <account count='1'>
- <name>User-1.100</name>
- <calendars>
- <name>calendar</name>
- <datasource count='10' mode='all'>Resource/CalDAV/Populate/</datasource>
- </calendars>
- </account>
- <account count='1'>
- <name>User-1.1000</name>
- <calendars>
- <name>calendar</name>
- <datasource count='100' mode='all'>Resource/CalDAV/Populate/</datasource>
- </calendars>
- </account>
-</populate>
Deleted: CalDAVTester/trunk/src/account.py
===================================================================
--- CalDAVTester/trunk/src/account.py 2010-11-15 20:00:30 UTC (rev 6634)
+++ CalDAVTester/trunk/src/account.py 2010-11-15 20:00:58 UTC (rev 6635)
@@ -1,187 +0,0 @@
-##
-# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-"""
-Class that encapsulates the account information for populating a CalDAV server.
-"""
-
-from hashlib import md5
-from utilities import webdav
-import copy
-import os
-import src.xmlDefs
-
-class account( object ):
- """
- Maintains information about an account on the server.
- """
- __slots__ = ['name', 'count', 'countarg', 'calendars', 'datasource', 'dataall', 'datasubstitute']
-
- def __init__( self ):
- self.name = ""
- self.count = 1
- self.countarg = None
- self.calendars = []
- self.datasource = None
- self.dataall = True
- self.datasubstitute = True
-
- def expand(self):
- """
- Create a list of new accounts from this one by expanding the
- name list using the supplied count and countargs.
- """
- accounts = []
- if (self.count > 1) and (self.name.find(self.countarg)):
- if self.count >= 10:
- strfmt = "%0" + str(len(str(self.count))) + "d"
- else:
- strfmt = "%d"
- name = self.name.replace(self.countarg, strfmt)
- for i in range(1, self.count + 1):
- expname = (name % i)
- newacct = copy.copy(self)
- newacct.name = expname
- accounts.append(newacct)
- else:
- accounts.append(self)
- return accounts
-
- def generate(self, server_info, path):
- """
- Create the necessary resources on the server for this account.
- """
-
- # Create user collection
- path += self.name + "/"
- if not webdav.ResourceExists(server_info, path).run():
- if not webdav.MakeCollection(server_info, path).run():
- raise ValueError("Could not make collection for user %s" % (self.name,))
-
- # Create calendars within user collection
- for calendar in self.calendars:
- calendar.generate(server_info, path)
-
- def remove(self, server_info, path):
- """
- Remove the generated resources on the server for this account.
- """
- path += self.name + "/"
- webdav.Delete(server_info, path).run()
-
- def parseXML( self, node ):
- self.count = int(node.get(src.xmlDefs.ATTR_COUNT, src.xmlDefs.ATTR_DEFAULT_COUNT))
- self.countarg = node.get(src.xmlDefs.ATTR_COUNTARG, src.xmlDefs.ATTR_DEFAULT_COUNTARG)
-
- for child in node.getchildren():
- if child.tag == src.xmlDefs.ELEMENT_NAME:
- self.name = child.text
- elif child.tag == src.xmlDefs.ELEMENT_CALENDARS:
- cal = calendar(self)
- cal.parseXML(child)
- self.calendars.extend(cal.expand())
-
-
-class calendar(object):
- __slots__ = ['account', 'name', 'count', 'countarg', 'datasource', 'datacount', 'datacountarg', 'dataall', 'datasubstitute']
-
- def __init__(self, account):
- self.account = account
- self.name = None
- self.count = 1
- self.countarg = None
- self.datasource = None
- self.datacount = 1
- self.datacountarg = None
- self.dataall = True
- self.datasubstitute = True
-
- def expand(self):
- """
- Create a list of new calendars from this one by expanding the
- name list using the supplied count and countargs.
- """
- calendars = []
- if (self.count > 1) and (self.name.find(self.countarg)):
- if self.count >= 10:
- strfmt = "%0" + str(len(str(self.count))) + "d"
- else:
- strfmt = "%d"
- name = self.name.replace(self.countarg, strfmt)
- for i in range(1, self.count + 1):
- expname = (name % i)
- newcal = copy.copy(self)
- newcal.name = expname
- calendars.append(newcal)
- else:
- calendars.append(self)
- return calendars
-
- def generate(self, server_info, path):
- """
- Create the necessary resources on the server for this calendar.
- """
-
- # Create calendars within user collection
- cpath = path + self.name + "/"
- if not webdav.ResourceExists(server_info, cpath).run():
- if not webdav.MakeCalendar(server_info, cpath).run():
- raise ValueError("Could not make calendar collection %s for user %s" % (self.name, account.name))
-
- # Now generate data in the calendar
- if not self.datasource:
- return
- dir = os.getcwd() + "/" + self.datasource
- dataitems = os.listdir(dir)
- for item in dataitems:
- if item.endswith(".ics"):
- fname = dir + item
- self.generateItems(server_info, cpath, fname)
-
- def generateItems(self, server_info, cpath, item):
- """
- Generate one or more iCalendar resources from the supplied data file,
- doing appropriate substitutions in the data.
- """
- file_object = open(item)
- try:
- caldata = file_object.read( )
- finally:
- file_object.close( )
-
- if self.datacount == 1:
- rpath = cpath + md5(cpath + item + str(self.count)).hexdigest() + ".ics"
- webdav.Put(server_info, rpath, "text/calendar; charset=utf-8", caldata).run()
- else:
- for ctr in range(1, self.datacount + 1):
- data = caldata.replace(self.datacountarg, str(ctr))
- rpath = cpath + md5(cpath + item + str(self.count) + str(ctr)).hexdigest() + ".ics"
- webdav.Put(server_info, rpath, "text/calendar; charset=utf-8", data).run()
-
- def parseXML( self, node ):
- self.count = int(node.get(src.xmlDefs.ATTR_COUNT, src.xmlDefs.ATTR_DEFAULT_COUNT))
- self.countarg = node.get(src.xmlDefs.ATTR_COUNTARG, src.xmlDefs.ATTR_DEFAULT_COUNTARG)
- self.dataall = src.xmlDefs.ATTR_MODE == src.xmlDefs.ATTR_VALUE_ALL
- self.datasubstitute = src.xmlDefs.ATTR_SUBSTITUTIONS == src.xmlDefs.ATTR_VALUE_YES
-
- for child in node.getchildren():
- if child.tag == src.xmlDefs.ELEMENT_NAME:
- self.name = child.text
- elif child.tag == src.xmlDefs.ELEMENT_DATASOURCE:
- self.datacount = int(child.get(src.xmlDefs.ATTR_COUNT, src.xmlDefs.ATTR_DEFAULT_COUNT))
- self.datacountarg = child.get(src.xmlDefs.ATTR_COUNTARG, src.xmlDefs.ATTR_DEFAULT_COUNTARG)
- self.datasource = child.text
-
Deleted: CalDAVTester/trunk/src/populate.py
===================================================================
--- CalDAVTester/trunk/src/populate.py 2010-11-15 20:00:30 UTC (rev 6634)
+++ CalDAVTester/trunk/src/populate.py 2010-11-15 20:00:58 UTC (rev 6635)
@@ -1,74 +0,0 @@
-##
-# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-"""
-Class that encapsulates the information for populating a CalDAV server.
-"""
-
-from src.account import account
-from utilities import webdav
-import src.xmlDefs
-
-class populate( object ):
- """
- Maintains information about accounts to be created on the server.
- """
- __slots__ = ['manager', 'description', 'path', 'accounts']
-
- def __init__( self, manager ):
- self.manager = manager
- self.description = ""
- self.path = None
- self.accounts = []
-
- def parseXML( self, node ):
- for child in node.getchildren():
- if child.tag == src.xmlDefs.ELEMENT_DESCRIPTION:
- self.description = child.text
- elif child.tag == src.xmlDefs.ELEMENT_PATH:
- self.path = child.text
- elif child.tag == src.xmlDefs.ELEMENT_ACCOUNT:
- acct = account()
- acct.parseXML(child)
- self.accounts.extend(acct.expand())
-
- def generateAccounts(self):
- """
- Generate each account on the server.
- """
-
- # Verify path and create it on the server
- if not self.path:
- raise ValueError("Path for account population not set up.")
-
- if not webdav.ResourceExists(self.manager.server_info, self.path).run():
- if not webdav.MakeCollection(self.manager.server_info, self.path).run():
- raise ValueError("Could not make collection for population set up")
-
- for account in self.accounts:
- self.manager.log("Generating account: %s" % (account.name,))
- account.generate(self.manager.server_info, self.path)
-
- def removeAccounts(self):
- """
- Remove each account on the server.
- """
- for account in self.accounts:
- self.manager.log("Removing account: %s" % (account.name,))
- account.remove(self.manager.server_info, self.path)
-
- # Finally remove path
- webdav.Delete(self.manager.server_info, self.path).run()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101115/ecf57819/attachment-0001.html>
More information about the calendarserver-changes
mailing list