[CalendarServer-changes] [4488] CalendarServer/trunk/calendarserver/tools/anonymize.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 6 16:22:50 PDT 2009
Revision: 4488
http://trac.macosforge.org/projects/calendarserver/changeset/4488
Author: sagen at apple.com
Date: 2009-08-06 16:22:50 -0700 (Thu, 06 Aug 2009)
Log Message:
-----------
Handle newer calendar server data in __uids__/XX/YY/<GUID> form
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/anonymize.py
Modified: CalendarServer/trunk/calendarserver/tools/anonymize.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/anonymize.py 2009-08-06 21:19:46 UTC (rev 4487)
+++ CalendarServer/trunk/calendarserver/tools/anonymize.py 2009-08-06 23:22:50 UTC (rev 4488)
@@ -131,25 +131,43 @@
if not os.path.exists(destUidHomes):
os.makedirs(destUidHomes)
- homeNames = os.listdir(sourceUidHomes)
- totalHomes = len(homeNames)
- print "Processing %d calendar homes..." % (totalHomes,)
+ homeList = []
- for home in homeNames:
- quotaUsed = 0
+ for first in os.listdir(sourceUidHomes):
+ if len(first) == 2:
+ firstPath = os.path.join(sourceUidHomes, first)
+ for second in os.listdir(firstPath):
+ if len(second) == 2:
+ secondPath = os.path.join(firstPath, second)
+ for home in os.listdir(secondPath):
+ record = directoryMap.lookupCUA(home)
+ if not record:
+ print "Couldn't find %s, skipping." % (home,)
+ continue
+ sourceHome = os.path.join(secondPath, home)
+ destHome = os.path.join(destUidHomes,
+ record['guid'][0:2], record['guid'][2:4],
+ record['guid'])
+ homeList.append((sourceHome, destHome, record))
- if len(home) <= 2:
- continue
- sourceHome = os.path.join(sourceUidHomes, home)
- if not os.path.isdir(sourceHome):
- continue
+ else:
+ home = first
+ sourceHome = os.path.join(sourceUidHomes, home)
+ if not os.path.isdir(sourceHome):
+ continue
+ record = directoryMap.lookupCUA(home)
+ if not record:
+ print "Couldn't find %s, skipping." % (home,)
+ continue
+ sourceHome = os.path.join(sourceUidHomes, home)
+ destHome = os.path.join(destUidHomes, record['guid'])
+ homeList.append((sourceHome, destHome, record))
- record = directoryMap.lookupCUA(home)
- if not record:
- print "Couldn't find %s, skipping." % (home,)
- continue
+ print "Processing %d calendar homes..." % (len(homeList),)
- destHome = os.path.join(destUidHomes, record['guid'])
+ for sourceHome, destHome, record in homeList:
+ quotaUsed = 0
+
if not os.path.exists(destHome):
os.makedirs(destHome)
@@ -280,7 +298,7 @@
prop.value = "urn:uuid:%s" % (record['guid'],)
if prop.params.has_key('X-CALENDARSERVER-EMAIL'):
prop.params['X-CALENDARSERVER-EMAIL'] = (record['email'],)
- if prop.params.has_key('EMAIL'):
+ else:
prop.params['EMAIL'] = (record['email'],)
prop.params['CN'] = (record['name'],)
except KeyError:
@@ -377,11 +395,12 @@
self.counts[internalType] += 1
count = self.counts[internalType]
+ namePrefix = randomName(6)
record = {
- 'guid' : str(uuid.uuid4()),
- 'name' : "%s %d" % (self.strings[internalType][1], count,),
+ 'guid' : str(uuid.uuid4()).upper(),
+ 'name' : "%s %s %d" % (namePrefix, self.strings[internalType][1], count,),
'recordName' : "%s%d" % (self.strings[internalType][1], count,),
- 'email' : ("%s%d at example.com" % (internalType, count,)),
+ 'email' : ("%s_%s%d at example.com" % (namePrefix, internalType, count,)),
'type' : self.strings[internalType][0],
'cua' : cua,
}
@@ -479,5 +498,13 @@
+nameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+def randomName(length):
+ l = []
+ for i in xrange(length):
+ l.append(random.choice(nameChars))
+ return "".join(l)
+
+
if __name__ == "__main__":
main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090806/3b353c48/attachment.html>
More information about the calendarserver-changes
mailing list