[CalendarServer-changes] [1698] CalendarClientSimulator/trunk/src

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 20 13:25:45 PDT 2007


Revision: 1698
          http://trac.macosforge.org/projects/calendarserver/changeset/1698
Author:   cdaboo at apple.com
Date:     2007-07-20 13:25:44 -0700 (Fri, 20 Jul 2007)

Log Message:
-----------
Add option to log output to a file (always used in multisim mode).

Modified Paths:
--------------
    CalendarClientSimulator/trunk/src/calendarclient.py
    CalendarClientSimulator/trunk/src/multisim.py
    CalendarClientSimulator/trunk/src/simulate.py

Modified: CalendarClientSimulator/trunk/src/calendarclient.py
===================================================================
--- CalendarClientSimulator/trunk/src/calendarclient.py	2007-07-20 18:45:33 UTC (rev 1697)
+++ CalendarClientSimulator/trunk/src/calendarclient.py	2007-07-20 20:25:44 UTC (rev 1698)
@@ -98,6 +98,7 @@
             },
             "calendar_data": {}
         }
+        self.logger = None
 
     def valid(self):
         if (self.server is None or
@@ -125,8 +126,14 @@
 
     def log(self, text):
         if self.verbose:
-            print text
+            if self.logger:
+                self.logger(text)
+            else:
+                print text
 
+    def setLogger(self, logger):
+        self.logger = logger
+
     def simulate(self):
         
         self.log("Starting CalendarClient simulation for user %s" % (self.user,))

Modified: CalendarClientSimulator/trunk/src/multisim.py
===================================================================
--- CalendarClientSimulator/trunk/src/multisim.py	2007-07-20 18:45:33 UTC (rev 1697)
+++ CalendarClientSimulator/trunk/src/multisim.py	2007-07-20 20:25:44 UTC (rev 1698)
@@ -57,6 +57,7 @@
     cache = "../data/user%02d.plist"
     clearcache = False
     verbose = False
+    logfile = "../logs/user%02d.txt"
     
     options, args = getopt.getopt(sys.argv[1:], "h", [
         "number=",
@@ -123,6 +124,8 @@
             cmd.append("--clear-cache")
         if verbose:
             cmd.append("--verbose")
+            cmd.append("--logfile")
+            cmd.append(logfile % (i,))
 
         # Add random delay
         delay = randint(1,1000)

Modified: CalendarClientSimulator/trunk/src/simulate.py
===================================================================
--- CalendarClientSimulator/trunk/src/simulate.py	2007-07-20 18:45:33 UTC (rev 1697)
+++ CalendarClientSimulator/trunk/src/simulate.py	2007-07-20 20:25:44 UTC (rev 1698)
@@ -35,6 +35,7 @@
     --cache           path to .plist file to cache data [Optional]
     --clear-cache     clear the cache when starting up [Optional]
     --verbose         print out activity log
+    --logfile         file to write activity log to [Optional]
     
     -h, --help        print this help and exit
 """
@@ -43,6 +44,7 @@
 if __name__ == '__main__':
 
     client = CalendarClient()
+    logfile = None
     
     options, args = getopt.getopt(sys.argv[1:], "h", [
         "server=",
@@ -54,6 +56,7 @@
         "cache=",
         "clear-cache",
         "verbose",
+        "logfile=",
         "help"
     ])
 
@@ -75,10 +78,19 @@
             client.invitesperday = int(value)
         elif option == "--cache":
             client.cache = value
+        elif option == "--clear-cache":
+            client.clearcache = True
         elif option == "--verbose":
             client.verbose = True
-        elif option == "--clear-cache":
-            client.clearcache = True
+        elif option == "--logfile":
+            
+
+            def logIt(text):
+                logfile = open(value, "a")
+                logfile.write(text + "\n")
+                
+            client.setLogger(logIt)
+
         else:
             print "Unrecognized option: %s" % (option,)
             usage()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070720/3aafb249/attachment.html


More information about the calendarserver-changes mailing list