[Bio] / FigKernelPackages / Subsystem.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Subsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13, Wed Jun 16 14:05:42 2004 UTC revision 1.14, Wed Jun 16 16:52:10 2004 UTC
# Line 9  Line 9 
9  use POSIX;  use POSIX;
10  use DirHandle;  use DirHandle;
11  use Data::Dumper;  use Data::Dumper;
12    use File::Copy;
13  use File::Spec;  use File::Spec;
14  use IPC::Open2;  use IPC::Open2;
15    
# Line 669  Line 670 
670      }      }
671  }  }
672    
673    #
674    # Increment the subsystem's version number.
675    #
676    sub incr_version {
677        my($self) = @_;
678    
679        my $dir = $self->{dir};
680        my $vfile = "$dir/VERSION";
681        my($ver);
682    
683        if (open(my $fh,"<$vfile"))
684        {
685            if (defined($ver = <$fh>) && ($ver =~ /^(\S+)/))
686            {
687                $ver = $1;
688            }
689            else
690            {
691                $ver = 0;
692            }
693            close($fh);
694        }
695        else
696        {
697            $ver = 0;
698        }
699    
700        $ver++;
701    
702        open(my $fh, ">$vfile") || die "could not open $vfile";
703        print $fh "$ver\n";
704        close($fh);
705    
706        chmod(0777, $vfile);
707    
708        $self->load_version();
709    }
710    
711  sub get_dir_from_name  sub get_dir_from_name
712  {  {
# Line 720  Line 758 
758      }      }
759    
760      my $ss_name = $self->{name};      my $ss_name = $self->{name};
761      my $ss_dir = $self->{dir};      my $ss_dir = "$self->{dir}/";
762      my $assign_dir = "$FIG_Config::data/Assginments/$user";      my $assign_dir = "$FIG_Config::data/Assginments/$user/";
763      &FIG::verify_dir($assign_dir);      &FIG::verify_dir($assign_dir);
764    
765      my $seed = &FIG::cgi_url() . "/";      my $seed = &FIG::cgi_url() . "/";
# Line 776  Line 814 
814    
815      open($log, ">$ss_dir/extension.log");      open($log, ">$ss_dir/extension.log");
816    
817        #
818        # Start the actual application with stdin and stdout redirected
819        # to pipes.
820        #
821        # We write $app_input to the stdin pipe, and close it.
822        # Then loop reading stdout, logging that output.
823        #
824      my $pid = open2($app_read, $app_write, $exe);      my $pid = open2($app_read, $app_write, $exe);
825    
826      if (!$pid)      if (!$pid)
# Line 816  Line 861 
861      my $stat = $?;      my $stat = $?;
862      print STDERR "Return status is $?\n";      print STDERR "Return status is $?\n";
863      print $log "Return status is $?\n";      print $log "Return status is $?\n";
864    
865        #
866        # At this point, the extension is finished.
867        # Back up the spreadsheet, and append the rows file to it.
868        #
869    
870        my $ssaD = $self->{dir};
871        &FIG::verify_dir("$ssaD/Backup");
872        my $ts = time;
873        rename("$ssaD/spreadsheet~","$ssaD/Backup/spreadsheet.$ts");
874        copy("$ssaD/spreadsheet","$ssaD/spreadsheet~");
875        rename("$ssaD/notes~","$ssaD/Backup/notes.$ts");
876    
877        #
878        # Append the new rows to the spreadsheet.
879        #
880    
881        my($ssafh, $rowsfh);
882        open($ssafh, ">>$ssaD/spreadsheet") or die "Cannot open $ssaD/spreadsheet for append: $!\n";
883        open($rowsfh, "<$ssaD/rows") or die "Cannot open $ssaD/rows for reading: $!\n";
884    
885        while (<$rowsfh>)
886        {
887            print $ssafh $_;
888  }  }
889        close($ssafh);
890        close($rowsfh);
891    
892        $self->incr_version();
893  }  }
894    
895    }
896    
897    
898  sub set_current_extend_pid  sub set_current_extend_pid
899  {  {
900      my($self, $pid) = @_;      my($self, $pid) = @_;

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3