Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:39:31

0001 #!/usr/bin/env perl
0002 # Author: Joerg Behr
0003 #This script enables jobs with the given job numbers.
0004 
0005 BEGIN {
0006 use File::Basename;
0007 unshift(@INC, dirname($0)."/mpslib");
0008 }
0009 use Mpslib;
0010 use warnings;
0011 use POSIX;
0012 read_db();
0013 
0014 my @enabledjobs;
0015 my $count = 0;
0016 my $confname = "";
0017 
0018 while (@ARGV) {
0019    my $arg = shift(@ARGV);
0020     if ($arg =~ /-N/g) {
0021       $confname = $arg;
0022       $confname =~ s/-N//; # Strips away the "-N"
0023       if (length($confname) == 0) {
0024         $confname = shift(@ARGV);
0025        }
0026       $confname =~ s/\s//g;
0027       if($confname =~ /\:/)
0028         {
0029           $confname =~ s/\://g;
0030           print "colons were removed in configuration name because they are not allowed: $confname\n";
0031         }
0032     }
0033    elsif ($arg eq "-h")
0034      {
0035        print 'mps_enablejob.pl [-h] [-N name] [jobids]
0036 Parameters/Options:
0037 -h         This help ...
0038 -N name    Enable Mille jobs with name "name".
0039 jobids     A list of Mille job ids which should be enabled. Does not work together with option -N.
0040 
0041 The command mps_enablejob.pl can be used to turn on Mille jobs which have been turn off previously. If no option is provided all jobs are enabled.
0042 ';
0043       exit; 
0044      }
0045    else
0046      {
0047        if(isdigit $arg)
0048          {
0049            $count++;
0050            push @enabledjobs, $arg;
0051          }
0052        else
0053          {
0054            print "only integer numbers are allowed for the job ids: $arg\n";
0055            exit(-1);
0056          }
0057      }
0058  }
0059 
0060 if($confname ne "")
0061   {
0062     print "Enable jobs: ${confname}.\n";
0063     for (my $i=0; $i<@JOBID; ++$i) {
0064       my $status = $JOBSTATUS[$i];
0065       if(defined $status)
0066         {
0067           unless($JOBDIR[$i] =~ /jobm/i)
0068             {
0069               my $name = $JOBSP3[$i];
0070               if($name eq $confname)
0071                 {
0072                   my $status = $JOBSTATUS[$i];
0073                   $status =~ s/DISABLED//ig;
0074                   $JOBSTATUS[$i] = $status;
0075                 }
0076             }
0077         }
0078     }
0079   }
0080 elsif($count==0)
0081   {
0082     for (my $i=0; $i<@JOBID; ++$i) {
0083       my $status = $JOBSTATUS[$i];
0084       if(defined $status)
0085         {
0086           unless($JOBDIR[$i] =~ /jobm/i)
0087             {
0088               $status =~ s/DISABLED//gi;
0089               $JOBSTATUS[$i] = $status;
0090             }
0091         }
0092     }
0093   }
0094 else
0095   {
0096     foreach my $j (@enabledjobs) {
0097       my $status = $JOBSTATUS[$j-1];
0098       if(defined $status)
0099         {
0100           unless($JOBDIR[$j-1] =~ /jobm/i)
0101             {
0102               $status =~ s/DISABLED//ig;
0103               $JOBSTATUS[$j-1] = $status;
0104             }
0105         }
0106     }
0107   }
0108 write_db();