[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm
raeburn
raeburn@source.lon-capa.org
Tue, 19 Oct 2010 19:33:21 -0000
raeburn Tue Oct 19 19:33:21 2010 EDT
Modified files:
/loncom/xml londefdef.pm
Log:
- Replace Apache::File with open() to facilitate use outside Apache/mod_perl
environment.
- Eliminate unused scalar ($temp_file).
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.423 loncom/xml/londefdef.pm:1.424
--- loncom/xml/londefdef.pm:1.423 Tue Sep 14 03:48:36 2010
+++ loncom/xml/londefdef.pm Tue Oct 19 19:33:21 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.423 2010/09/14 03:48:36 raeburn Exp $
+# $Id: londefdef.pm,v 1.424 2010/10/19 19:33:21 raeburn Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -43,7 +43,6 @@
use strict;
use Apache::lonxml;
use Apache::lontable;
-use Apache::File();
use Image::Magick;
use Apache::lonmenu();
use Apache::lonmeta();
@@ -4616,13 +4615,13 @@
#if replication failed try to produce eps file dynamically
$src=~s/\.ps$/\.eps/;
- my $temp_file;
- open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
- my $newsrc=$orig_src;
- $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
- &Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
- print FILE ("$newsrc\n");
- close(FILE);
+ if (open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat")) {
+ my $newsrc=$orig_src;
+ $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
+ &Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
+ print FILE ("$newsrc\n");
+ close(FILE);
+ }
$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
if ($sext ne "") { # Put the ext. back in to uniquify.
@@ -4655,8 +4654,10 @@
sub eps_generation {
my ($src,$file,$width_param) = @_;
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
- my $temp_file = Apache::File->new('>>'.$filename);
- print $temp_file "$src\n";
+ if (open(my $tmpfile,">>$filename")) {
+ print $tmpfile "$src\n";
+ close($tmpfile);
+ }
my $newsrc = $src;
$newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i;
$newsrc=~s{/home/httpd/html/res}{};