From: Mike G. v. a. <we...@ma...> - 2010-05-15 19:05:01
|
Log Message: ----------- added fixes to PGalias.pm and PGcore.pm related to using $self-> in contexts where the binding was not as expected (e.g. in 'blah'. $self->{foobar} .'blah' ) Other minor fixes and improvements. Modified Files: -------------- pg/lib: PGalias.pm PGcore.pm PGloadfiles.pm pg/lib/WeBWorK/PG: IO.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.3 -r1.4 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -27,7 +27,7 @@ use PGrandom; use PGalias; use PGloadfiles; -use WeBWorK::PG::IO; +use WeBWorK::PG::IO(); # don't important any command directly use Tie::IxHash; ################################## @@ -668,22 +668,25 @@ my $path = shift; my $delim = "/"; my $tmpDirectory = $self->tempDirectory(); +#warn "\nTMP tmpDirectory $tmpDirectory"; unless ( -e $tmpDirectory) { # if by some unlucky chance the tmpDirectory hasn't been created, create it. my $parentDirectory = $tmpDirectory; $parentDirectory =~s|/$||; # remove a trailing / $parentDirectory =~s|/\w*$||; # remove last node my ($perms, $groupID) = (stat $parentDirectory)[2,5]; - createDirectory($tmpDirectory, $perms, $groupID) - or warn "Failed to create directory at $path"; + #FIXME where is the parentDirectory defined?? +#warn "Creating tmp directory at $tmpDirectory, perms $perms groupID $groupID"; + $self->createDirectory($tmpDirectory, $perms, $groupID) + or warn "Failed to create parent tmp directory at $path"; } # use the permissions/group on the temp directory itself as a template my ($perms, $groupID) = (stat $tmpDirectory)[2,5]; - #warn "&urePathToTmpFile: perms=$perms groupID=$groupID\n"; +#warn "&urePathToTmpFile: directory=$tmpDirectory, perms=$perms, groupID=$groupID\n"; # if the path starts with $tmpDirectory (which is permitted but optional) remove this initial segment $path =~ s|^$tmpDirectory|| if $path =~ m|^$tmpDirectory|; - #$path = convertPath($path); + #$path = $self->convertPath($path); # find the nodes on the given path my @nodes = split("$delim",$path); @@ -693,11 +696,13 @@ while (@nodes>1) { $path = $path . shift (@nodes) . "/"; #convertPath($path . shift (@nodes) . "/"); +#warn "\PATH is now $path"; unless (-e $path) { #system("mkdir $path"); #createDirectory($path,$Global::tmp_directory_permission, $Global::numericalGroupID) - createDirectory($path, $perms, $groupID) - or warn "Failed to create directory at $path"; +#warn "PATH $path perms $perms groupID $groupID"; + $self->createDirectory($path, $perms, $groupID) + or warn "Failed to create directory at $path with permissions $perms and groupID $groupID"; } } Index: PGalias.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGalias.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/PGalias.pm -Llib/PGalias.pm -u -r1.5 -r1.6 --- lib/PGalias.pm +++ lib/PGalias.pm @@ -160,7 +160,6 @@ my $aux_file_path = shift @_; my $resource_alias = new PGresource($aux_file_path); # just call it alias? FIXME -- not in use yet. - # warn "make alias for $aux_file_path"; warn "Empty string used as input into the function alias" unless $aux_file_path; my $displayMode = $self->{displayMode}; @@ -460,17 +459,18 @@ $gifFilePath = "$aux_file_path.gif"; } else { # we assume the file is in the same directory as the problem source file - $gifFilePath = $templateDirectory . ($self->directoryFromPath($fileName)) . "$aux_file_path.gif"; + my $dir = $self->directoryFromPath($fileName); + $gifFilePath = "$templateDirectory${dir}$aux_file_path.gif"; } my $gifFileName = $self->fileFromPath($gifFilePath); - $gifFileName =~ /^(.*)\.gif$/; - my $pngFilePath = $self->surePathToTmpFile("${tempDirectory}png/$setNumber-$probNum-$1.png"); - my $returnCode = system "cat $gifFilePath | ${$envir->{externalGif2PngPath}} > $pngFilePath"; - + my $pngFilePath = $self->surePathToTmpFile("${tempDirectory}png/$setNumber-$probNum-$1.png"); + my $command = $envir->{externalGif2PngPath}; + my $returnCode = system "cat $gifFilePath | $command > $pngFilePath"; + #warn "FILE path $pngFilePath exists =", -e $pngFilePath; if ($returnCode or not -e $pngFilePath) { - die "failed to convert $gifFilePath to $pngFilePath using gif->png with ${$envir->{externalGif2PngPath}}: $!\n"; + warn "returnCode $returnCode: failed to convert $gifFilePath to $pngFilePath using gif->png with $command: $!"; } $adr_output = $pngFilePath; @@ -575,7 +575,8 @@ # $fileName is obtained from environment for PGeval # it gives the full path to the current problem my $pngSourceFile = $self->convertPath("$templateDirectory${filePath}$aux_file_path.png"); - my $link = "gif/".$self->{uniqIDstub}."-$aux_file_path.$ext"; + my $uniqIDstub = $self->{uniqIDstub}; + my $link = "gif/${uniqIDstub}-$aux_file_path.$ext"; my $linkPath = $self->surePathToTmpFile($link); $adr_output = "${tempURL}$link"; #warn "linkPath is $linkPath"; @@ -635,7 +636,8 @@ $pngFilePath = "$aux_file_path.png"; } else { # we assume the file is in the same directory as the problem source file - $pngFilePath = $templateDirectory . ($self->directoryFromPath($fileName)) . "$aux_file_path.png"; + my $dir = $self->directoryFromPath($fileName); + $pngFilePath = "$templateDirectory${dir}$aux_file_path.png"; } $adr_output = $pngFilePath; Index: PGloadfiles.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGloadfiles.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -Llib/PGloadfiles.pm -Llib/PGloadfiles.pm -u -r1.1 -r1.2 --- lib/PGloadfiles.pm +++ lib/PGloadfiles.pm @@ -155,7 +155,7 @@ use WeBWorK::PG::Translator; use WeBWorK::PG::IO; -our @ISA = ( qw ( PGcore ) ); # look up features in PGcore -- in this case we want the environment. +our @ISA = qw ( PGcore ) ; # look up features in PGcore -- in this case we want the environment. Index: IO.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/WeBWorK/PG/IO.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/WeBWorK/PG/IO.pm -Llib/WeBWorK/PG/IO.pm -u -r1.5 -r1.6 --- lib/WeBWorK/PG/IO.pm +++ lib/WeBWorK/PG/IO.pm @@ -194,15 +194,21 @@ sub createDirectory { my ($dirName, $permission, $numgid) = @_; $permission = (defined($permission)) ? $permission : '0770'; - # FIXME -- find out where the permission is supposed to be defined. - #warn "dirName is $dirName and permission is $permission"; + # FIXME -- find out where the permission is supposed to be defined + my $errors = ''; mkdir($dirName, $permission) - or warn "Can't do mkdir($dirName, $permission): $!"; + or $errors .= "Can't do mkdir($dirName, $permission): $!\n".caller(3); chmod($permission, $dirName) - or warn "Can't do chmod($permission, $dirName): $!"; + or $errors .= "Can't do chmod($permission, $dirName): $!\n".caller(3); unless ($numgid == -1) { chown(-1,$numgid,$dirName) - or warn "Can't do chown(-1,$numgid,$dirName): $!"; + or $errors .= "Can't do chown(-1,$numgid,$dirName): $!\n".caller(3); + } + if ($errors) { + warn $errors; + return 0; + } else { + return 1; } } |