[LON-CAPA-cvs] cvs: loncom /homework imageresponse.pm randomlabel.pm /interface londocs.pm /lonnet/perl lonnet.pm lonrep.pm lonuploadrep.pm /xml londefdef.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 16 Mar 2005 21:35:18 -0000


This is a MIME encoded message

--raeburn1111008918
Content-Type: text/plain

raeburn		Wed Mar 16 16:35:18 2005 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
    /loncom/homework	imageresponse.pm randomlabel.pm 
    /loncom/interface	londocs.pm 
    /loncom/lonnet/perl	lonnet.pm lonrep.pm lonuploadrep.pm 
  Log:
  lonnet::repcopy() and lonnet::repcopy_userfile() now return strings, with simplified lower-case-only responses, for consistency with other return values from lonnet functions.
  
  
--raeburn1111008918
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20050316163518.txt"

Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.263 loncom/xml/londefdef.pm:1.264
--- loncom/xml/londefdef.pm:1.263	Tue Mar 15 06:26:34 2005
+++ loncom/xml/londefdef.pm	Wed Mar 16 16:35:17 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.263 2005/03/15 11:26:34 foxr Exp $
+# $Id: londefdef.pm,v 1.264 2005/03/16 21:35:17 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -3757,7 +3757,7 @@
     $pssrc  =~ s/\.(gif|jpg|jpeg|png)$/.ps/i;
     if (not -e $epssrc && not -e $pssrc) {
 	my $result=&Apache::lonnet::repcopy($epssrc);
-	if ($result ne 'OK') { &Apache::lonnet::repcopy($pssrc); }
+	if ($result ne 'ok') { &Apache::lonnet::repcopy($pssrc); }
     }
     return '';
 }
