[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, 02 Mar 2005 22:26:37 -0000
This is a MIME encoded message
--raeburn1109802397
Content-Type: text/plain
raeburn Wed Mar 2 17:26:37 2005 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm lonrep.pm lonuploadrep.pm
/loncom/homework imageresponse.pm randomlabel.pm
/loncom/xml londefdef.pm
/loncom/interface londocs.pm
Log:
lonnet::repcopy() and lonnet::repcopy_userfile() now return strings rather than constants defined in Apache::Constants. This allows lonnet::repcopy() to be used for cloning in batch course creation run from a command line script. If Apache::Constants are to be returned by PerlHandlers these should be set in the appropriate handler rather than in subroutines in lonnet called by the handler, based on the string response from lonnet::repcopy().
--raeburn1109802397
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20050302172637.txt"
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.601 loncom/lonnet/perl/lonnet.pm:1.602
--- loncom/lonnet/perl/lonnet.pm:1.601 Mon Feb 28 19:22:59 2005
+++ loncom/lonnet/perl/lonnet.pm Wed Mar 2 17:26:36 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.601 2005/03/01 00:22:59 albertel Exp $
+# $Id: lonnet.pm,v 1.602 2005/03/02 22:26:36 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 'HTTP_SERVICE_UNAVAILABLE';
} elsif ($remoteurl eq 'not_found') {
#&logthis("Subscribe returned not_found: $filename");
- return HTTP_NOT_FOUND;
+ return 'HTTP_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 'HTTP_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 'HTTP_SERVICE_UNAVAILABLE';
} else {
if ($remoteurl!~/\.meta$/) {
my $mrequest=new HTTP::Request('GET',$remoteurl.'.meta');
@@ -1054,7 +1054,7 @@
}
}
rename($transname,$filename);
- return OK;
+ return 'OK';
}
}
}
@@ -5237,10 +5237,8 @@
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);
@@ -5263,7 +5261,7 @@
return -1;
}
if ($info < $fileinfo[9]) {
- return OK;
+ return 'OK';
}
$info = '';
$lwpresp = &getuploaded('GET',$uri,$cdom,$cnum,\$info,\$rtncode);
@@ -5297,7 +5295,7 @@
open(FILE,">$file");
print FILE $info;
close(FILE);
- return OK;
+ return 'OK';
}
sub tokenwrapper {
@@ -6117,8 +6115,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
+'HTTP_SERVICE_UNAVAILABLE', 'HTTP_NOT_FOUND', 'FORBIDDEN', 'OK', or
+'HTTP_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.6 loncom/lonnet/perl/lonrep.pm:1.7
--- loncom/lonnet/perl/lonrep.pm:1.6 Thu Nov 29 13:55:24 2001
+++ loncom/lonnet/perl/lonrep.pm Wed Mar 2 17:26:36 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Replication Manager
#
-# $Id: lonrep.pm,v 1.6 2001/11/29 18:55:24 www Exp $
+# $Id: lonrep.pm,v 1.7 2005/03/02 22:26:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@
}
} else {
my $response=Apache::lonnet::repcopy($filename);
- if ($response==OK) {
+ if ($response eq 'OK') {
$r->filename($filename);
return OK;
}
Index: loncom/lonnet/perl/lonuploadrep.pm
diff -u loncom/lonnet/perl/lonuploadrep.pm:1.4 loncom/lonnet/perl/lonuploadrep.pm:1.5
--- loncom/lonnet/perl/lonuploadrep.pm:1.4 Thu Sep 2 14:01:52 2004
+++ loncom/lonnet/perl/lonuploadrep.pm Wed Mar 2 17:26:36 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;
}
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.62 loncom/homework/imageresponse.pm:1.63
--- loncom/homework/imageresponse.pm:1.62 Thu Feb 10 18:00:10 2005
+++ loncom/homework/imageresponse.pm Wed Mar 2 17:26:36 2005
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.62 2005/02/10 23:00:10 albertel Exp $
+# $Id: imageresponse.pm,v 1.63 2005/03/02 22:26:36 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.64 loncom/homework/randomlabel.pm:1.65
--- loncom/homework/randomlabel.pm:1.64 Thu Feb 10 18:00:10 2005
+++ loncom/homework/randomlabel.pm Wed Mar 2 17:26:36 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# random labelling tool
#
-# $Id: randomlabel.pm,v 1.64 2005/02/10 23:00:10 albertel Exp $
+# $Id: randomlabel.pm,v 1.65 2005/03/02 22:26:36 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/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.259 loncom/xml/londefdef.pm:1.260
--- loncom/xml/londefdef.pm:1.259 Mon Feb 28 22:21:58 2005
+++ loncom/xml/londefdef.pm Wed Mar 2 17:26:36 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.259 2005/03/01 03:21:58 albertel Exp $
+# $Id: londefdef.pm,v 1.260 2005/03/02 22:26:36 raeburn Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -3749,7 +3749,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 '';
}
@@ -3815,12 +3815,12 @@
$src=~s/\.(gif|png|jpg|jpeg)$/\.eps/i;
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
if (! -e $src) {
- if (&Apache::lonnet::repcopy($src) ne OK ) {
+ if (&Apache::lonnet::repcopy($src) ne 'OK' ) {
#if replication failed try to find ps file
$src=~s/\.eps$/\.ps/;
#if no ps file try to replicate it
if (not -e $src &&
- &Apache::lonnet::repcopy($src) ne OK) {
+ &Apache::lonnet::repcopy($src) ne 'OK') {
#if replication failed try to produce eps file dynamically
$src=~s/\.ps$/\.eps/;
my $temp_file;
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.168 loncom/interface/londocs.pm:1.169
--- loncom/interface/londocs.pm:1.168 Sun Feb 20 19:32:45 2005
+++ loncom/interface/londocs.pm Wed Mar 2 17:26:36 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.168 2005/02/21 00:32:45 www Exp $
+# $Id: londocs.pm,v 1.169 2005/03/02 22:26:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1489,7 +1489,7 @@
if ($url=~/^\/res\//) {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
- if ($result==OK) {
+ if ($result eq 'OK') {
$r->print('<font color="green">'.&mt('ok').'</font>');
$r->rflush();
&Apache::lonnet::countacc($url);
@@ -1532,9 +1532,9 @@
&checkonthis($r,$_,$level+1);
}
}
- } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
+ } elsif ($result eq 'HTTP_SERVICE_UNAVAILABLE') {
$r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
- } elsif ($result==HTTP_NOT_FOUND) {
+ } elsif ($result eq 'HTTP_NOT_FOUND') {
unless ($url=~/\$/) {
$r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
} else {
--raeburn1109802397--