[CalendarServer-changes] [8043] CalendarServer/trunk/contrib/tools/protocolanalysis.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 1 18:25:06 PDT 2011


Revision: 8043
          http://trac.macosforge.org/projects/calendarserver/changeset/8043
Author:   cdaboo at apple.com
Date:     2011-09-01 18:25:04 -0700 (Thu, 01 Sep 2011)
Log Message:
-----------
Additional request detail.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/tools/protocolanalysis.py

Modified: CalendarServer/trunk/contrib/tools/protocolanalysis.py
===================================================================
--- CalendarServer/trunk/contrib/tools/protocolanalysis.py	2011-09-01 20:17:24 UTC (rev 8042)
+++ CalendarServer/trunk/contrib/tools/protocolanalysis.py	2011-09-02 01:25:04 UTC (rev 8043)
@@ -131,7 +131,7 @@
 
     class LogLine(object):
         
-        def __init__(self, userid, logDateTime, logTime, method, uri, status, bytes, referer, client, extended):
+        def __init__(self, userid, logDateTime, logTime, method, uri, status, reqbytes, referer, client, extended):
 
             self.userid = userid
             self.logDateTime = logDateTime
@@ -139,7 +139,7 @@
             self.method = method
             self.uri = uri
             self.status = status
-            self.bytes = bytes
+            self.bytes = reqbytes
             self.referer = referer
             self.client = client
             self.extended = extended
@@ -439,7 +439,7 @@
         
         startPos += 4
         endPos = line.find(' ', startPos)
-        bytes = int(line[startPos:endPos])
+        reqbytes = int(line[startPos:endPos])
         
         startPos = endPos + 2
         endPos = line.find('"', startPos)
@@ -471,7 +471,7 @@
             items = line[startPos:].split()
             extended = dict([item.split('=') for item in items])
     
-        self.currentLine = CalendarServerLogAnalyzer.LogLine(userid, logDateTime, logTime, method, uri, status, bytes, referrer, client, extended)
+        self.currentLine = CalendarServerLogAnalyzer.LogLine(userid, logDateTime, logTime, method, uri, status, reqbytes, referrer, client, extended)
     
     def getClientAdjustedName(self):
     
@@ -511,36 +511,35 @@
     
     def getAdjustedMethodName(self):
 
-        uribits = self.currentLine.uri.split('/')[1:]
+        uribits = self.currentLine.uri.rstrip("/").split('/')[1:]
         if len(uribits) == 0:
             uribits = [self.currentLine.uri]
 
+        calendar_specials = ("dropbox", "notification", "freebusy", "outbox",)
+        adbk_specials = ("notification",)
+   
         if self.currentLine.method == "PROPFIND":
             
             cached = "cached" in self.currentLine.extended
 
             if uribits[0] == "calendars":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "PROPFIND%s Calendar Home" % ("-cached" if cached else "")
-                    elif uribits[3] == "inbox":
-                        return "PROPFIND Inbox"
-                    elif uribits[3] == ("dropbox", "freebusy"):
-                        pass
-                    elif uribits[3] == "notification":
-                        return "PROPFIND Notification"
-                    else:
+                if len(uribits) == 3:
+                    return "PROPFIND%s Calendar Home" % ("-cached" if cached else "")
+                elif len(uribits) > 3:
+                    if uribits[3] in calendar_specials:
+                        return "PROPFIND %s" % (uribits[3],)
+                    elif len(uribits) == 4:
                         return "PROPFIND Calendar"
     
             elif uribits[0] == "addressbooks":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "PROPFIND%s Adbk Home" % ("-cached" if cached else "")
-                    elif uribits[3] == "notification":
-                        return "PROPFIND Notification"
-                    else:
+                if len(uribits) == 3:
+                    return "PROPFIND%s Adbk Home" % ("-cached" if cached else "")
+                elif len(uribits) > 3:
+                    if uribits[3] in adbk_specials:
+                        return "PROPFIND %s" % (uribits[3],)
+                    elif len(uribits) == 4:
                         return "PROPFIND Adbk"
     
             elif uribits[0] == "directory":
@@ -576,7 +575,7 @@
             
         elif self.currentLine.method == "POST":
             
-            if uribits[0] == "calendars" and len(uribits) > 3 and uribits[3] == "outbox":
+            if uribits[0] == "calendars" and len(uribits) == 4 and uribits[3] == "outbox":
                 if "freebusy" in self.currentLine.extended:
                     return "POST Freebusy"
                 else:
@@ -587,10 +586,10 @@
                         return "POST Attendee"
             elif uribits[0] == "calendars":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "POST Calendar Home"
-                    elif uribits[3] == "outbox":
+                if len(uribits) == 3:
+                    return "POST Calendar Home"
+                elif len(uribits) == 4:
+                    if uribits[3] == "outbox":
                         if "freebusy" in self.currentLine.extended:
                             return "POST Freebusy"
                         else:
