[LON-CAPA-cvs] cvs: modules /gerd/harvesting getdata.pl
www
www@source.lon-capa.org
Fri, 17 Jun 2011 18:37:19 -0000
www Fri Jun 17 18:37:19 2011 EDT
Modified files:
/modules/gerd/harvesting getdata.pl
Log:
Forking now
Index: modules/gerd/harvesting/getdata.pl
diff -u modules/gerd/harvesting/getdata.pl:1.2 modules/gerd/harvesting/getdata.pl:1.3
--- modules/gerd/harvesting/getdata.pl:1.2 Wed Jun 15 00:24:56 2011
+++ modules/gerd/harvesting/getdata.pl Fri Jun 17 18:37:19 2011
@@ -1,20 +1,39 @@
use strict;
-my $offset=0;
-
use lib '/home/httpd/lib/perl';
use Apache::lonnet;
+use POSIX;
+
+my $start=shift;
+my $end=shift;
+
+print "Start: $start End: $end\n";
+
+# ---------------------------------------------------- Fork once and dissociate
+
+my $fpid=fork;
+exit if $fpid;
+die "Couldn't fork: $!" unless defined ($fpid);
+
+POSIX::setsid() or die "Can't start new session: $!";
+
+# -------------------------------------------------------------- On our own now
+
+
my $count=0;
+open(LOG,">matrix/rawsubs".$start.'_'.$end.".log");
+print LOG "Starting PID $$ from $start to $end\n";
open(IN,"matrix/allstudents.dat");
-print("Opened reading\n");
-open(OUT,">matrix/rawsubs.dat");
-print("Opened writing\n");
+print LOG "Opened reading\n";
+open(OUT,">matrix/rawsubs".$start.'_'.$end.".dat");
+print LOG "Opened writing\n";
while (my $line=<IN>) {
my ($cnum,$cdom,$uname,$udom)=split(/\:/,$line);
$count++;
- if ($count<$offset) { print "."; next;}
+ if ($count<$start) { next; }
+ if ($count>$end) { next; }
my %data=&Apache::lonnet::dump($cdom.'_'.$cnum,$udom,$uname);
- print "==== $count = $udom = $uname =$cnum = $cdom ====\n";
+ print LOG "==== $count = $udom = $uname =$cnum = $cdom ====\n";
foreach my $record (keys(%data)) {
if ($record=~/^version\:(.+)$/) {
my $symb=$1;
@@ -27,15 +46,15 @@
if ($item=~/^resource\.(.+)\.tries$/) {
my $part=$1;
if ($data{"$version:$symb:resource.$part.regrader"}) {
- print "Regraded\n";
+ print LOG "Regraded\n";
next;
}
my $tries=$data{"$version:$symb:resource.$part.tries"};
my $solved=$data{"$version:$symb:resource.$part.solved"};
my $timestamp=$data{"$version:$symb:timestamp"};
unless ($tries && $solved && $timestamp) {
- print "=========== ERROR: $count Symb: $symb $uname $udom $cnum $cdom =====================\n";
- print "==== Version $version Tries: $tries Solved: $solved Time: $timestamp Keys: $keys ==\n";
+ print LOG "=========== ERROR: $count Symb: $symb $uname $udom $cnum $cdom =====================\n";
+ print LOG "==== Version $version Tries: $tries Solved: $solved Time: $timestamp Keys: $keys ==\n";
next;
}
print OUT "$uname\t$udom\t$cnum\t$cdom\t$url\t$part\t$instance\t$tries\t$solved\t$timestamp\n";
@@ -46,3 +65,5 @@
}
close(OUT);
close(IN);
+print LOG "Done\n";
+close(LOG);