[LON-CAPA-cvs] cvs: loncom /metadata_database parse_activity_log.pl

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 15 Sep 2004 21:11:07 -0000


matthew		Wed Sep 15 17:11:07 2004 EDT

  Modified files:              
    /loncom/metadata_database	parse_activity_log.pl 
  Log:
  Added option to make a backup of the activity.log.
  
  
Index: loncom/metadata_database/parse_activity_log.pl
diff -u loncom/metadata_database/parse_activity_log.pl:1.4 loncom/metadata_database/parse_activity_log.pl:1.5
--- loncom/metadata_database/parse_activity_log.pl:1.4	Wed Aug 25 11:55:17 2004
+++ loncom/metadata_database/parse_activity_log.pl	Wed Sep 15 17:11:06 2004
@@ -2,7 +2,7 @@
 #
 # The LearningOnline Network
 #
-# $Id: parse_activity_log.pl,v 1.4 2004/08/25 15:55:17 matthew Exp $
+# $Id: parse_activity_log.pl,v 1.5 2004/09/15 21:11:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,12 +44,13 @@
 use Time::HiRes();
 use Getopt::Long();
 use IO::File;
-
+use File::Copy;
 #
 # Determine parameters
-my ($help,$course,$domain,$drop,$file,$time_run,$nocleanup,$log);
+my ($help,$course,$domain,$drop,$file,$time_run,$nocleanup,$log,$backup);
 &Getopt::Long::GetOptions( "course=s"  => \$course,
                            "domain=s"  => \$domain,
+                           "backup"    => \$backup,
                            "help"      => \$help,
                            "logfile=s" => \$file,
                            "timerun"   => \$time_run,
@@ -64,6 +65,8 @@
 Parameters:
    course             Required
    domain             Optional
+   backup             optional   if present, backup the activity log file
+                                 before processing it
    drop               optional   if present, drop all course 
                                  specific activity log tables.
    file               optional   Specify the file to parse, including path
@@ -140,6 +143,7 @@
 if (-e $sourcefilename) {
     $logthis->('renaming '.$sourcefilename.' to '.$newfilename);
     rename($sourcefilename,$newfilename);
+    Copy($newfilename,$newfilename.'.'.time) if ($backup);
     $logthis->("renamed $sourcefilename to $newfilename");
 } else {
     my $command = 'touch '.$newfilename;