@@ -599,17 +598,17 @@
                                     return "POST Organizer"
                             else:
                                 return "POST Attendee"
-                    elif uribits[3] in ("dropbox", "freebusy", "notification"):
+                    elif uribits[3] in calendar_specials:
                         pass
                     else:
                         return "POST Calendar"
     
             elif uribits[0] == "addressbooks":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "POST Adbk Home"
-                    elif uribits[3] == "notification":
+                if len(uribits) == 3:
+                    return "POST Adbk Home"
+                elif len(uribits) == 4:
+                    if uribits[3] in adbk_specials:
                         pass
                     else:
                         return "POST Adbk"
@@ -619,38 +618,83 @@
             
         elif self.currentLine.method == "PUT":
             
-            if len(uribits) > 3 and uribits[3] == "dropbox":
-                return "PUT Dropbox"
-            
+            if uribits[0] == "calendars":
+                if len(uribits) > 3:
+                    if uribits[3] in calendar_specials:
+                        return "PUT %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "PUT Calendar"
+                    else:
+                        return "PUT ics"
+
+            elif uribits[0] == "addressbooks":
+                if len(uribits) > 3:
+                    if uribits[3] in adbk_specials:
+                        return "PUT %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "PUT Adbk"
+                    else:
+                        return "PUT vcf"
+        
         elif self.currentLine.method == "GET":
             
             if uribits[0] == "calendars":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "GET Calendar Home"
-                    elif uribits[3] in ("notification", "outbox"):
-                        pass
-                    elif uribits[3] == "dropbox":
-                        return "GET Dropbox"
-                    elif uribits[3] == "freebusy":
-                        return "GET Freebusy"
+                if len(uribits) == 3:
+                    return "GET Calendar Home"
+                elif len(uribits) > 3:
+                    if uribits[3] in calendar_specials:
+                        return "GET %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "GET Calendar"
+                    elif uribits[3] == "inbox":
+                        return "GET inbox ics"
                     else:
-                        return "GET Calendar"
+                        return "GET ics"
     
             elif uribits[0] == "addressbooks":
                 
-                if len(uribits) > 3:
-                    if uribits[3] == "":
-                        return "GET Adbk Home"
-                    elif uribits[3] == "notification":
-                        pass
+                if len(uribits) == 3:
+                    return "GET Adbk Home"
+                elif len(uribits) > 3:
+                    if uribits[3] in adbk_specials:
+                        return "GET %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "GET Adbk"
                     else:
-                        return "GET Adbk"
+                        return "GET vcf"
 
             elif uribits[0].startswith("timezones"):
                 return "GET Timezones"
 
+        elif self.currentLine.method == "DELETE":
+            
+            if uribits[0] == "calendars":
+                
+                if len(uribits) == 3:
+                    return "DELETE Calendar Home"
+                elif len(uribits) > 3:
+                    if uribits[3] in calendar_specials:
+                        return "DELETE %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "DELETE Calendar"
+                    elif uribits[3] == "inbox":
+                        return "DELETE inbox ics"
+                    else:
+                        return "DELETE ics"
+    
+            elif uribits[0] == "addressbooks":
+                
+                if len(uribits) == 3:
+                    return "DELETE Adbk Home"
+                elif len(uribits) > 3:
+                    if uribits[3] in adbk_specials:
+                        return "DELETE %s" % (uribits[3],)
+                    elif len(uribits) == 4:
+                        return "DELETE Adbk"
+                    else:
+                        return "DELETE vcf"
+
         return self.currentLine.method
     
     def getCountBucket(self, count, buckets):
@@ -1299,14 +1343,14 @@
                     row.append(value)
                 else:
                     if type(value) is float:
-                        format = "%.1f"
+                        fmt = "%.1f"
                     else:
-                        format = "%d"
+                        fmt = "%d"
                     if " TOTAL" in v:
                         total = v[" TOTAL"]
-                        row.append((format + " (%2d%%)") % (value, safePercent(value, total),))
+                        row.append((fmt + " (%2d%%)") % (value, safePercent(value, total),))
                     else:
-                        row.append(format % (value,))
+                        row.append(fmt % (value,))
             table.addRow(row)
     
         if " TOTAL" in rowNames:
@@ -1315,12 +1359,12 @@
             for k,v in sorted(data.iteritems(), key=lambda x:x[0].lower()):
                 value = v[" TOTAL"]
                 if type(value) is str:
-                    format = "%s"
+                    fmt = "%s"
                 elif type(value) is float:
-                    format = "%.1f"
+                    fmt = "%.1f"
                 else:
-                    format = "%d"
-                row.append(format % (value,))
+                    fmt = "%d"
+                row.append(fmt % (value,))
             table.addFooter(row)
     
         table.printTabDelimitedData() if doTabs else table.printTable()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110901/3a341fe1/attachment-0001.html>


More information about the calendarserver-changes mailing list