[LON-CAPA-cvs] cvs: loncom /debugging_tools activity_to_accesscount.pl

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 14 Nov 2003 20:42:34 -0000


matthew		Fri Nov 14 15:42:34 2003 EDT

  Modified files:              
    /loncom/debugging_tools	activity_to_accesscount.pl 
  Log:
  Store the filenames escaped.
  Take the target assesscount db file on the command line.
  
  
Index: loncom/debugging_tools/activity_to_accesscount.pl
diff -u loncom/debugging_tools/activity_to_accesscount.pl:1.2 loncom/debugging_tools/activity_to_accesscount.pl:1.3
--- loncom/debugging_tools/activity_to_accesscount.pl:1.2	Fri Nov 14 14:41:38 2003
+++ loncom/debugging_tools/activity_to_accesscount.pl	Fri Nov 14 15:42:34 2003
@@ -9,13 +9,19 @@
     return $str;
 }
 
+sub escape {
+    my $str=shift;
+    $str =~ s/(\W)/"%".unpack('H2',$1)/eg;
+    return $str;
+}
+
 my %resourceaccess;
 
 sub main {
     my $file=$ARGV[0];
-    my ($path) = ($file =~ m:(.*)/activity\.log$:);
-    my $target = $path.'/nohist_accesscount.db';
-    print STDERR "source: $file\ntarget: $target\n";
+    my $target = $ARGV[1];
+    my ($owner) = ($target =~ m:.*/(.*)/nohist_accesscount.db:);
+    print STDERR "source: $file\ntarget: $target\nowner: $owner\n";
     my %accessDB;
     my $accesstime = 0;
     my $starttime = time;
@@ -66,7 +72,7 @@
                 next; 
             }
             $resource = &unescape($resource);
-            if ($resource !~ m:(.*)/(.*)/: || $resource =~ m:/prtspool/:) {
+            if ($resource !~ m:/$owner/:) {
                 next;
             }
             if ($resource =~ /___\d+___/) {
@@ -84,6 +90,7 @@
     }
     #
     while (my ($resource,$count) = each(%resourceaccess)) {
+        $resource = &escape($resource);
         if (exists($accessDB{$resource})) {
             $accessDB{$resource}+=$count;
         } else {