@@ -3834,14 +3834,14 @@
     &Apache::lonxml::debug("Filelocation gives; $src <BR />");
     if (! -e $src) {
 	&Apache::lonxml::debug("$src does not exist");
-	if (&Apache::lonnet::repcopy($src) ne 'OK' ) {
+	if (&Apache::lonnet::repcopy($src) ne 'ok' ) {
 	    &Apache::lonxml::debug("Repcopy of $src failed (1)");
 	    #if replication failed try to find ps file
 	    $src=~s/\.eps$/\.ps/;
 	    &Apache::lonxml::debug("Now looking for $src");
 	    #if no ps file try to replicate it
 	    if (not -e $src &&
-		&Apache::lonnet::repcopy($src) ne 'OK') {
+		&Apache::lonnet::repcopy($src) ne 'ok') {
 		&Apache::lonxml::debug("Failed to find or replicate $src");
 
 		#if replication failed try to produce eps file dynamically
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.63 loncom/homework/imageresponse.pm:1.64
--- loncom/homework/imageresponse.pm:1.63	Wed Mar  2 17:26:36 2005
+++ loncom/homework/imageresponse.pm	Wed Mar 16 16:35:17 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.63 2005/03/02 22:26:36 raeburn Exp $
+# $Id: imageresponse.pm,v 1.64 2005/03/16 21:35:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -227,7 +227,7 @@
 	}
     } else {
 	$image=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$image);
-	if (&Apache::lonnet::repcopy($image) ne 'OK') {
+	if (&Apache::lonnet::repcopy($image) ne 'ok') {
 	    $image='/home/httpd/html/adm/lonKaputt/lonlogo_broken.gif';
 	}
     }
Index: loncom/homework/randomlabel.pm
diff -u loncom/homework/randomlabel.pm:1.65 loncom/homework/randomlabel.pm:1.66
--- loncom/homework/randomlabel.pm:1.65	Wed Mar  2 17:26:36 2005
+++ loncom/homework/randomlabel.pm	Wed Mar 16 16:35:17 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # random labelling tool
 #
-# $Id: randomlabel.pm,v 1.65 2005/03/02 22:26:36 raeburn Exp $
+# $Id: randomlabel.pm,v 1.66 2005/03/16 21:35:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -91,7 +91,7 @@
     my $bgimg= &Apache::lonxml::get_param('bgimg',$parstack,$safeeval);
     if ( defined($bgimg) && $bgimg !~ /^http:/ ) {
 	$bgimg=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$bgimg);
-	if (&Apache::lonnet::repcopy($bgimg) ne 'OK') {
+	if (&Apache::lonnet::repcopy($bgimg) ne 'ok') {
 	    $bgimg='/home/httpd/html/adm/lonKaputt/lonlogo_broken.gif';
 	}
     }
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.171 loncom/interface/londocs.pm:1.172
--- loncom/interface/londocs.pm:1.171	Thu Mar 10 11:11:32 2005
+++ loncom/interface/londocs.pm	Wed Mar 16 16:35:17 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.171 2005/03/10 16:11:32 www Exp $
+# $Id: londocs.pm,v 1.172 2005/03/16 21:35:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1501,7 +1501,7 @@
        if ($url=~/^\/res\//) {
 	  my $result=&Apache::lonnet::repcopy(
                               &Apache::lonnet::filelocation('',$url));
-          if ($result eq 'OK') {
+          if ($result eq 'ok') {
              $r->print('<font color="green">'.&mt('ok').'</font>');
              $r->rflush();
              &Apache::lonnet::countacc($url);
@@ -1540,9 +1540,9 @@
                     &checkonthis($r,$_,$level+1);
                  }
              }
-          } elsif ($result eq 'HTTP_SERVICE_UNAVAILABLE') {
+          } elsif ($result eq 'unavailable') {
              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
-          } elsif ($result eq 'HTTP_NOT_FOUND') {
+          } elsif ($result eq 'not_found') {
 	      unless ($url=~/\$/) {
 		  $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
 	      } else {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.606 loncom/lonnet/perl/lonnet.pm:1.607
--- loncom/lonnet/perl/lonnet.pm:1.606	Thu Mar 10 14:10:30 2005
+++ loncom/lonnet/perl/lonnet.pm	Wed Mar 16 16:35:17 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.606 2005/03/10 19:10:30 matthew Exp $
+# $Id: lonnet.pm,v 1.607 2005/03/16 21:35:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -994,27 +994,27 @@
 sub repcopy {
     my $filename=shift;
     $filename=~s/\/+/\//g;
-    if ($filename=~m|^/home/httpd/html/adm/|) { return 'OK'; }
-    if ($filename=~m|^/home/httpd/html/lonUsers/|) { return 'OK'; }
+    if ($filename=~m|^/home/httpd/html/adm/|) { return 'ok'; }
+    if ($filename=~m|^/home/httpd/html/lonUsers/|) { return 'ok'; }
     if ($filename=~m|^/home/httpd/html/userfiles/| or
 	$filename=~m|^/*uploaded/|) { 
 	return &repcopy_userfile($filename);
     }
     $filename=~s/[\n\r]//g;
     my $transname="$filename.in.transfer";
-    if ((-e $filename) || (-e $transname)) { return 'OK'; }
+    if ((-e $filename) || (-e $transname)) { return 'ok'; }
     my $remoteurl=subscribe($filename);
     if ($remoteurl =~ /^con_lost by/) {
 	   &logthis("Subscribe returned $remoteurl: $filename");
-           return 'HTTP_SERVICE_UNAVAILABLE';
+           return 'unavailable';
     } elsif ($remoteurl eq 'not_found') {
 	   #&logthis("Subscribe returned not_found: $filename");
-	   return 'HTTP_NOT_FOUND';
+	   return 'not_found';
     } elsif ($remoteurl =~ /^rejected by/) {
 	   &logthis("Subscribe returned $remoteurl: $filename");
-           return 'FORBIDDEN';
+           return 'forbidden';
     } elsif ($remoteurl eq 'directory') {
-           return 'OK';
+           return 'ok';
     } else {
         my $author=$filename;
         $author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/;
@@ -1025,7 +1025,7 @@
            my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
            if ($path ne "$perlvar{'lonDocRoot'}/res") {
                &logthis("Malconfiguration for replication: $filename");
-	       return 'HTTP_BAD_REQUEST';
+	       return 'bad_request';
            }
            my $count;
            for ($count=5;$count<$#parts;$count++) {
@@ -1042,7 +1042,7 @@
                my $message=$response->status_line;
                &logthis("<font color=blue>WARNING:"
                        ." LWP get: $message: $filename</font>");
-               return 'HTTP_SERVICE_UNAVAILABLE';
+               return 'unavailable';
            } else {
 	       if ($remoteurl!~/\.meta$/) {
                   my $mrequest=new HTTP::Request('GET',$remoteurl.'.meta');
@@ -1054,7 +1054,7 @@
                   }
 	       }
                rename($transname,$filename);
-               return 'OK';
+               return 'ok';
            }
        }
     }
@@ -5259,7 +5259,7 @@
 sub repcopy_userfile {
     my ($file)=@_;
     if ($file =~ m|^/*uploaded/|) { $file=&filelocation("",$file); }
-    if ($file =~ m|^/home/httpd/html/lonUsers/|) { return 'OK'; }
+    if ($file =~ m|^/home/httpd/html/lonUsers/|) { return 'ok'; }
     my ($cdom,$cnum,$filename) = 
 	($file=~m|^\Q$perlvar{'lonDocRoot'}\E/+userfiles/+([^/]+)/+([^/]+)/+(.*)|);
     my ($info,$rtncode);
@@ -5282,7 +5282,7 @@
 	    return -1;
 	}
 	if ($info < $fileinfo[9]) {
-	    return 'OK';
+	    return 'ok';
 	}
 	$info = '';
 	$lwpresp = &getuploaded('GET',$uri,$cdom,$cnum,\$info,\$rtncode);
@@ -5316,7 +5316,7 @@
     open(FILE,">$file");
     print FILE $info;
     close(FILE);
-    return 'OK';
+    return 'ok';
 }
 
 sub tokenwrapper {
@@ -6133,8 +6133,8 @@
 
 repcopy($filename) : subscribes to the requested file, and attempts to
 replicate from the owning library server, Might return
-'HTTP_SERVICE_UNAVAILABLE', 'HTTP_NOT_FOUND', 'FORBIDDEN', 'OK', or
-'HTTP_BAD_REQUEST', also attempts to grab the metadata for the
+'unavailable', 'not_found', 'forbidden', 'ok', or
+'bad_request', also attempts to grab the metadata for the
 resource. Expects the local filesystem pathname
 (/home/httpd/html/res/....)
 
Index: loncom/lonnet/perl/lonrep.pm
diff -u loncom/lonnet/perl/lonrep.pm:1.7 loncom/lonnet/perl/lonrep.pm:1.8
--- loncom/lonnet/perl/lonrep.pm:1.7	Wed Mar  2 17:26:36 2005
+++ loncom/lonnet/perl/lonrep.pm	Wed Mar 16 16:35:17 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Replication Manager
 #
-# $Id: lonrep.pm,v 1.7 2005/03/02 22:26:36 raeburn Exp $
+# $Id: lonrep.pm,v 1.8 2005/03/16 21:35:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,7 @@
         }
       } else {
           my $response=Apache::lonnet::repcopy($filename);
-          if ($response eq 'OK') {
+          if ($response eq 'ok') {
 	      $r->filename($filename);
               return OK;
           }
Index: loncom/lonnet/perl/lonuploadrep.pm
diff -u loncom/lonnet/perl/lonuploadrep.pm:1.5 loncom/lonnet/perl/lonuploadrep.pm:1.6
--- loncom/lonnet/perl/lonuploadrep.pm:1.5	Wed Mar  2 17:26:36 2005
+++ loncom/lonnet/perl/lonuploadrep.pm	Wed Mar 16 16:35:17 2005
@@ -52,7 +52,7 @@
             }
         }
         my $response=&Apache::lonnet::repcopy_userfile($r->uri);
-        if ($response eq 'OK') {
+        if ($response eq 'ok') {
             $r->filename($filename);
             return OK;
         }

--raeburn1111008918--