[CalendarServer-changes] [10160] CalendarServer/trunk/calendarserver
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 12 13:53:55 PST 2012
Revision: 10160
http://trac.calendarserver.org//changeset/10160
Author: cdaboo at apple.com
Date: 2012-12-12 13:53:55 -0800 (Wed, 12 Dec 2012)
Log Message:
-----------
Tweak client name in stats, fix unit test.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/logAnalysis.py
Added Paths:
-----------
CalendarServer/trunk/calendarserver/test/test_logAnalysis.py
Removed Paths:
-------------
CalendarServer/trunk/calendarserver/test/test_methodDescriptor.py
Modified: CalendarServer/trunk/calendarserver/logAnalysis.py
===================================================================
--- CalendarServer/trunk/calendarserver/logAnalysis.py 2012-12-12 17:18:55 UTC (rev 10159)
+++ CalendarServer/trunk/calendarserver/logAnalysis.py 2012-12-12 21:53:55 UTC (rev 10160)
@@ -332,18 +332,22 @@
-versionClients = (
+osClients = (
"Mac OS X/",
"iOS/",
+)
+
+versionClients = (
"iCal/",
"iPhone/",
- "CalendarAgent",
+ "CalendarAgent/",
"Calendar/",
"CoreDAV/",
"Safari/",
- "dataaccessd",
+ "dataaccessd/",
+ "Preferences/",
"curl/",
- "DAVKit",
+ "DAVKit/",
)
quickclients = (
@@ -358,16 +362,27 @@
def getAdjustedClientName(stats):
userAgent = stats["userAgent"]
- for client in versionClients:
+ os = ""
+ for client in osClients:
index = userAgent.find(client)
if index != -1:
l = len(client)
- endex = userAgent[index + l:].find(' ', index)
- return userAgent[index:] if endex == -1 else userAgent[index:endex + l]
+ endex = userAgent.find(' ', index + l)
+ os = (userAgent[index:] if endex == -1 else userAgent[index:endex]) + " "
+ for client in versionClients:
+ index = userAgent.find(client)
+ if index != -1:
+ if os:
+ return os + client[:-1]
+ else:
+ l = len(client)
+ endex = userAgent.find(' ', index + l)
+ return os + (userAgent[index:] if endex == -1 else userAgent[index:endex])
+
for quick, result in quickclients:
index = userAgent.find(quick)
if index != -1:
- return result
+ return os + result
return userAgent[:20]
Copied: CalendarServer/trunk/calendarserver/test/test_logAnalysis.py (from rev 10157, CalendarServer/trunk/calendarserver/test/test_methodDescriptor.py)
===================================================================
--- CalendarServer/trunk/calendarserver/test/test_logAnalysis.py (rev 0)
+++ CalendarServer/trunk/calendarserver/test/test_logAnalysis.py 2012-12-12 21:53:55 UTC (rev 10160)
@@ -0,0 +1,87 @@
+##
+# Copyright (c) 2012 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.
+##
+
+from twisted.trial.unittest import TestCase
+from calendarserver.logAnalysis import getAdjustedMethodName, \
+ getAdjustedClientName
+
+class LogAnalysis(TestCase):
+
+ def test_getAdjustedMethodName(self):
+ """
+ L{getAdjustedMethodName} returns the appropriate method.
+ """
+
+ data = (
+ ("PROPFIND", "/calendars/users/user01/", {}, "PROPFIND Calendar Home",),
+ ("PROPFIND", "/calendars/users/user01/", {"cached": "1"}, "PROPFIND cached Calendar Home",),
+ ("PROPFIND", "/calendars/users/user01/ABC/", {}, "PROPFIND Calendar",),
+ ("PROPFIND", "/calendars/users/user01/inbox/", {}, "PROPFIND Inbox",),
+ ("PROPFIND", "/addressbooks/users/user01/", {}, "PROPFIND Adbk Home",),
+ ("PROPFIND", "/addressbooks/users/user01/", {"cached": "1"}, "PROPFIND cached Adbk Home",),
+ ("PROPFIND", "/addressbooks/users/user01/ABC/", {}, "PROPFIND Adbk",),
+ ("PROPFIND", "/addressbooks/users/user01/inbox/", {}, "PROPFIND Adbk",),
+ ("PROPFIND", "/principals/users/user01/", {}, "PROPFIND Principals",),
+ ("PROPFIND", "/principals/users/user01/", {"cached": "1"}, "PROPFIND cached Principals",),
+ ("PROPFIND", "/.well-known/caldav", {}, "PROPFIND",),
+
+ ("REPORT(CalDAV:sync-collection)", "/calendars/users/user01/ABC/", {}, "REPORT cal-sync",),
+ ("REPORT(CalDAV:calendar-query)", "/calendars/users/user01/ABC/", {}, "REPORT cal-query",),
+
+ ("POST", "/calendars/users/user01/", {}, "POST Calendar Home",),
+ ("POST", "/calendars/users/user01/outbox/", {"recipients": "1"}, "POST Freebusy",),
+ ("POST", "/calendars/users/user01/outbox/", {}, "POST Outbox",),
+ ("POST", "/apns", {}, "POST apns",),
+
+ ("PUT", "/calendars/users/user01/calendar/1.ics", {}, "PUT ics",),
+ ("PUT", "/calendars/users/user01/calendar/1.ics", {"itip.requests": "1"}, "PUT Organizer",),
+ ("PUT", "/calendars/users/user01/calendar/1.ics", {"itip.reply": "1"}, "PUT Attendee",),
+
+ ("GET", "/calendars/users/user01/", {}, "GET Calendar Home",),
+ ("GET", "/calendars/users/user01/calendar/", {}, "GET Calendar",),
+ ("GET", "/calendars/users/user01/calendar/1.ics", {}, "GET ics",),
+
+ ("DELETE", "/calendars/users/user01/", {}, "DELETE Calendar Home",),
+ ("DELETE", "/calendars/users/user01/calendar/", {}, "DELETE Calendar",),
+ ("DELETE", "/calendars/users/user01/calendar/1.ics", {}, "DELETE ics",),
+ ("DELETE", "/calendars/users/user01/inbox/1.ics", {}, "DELETE inbox ics",),
+
+ ("ACL", "/calendars/users/user01/", {}, "ACL",),
+ )
+
+ for method, uri, extras, result in data:
+ extras["method"] = method
+ extras["uri"] = uri
+ self.assertEqual(getAdjustedMethodName(extras), result, "Failed getAdjustedMethodName: %s" % (result,))
+
+
+ def test_getAdjustedClientName(self):
+ """
+ L{getAdjustedClientName} returns the appropriate method.
+ """
+
+ data = (
+ ("Mac OS X/10.8.2 (12C60) CalendarAgent/55", "Mac OS X/10.8.2 CalendarAgent",),
+ ("CalendarStore/5.0.3 (1204.2); iCal/5.0.3 (1605.4); Mac OS X/10.7.5 (11G63b)", "Mac OS X/10.7.5 iCal",),
+ ("DAVKit/5.0 (767); iCalendar/5.0 (79); iPhone/4.2.1 8C148", "iPhone/4.2.1",),
+ ("iOS/6.0 (10A405) Preferences/1.0", "iOS/6.0 Preferences",),
+ ("iOS/6.0.1 (10A523) dataaccessd/1.0", "iOS/6.0.1 dataaccessd",),
+ ("InterMapper/5.4.3", "InterMapper",),
+ ("Mac OS X/10.8.2 (12C60) AddressBook/1167", "Mac OS X/10.8.2 AddressBook",),
+ )
+
+ for ua, result in data:
+ self.assertEqual(getAdjustedClientName({"userAgent": ua}), result, "Failed getAdjustedClientName: %s" % (ua,))
Deleted: CalendarServer/trunk/calendarserver/test/test_methodDescriptor.py
===================================================================
--- CalendarServer/trunk/calendarserver/test/test_methodDescriptor.py 2012-12-12 17:18:55 UTC (rev 10159)
+++ CalendarServer/trunk/calendarserver/test/test_methodDescriptor.py 2012-12-12 21:53:55 UTC (rev 10160)
@@ -1,67 +0,0 @@
-##
-# Copyright (c) 2012 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.
-##
-
-from twisted.trial.unittest import TestCase
-from calendarserver.methodDescriptor import getAdjustedMethodName
-
-class MethodDescriptor(TestCase):
- """
- Tests for L{getAdjustedMethodName}.
- """
- def test_getAdjustedMethodName(self):
- """
- L{getAdjustedMethodName} returns the appropriate method.
- """
-
- data = (
- ("PROPFIND", "/calendars/users/user01/", {}, "PROPFIND Calendar Home",),
- ("PROPFIND", "/calendars/users/user01/", {"cached": "1"}, "PROPFIND cached Calendar Home",),
- ("PROPFIND", "/calendars/users/user01/ABC/", {}, "PROPFIND Calendar",),
- ("PROPFIND", "/calendars/users/user01/inbox/", {}, "PROPFIND Inbox",),
- ("PROPFIND", "/addressbooks/users/user01/", {}, "PROPFIND Adbk Home",),
- ("PROPFIND", "/addressbooks/users/user01/", {"cached": "1"}, "PROPFIND cached Adbk Home",),
- ("PROPFIND", "/addressbooks/users/user01/ABC/", {}, "PROPFIND Adbk",),
- ("PROPFIND", "/addressbooks/users/user01/inbox/", {}, "PROPFIND Adbk",),
- ("PROPFIND", "/principals/users/user01/", {}, "PROPFIND Principals",),
- ("PROPFIND", "/principals/users/user01/", {"cached": "1"}, "PROPFIND cached Principals",),
- ("PROPFIND", "/.well-known/caldav", {}, "PROPFIND",),
-
- ("REPORT(CalDAV:sync-collection)", "/calendars/users/user01/ABC/", {}, "REPORT cal-sync",),
- ("REPORT(CalDAV:calendar-query)", "/calendars/users/user01/ABC/", {}, "REPORT cal-query",),
-
- ("POST", "/calendars/users/user01/", {}, "POST Calendar Home",),
- ("POST", "/calendars/users/user01/outbox/", {"recipients": "1"}, "POST Freebusy",),
- ("POST", "/calendars/users/user01/outbox/", {}, "POST Outbox",),
- ("POST", "/apns", {}, "POST apns",),
-
- ("PUT", "/calendars/users/user01/calendar/1.ics", {}, "PUT ics",),
- ("PUT", "/calendars/users/user01/calendar/1.ics", {"itip.requests": "1"}, "PUT Organizer",),
- ("PUT", "/calendars/users/user01/calendar/1.ics", {"itip.reply": "1"}, "PUT Attendee",),
-
- ("GET", "/calendars/users/user01/", {}, "GET Calendar Home",),
- ("GET", "/calendars/users/user01/calendar/", {}, "GET Calendar",),
- ("GET", "/calendars/users/user01/calendar/1.ics", {}, "GET ics",),
-
- ("DELETE", "/calendars/users/user01/", {}, "DELETE Calendar Home",),
- ("DELETE", "/calendars/users/user01/calendar/", {}, "DELETE Calendar",),
- ("DELETE", "/calendars/users/user01/calendar/1.ics", {}, "DELETE ics",),
- ("DELETE", "/calendars/users/user01/inbox/1.ics", {}, "DELETE inbox ics",),
-
- ("ACL", "/calendars/users/user01/", {}, "ACL",),
- )
-
- for method, uri, extras, result in data:
- self.assertEqual(getAdjustedMethodName(method, uri, extras), result, "Failed getAdjustedMethodName: %s" % (result,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121212/f2830002/attachment-0001.html>
More information about the calendarserver-changes
mailing list