Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:15

0001 #!/usr/bin/env perl
0002 
0003 ##################
0004 # 
0005 # Project: Millipede Production Enviroment GUI
0006 # File:    /afs/cern.ch/user/s/sanchl/public/ZooZ-1.2/mpedegui.zooz
0007 # Authors: Luis Sanchez, Andrea Parenti, Silvia Miglioranzi
0008 # Contact: parenti@mail.cern.ch
0009 #
0010 ##################
0011 
0012 #
0013 # Headers
0014 #
0015 use strict;
0016 use warnings;
0017 
0018 use Tk 804;
0019 use Tk::DialogBox;
0020 require Tk::ROText;
0021 use Switch;
0022 
0023 # Needed in order to read mps.db
0024 BEGIN {
0025 use File::Basename;
0026 unshift(@INC, dirname($0)."/mpslib");
0027 }
0028 use Mpslib;
0029 
0030 #
0031 # Global variables
0032 #
0033 my (
0034      # MainWindow
0035      $MW,
0036 
0037      # Hash of all widgets
0038      %ZWIDGETS,
0039      
0040 
0041     );
0042 
0043 #
0044 # User-defined variables (if any)
0045 #
0046 
0047 # Working directory
0048     my $workdir;
0049 
0050 # Variables for mps_setup
0051     my $pathmillescript_variable;
0052     my $pathcfg_variable;
0053     my $pathdata_variable;
0054     my $pathpedescript_variable;
0055     my $pathcastor_variable;
0056     my $jobname_variable;
0057     my $setuppedejob_variable;
0058     my $njobs_variable;
0059     my $appendmillejob_variable;
0060     my $milleclass_variable;
0061     my $pedeclass_variable;
0062     my $batchclass_variable;
0063     my $pedemem_variable;
0064 # Variables for mps_fire
0065     my $firemerge_variable;
0066     my $njobsfir_variable;
0067 # Variables for mps_kill
0068 
0069 # Variables for mps_retry
0070     my $retryID_variable;
0071     my $retrymerge_variable;
0072     my $retryforce_variable;
0073 
0074 # Variables for mps_save
0075     my $pathsave_variable;
0076 
0077 # Standard outputs
0078     my $mpssetup_output;
0079     my $mpsfire_output;
0080     my $mpskill_output;
0081     my $mpsretry_output;
0082     my $mpsfetch_output;
0083     my $mpsstat_output;
0084     my $mpssave_output;
0085 
0086     my $row_offset;
0087     
0088 ######################
0089 #
0090 # Create the MainWindow
0091 #
0092 ######################
0093 
0094 $MW = MainWindow->new;
0095 
0096 ######################
0097 #
0098 # Load any images and fonts
0099 #
0100 ######################
0101 ZloadImages();
0102 ZloadFonts ();
0103 
0104 ### THIS IS THE TITLE ###
0105 
0106 # Widget title_label isa Label
0107 $ZWIDGETS{'title_label'} = $MW->Label(
0108    -text => 'Millipede Production System GUI',
0109   )->grid(
0110    -row        => 0,
0111    -column     => 0,
0112    -columnspan => 4,
0113    -sticky     => 'ew',
0114   );
0115 
0116 # Widget workdir_label isa Label
0117 $ZWIDGETS{'workdir_label'} = $MW->Label(
0118    -text => 'Working Directory:',
0119   )->grid(
0120    -row        => 1,
0121    -column     => 0,
0122    -sticky     => 'ew',
0123   );
0124 
0125 # Widget workDir isa ROText
0126 $ZWIDGETS{'ROText2'} = $MW->ROText(
0127    -height       => 1,
0128    -background => 'white',
0129   )
0130    ->grid(
0131    -row        => 1,
0132    -column     => 1,
0133    -columnspan => 3,
0134   );
0135 
0136 
0137 ### THIS IS THE MPS_SETUP SECTION ###
0138 $row_offset=2;
0139 
0140 # Widget pathmillescript_label isa Label
0141 $ZWIDGETS{'pathmillescript_label'} = $MW->Label(
0142    -text => 'Path to milleScript:',
0143   )->grid(
0144    -row    => $row_offset,
0145    -column => 0,
0146    -sticky => 'ew',
0147   );
0148 
0149 
0150 # Widget pathmillescript_entry isa Entry
0151 $ZWIDGETS{'pathmillescript_entry'} = $MW->Entry(   
0152     -textvariable => \$pathmillescript_variable,
0153         -background => 'white',
0154     )
0155    ->grid(
0156    -row    => $row_offset+1,
0157    -column => 0,
0158    -sticky => 'ew',
0159   );
0160 
0161 # Widget pathcfg_label isa Label
0162 $ZWIDGETS{'pathcfg_label'} = $MW->Label(
0163    -text => 'Path to cfg/py file:',
0164   )->grid(
0165    -row    => $row_offset+2,
0166    -column => 0,
0167    -sticky => 'ew',
0168   );
0169 
0170 # Widget pathcfg_entry isa Entry
0171 $ZWIDGETS{'pathcfg_entry'} = $MW->Entry(
0172     -textvariable => \$pathcfg_variable,
0173         -background => 'white',
0174     )
0175     ->grid(
0176    -row    => $row_offset+3,
0177    -column => 0,
0178    -sticky => 'ew',
0179   );
0180 
0181 # Widget pathdata_label isa Label
0182 $ZWIDGETS{'pathdata_label'} = $MW->Label(
0183    -text => 'Path to data:',
0184   )->grid(
0185    -row    => $row_offset+4,
0186    -column => 0,
0187    -sticky => 'ew',
0188   );
0189 
0190 # Widget pathdata_entry isa Entry
0191 $ZWIDGETS{'pathdata_entry'} = $MW->Entry(
0192     -textvariable => \$pathdata_variable,
0193         -background => 'white',
0194     )->grid(
0195    -row    => $row_offset+5,
0196    -column => 0,
0197    -sticky => 'ew',
0198   );
0199 
0200 
0201 # Widget pathpedescript_label isa Label
0202 $ZWIDGETS{'pathpedescript_label'} = $MW->Label(
0203    -text => 'Path to pedeScript:',
0204   )->grid(
0205    -row    => $row_offset+6,
0206    -column => 0,
0207    -sticky => 'ew',
0208   );
0209 
0210 # Widget pathpedescript_entry isa Entry
0211 $ZWIDGETS{'pathpedescript_entry'} = $MW->Entry(
0212     -textvariable => \$pathpedescript_variable,
0213         -background => 'white',
0214     )->grid(
0215    -row    => $row_offset+7,
0216    -column => 0,
0217    -sticky => 'ew',
0218   );
0219 
0220 
0221 # Widget pathcastor_label isa Label
0222 $ZWIDGETS{'pathcastor_label'} = $MW->Label(
0223    -text => 'Path to castor directory:',
0224   )->grid(
0225    -row    => $row_offset+8,
0226    -column => 0,
0227    -sticky => 'ew',
0228   );
0229 
0230 # Widget pathcastor_entry isa Entry
0231 $ZWIDGETS{'pathcastor_entry'} = $MW->Entry(
0232     -textvariable => \$pathcastor_variable,
0233         -background => 'white',
0234     )->grid(
0235    -row    => $row_offset+9,
0236    -column => 0,
0237    -sticky => 'ew',
0238   );
0239 
0240 # Widget pathmillescript_button isa Button
0241 $ZWIDGETS{'pathmillescript_button'} = $MW->Button(
0242    -anchor  => 'center',
0243    -justify => 'center',
0244    -text    => 'Browse',
0245    -command => sub{$pathmillescript_variable = &open_file_v3($pathmillescript_variable,"Choose Mille script","sh")},
0246   )->grid(
0247    -row    => $row_offset+1,
0248    -column => 1,
0249    -sticky => 'w',
0250   );
0251 
0252 # Widget pathcfg_button isa Button
0253 $ZWIDGETS{'pathcfg_button'} = $MW->Button(
0254    -text => 'Browse',
0255    -command => sub{$pathcfg_variable = &open_file_v3($pathcfg_variable,"Choose cfg/py file","py")},
0256   )->grid(
0257    -row    => $row_offset+3,
0258    -column => 1,
0259    -sticky => 'w',
0260   );
0261 
0262 # Widget pathdata_button isa Button
0263 $ZWIDGETS{'pathdata_button'} = $MW->Button(
0264    -text => 'Browse',
0265    -command => sub{$pathdata_variable = &open_file_v3($pathdata_variable,"Choose data file","*")},
0266   )->grid(
0267    -row    => $row_offset+5,
0268    -column => 1,
0269    -sticky => 'w',
0270   );
0271 
0272 # Widget pathpedescript_button isa Button
0273 $ZWIDGETS{'pathpedescript_button'} = $MW->Button(
0274    -text => 'Browse',
0275    -command => sub{$pathpedescript_variable = &open_file_v3($pathpedescript_variable,"Choose Pede script","sh")},
0276   )->grid(
0277    -row    => $row_offset+7,
0278    -column => 1,
0279    -sticky => 'w',
0280   );
0281 
0282 # Widget njobs_label isa Label
0283 $ZWIDGETS{'njobs_label'} = $MW->Label(
0284    -text => 'Number of jobs:',
0285   )->grid(
0286    -row        => $row_offset,
0287    -column     => 2,
0288    -sticky     => 'ew',
0289   );
0290 
0291 # Widget njobs_menu isa Optionmenu
0292 $ZWIDGETS{'njobs_menu'} = $MW->Optionmenu(
0293         -options => [[1 =>1], [10 =>10], [100=>100], [1000=>1000]],
0294         -variable => \$njobs_variable,
0295     )->grid(
0296    -row        => $row_offset+1,
0297    -column     => 2,
0298    -sticky     => 'ew',
0299   );
0300   
0301 # Widget jobaname_entry isa Entry
0302 $ZWIDGETS{'njobs_entry'} = $MW->Entry(
0303     -textvariable => \$njobs_variable,
0304         -background => 'white',
0305     )->grid(
0306 
0307    -row        => $row_offset+2,
0308    -column     => 2,
0309    -sticky => 'ew',
0310   );
0311 
0312 # Widget batchclass_label isa Label
0313 $ZWIDGETS{'batchclass_label'} = $MW->Label(
0314    -text => 'Batch system queue/class:',
0315   )->grid(
0316    -row        => $row_offset+3,
0317    -column     => 2,
0318    -sticky     => 'ew',
0319   );
0320 
0321 # Widget milleclass_menu isa Optionmenu
0322 $ZWIDGETS{'milleclass_menu'} = $MW->Optionmenu(
0323         -options => [ ["(Choose mille queue)"=>""], ["8nm"=>"8nm"], ["1nh"=>"1nh"], ["8nh"=>"8nh"], ["1nd"=>"1nd"], ["2nd"=>"2nd"], ["1nw"=>"1nw"], ["2nw"=>"2nw"], ["cmscaf1nh"=>"cmscaf1nh"], ["cmscaf1nd"=>"cmscaf1nd"], ["cmscaf1nw"=>"cmscaf1nw"] ],
0324         -variable => \$milleclass_variable,
0325         -command => \&createbatchclass,
0326     )->grid(
0327    -row        => $row_offset+4,
0328    -column     => 2,
0329    -sticky     => 'ew',
0330   );
0331 
0332 # Widget pedeclass_menu isa Optionmenu
0333 $ZWIDGETS{'pedeclass_menu'} = $MW->Optionmenu(
0334         -options => [ ["(Choose pede queue)"=>""], ["8nm"=>"8nm"], ["1nh"=>"1nh"], ["8nh"=>"8nh"], ["1nd"=>"1nd"], ["2nd"=>"2nd"], ["1nw"=>"1nw"], ["2nw"=>"2nw"], ["cmscaf1nh"=>"cmscaf1nh"], ["cmscaf1nd"=>"cmscaf1nd"], ["cmscaf1nw"=>"cmscaf1nw"], ["cmscafspec1nh"=>"cmscafspec1nh"], ["cmscafspec1nd"=>"cmscafspec1nd"], ["cmscafspec1nw"=>"cmscafspec1nw"] ],
0335         -variable => \$pedeclass_variable,
0336         -command => \&createbatchclass,
0337     )->grid(
0338    -row        => $row_offset+5,
0339    -column     => 2,
0340    -sticky     => 'ew',
0341   );
0342 
0343   
0344 # Widget batchclass_entry isa Entry
0345 $ZWIDGETS{'batchclass_entry'} = $MW->Entry(
0346     -textvariable => \$batchclass_variable,
0347         -background => 'white',
0348     )->grid(
0349 
0350    -row        => $row_offset+6,
0351    -column     => 2,
0352    -sticky => 'ew',
0353   );
0354 
0355 
0356 # Widget jobname_label isa Label
0357 $ZWIDGETS{'jobname_label'} = $MW->Label(
0358    -text => 'Jobname for batch system:',
0359   )->grid(
0360    -row    => $row_offset+7,
0361    -column => 2,
0362    -sticky => 'ew',
0363   );
0364 
0365 
0366 # Widget jobaname_entry isa Entry
0367 $ZWIDGETS{'jobaname_entry'} = $MW->Entry(
0368     -textvariable => \$jobname_variable,
0369         -background => 'white',
0370     )->grid(
0371    -row    => $row_offset+8,
0372    -column => 2,
0373    -sticky => 'ew',
0374   );
0375 
0376 # Widget setuppedejob_label isa Label
0377 $ZWIDGETS{'setuppedejob_label'} = $MW->Label(
0378    -text => 'Setup a Pede job?',
0379   )->grid(
0380    -row        => $row_offset,
0381    -column     => 3,
0382    -sticky     => 'ew',
0383   );
0384 
0385 # Widget setuppedejob_menu isa Optionmenu
0386 $ZWIDGETS{'setuppedejob_menu'} = $MW->Optionmenu(
0387         -options => [[yes=>1], [no=>2]],
0388         -variable => \$setuppedejob_variable,
0389     )->grid(
0390    -row        => $row_offset+1,
0391    -column     => 3,
0392    -sticky     => 'ew',
0393   );
0394 
0395 
0396 # Widget pede_mem isa Label
0397 $ZWIDGETS{'pede_mem'} = $MW->Label(
0398    -text => 'Memory for pede job:',
0399   )->grid(
0400    -row        => $row_offset+2,
0401    -column     => 3,
0402    -sticky     => 'ew',
0403   );
0404   
0405 # Widget pede_mem_entry isa Entry
0406 $ZWIDGETS{'pede_mem_entry'} = $MW->Entry(
0407     -textvariable => \$pedemem_variable,
0408         -background => 'white',
0409     )->grid(
0410 
0411    -row        => $row_offset+3,
0412    -column     => 3,
0413    -sticky => 'ew',
0414   );
0415 
0416 
0417 # Widget appendmillejob_label isa Label
0418 $ZWIDGETS{'appendmillejob_label'} = $MW->Label(
0419    -text => 'Set up additional Mille jobs?',
0420   )->grid(
0421    -row        => $row_offset+4,
0422    -column     => 3,
0423    -sticky     => 'ew',
0424   );
0425 
0426 # Widget appendmillejob_menu isa Optionmenu
0427 $ZWIDGETS{'appendmillejob_menu'} = $MW->Optionmenu(
0428         -options => [[no=>2], [yes=>1]],
0429         -variable => \$appendmillejob_variable,
0430     )->grid(
0431    -row        => $row_offset+5,
0432    -column     => 3,
0433    -sticky     => 'ew',
0434   );
0435 
0436 
0437 # Widget setup_button isa Button
0438 $ZWIDGETS{'setup_button'} = $MW->Button(
0439    -text => 'Run mps_setup',
0440    -command => \&setup_cmd,
0441    -background => 'cyan',
0442   )->grid(
0443    -row        => $row_offset+9,
0444    -column     => 2,
0445    -columnspan => 2,
0446    -sticky     => 'ew',
0447   );
0448 
0449 
0450 ### THIS IS THE MPS_FIRE SECTION ###
0451 $row_offset=12;
0452 
0453 # Widget njobsfir_label isa Label
0454 $ZWIDGETS{'njobsfir_label'} = $MW->Label(
0455    -text => 'Numbers of jobs to fire: ',
0456   )->grid(
0457    -row        => $row_offset,
0458    -column     => 0,
0459    -sticky     => 'ew',
0460   );
0461   
0462 # Widget jobaname_entry isa Entry
0463 $ZWIDGETS{'njobsfir_entry'} = $MW->Entry(
0464     -textvariable => \$njobsfir_variable,
0465         -background => 'white',
0466     )->grid(
0467 
0468    -row        => $row_offset+1,
0469    -column     => 0,
0470    -sticky => 'ew',
0471   );
0472 
0473 
0474 # Widget firemerge_label isa Label
0475 $ZWIDGETS{'firemerge_label'} = $MW->Label(
0476    -text => 'Fire merge job:',
0477   )->grid(
0478    -row        => $row_offset,
0479    -column     => 1,
0480    -sticky     => 'ew',
0481   );
0482 
0483 # Widget firemerge_menu isa Optionmenu
0484 $ZWIDGETS{'firemerge_menu'} = $MW->Optionmenu(
0485         -options => [["no"=>""], ["yes"=>"-m"], ["force merge job"=>"-mf"]],
0486         -variable => \$firemerge_variable,
0487     )->grid(
0488    -row        => $row_offset+1,
0489    -column     => 1,
0490    -sticky     => 'ew',
0491   );
0492 
0493 # Widget status_button isa Button
0494 $ZWIDGETS{'runmpsfire_button'} = $MW->Button(
0495    -text => 'Run mps_fire',
0496    -command => \&mpsfire_cmd,
0497    -background => 'cyan',
0498   )->grid(
0499    -row        => $row_offset+1,
0500    -column     => 2,
0501    -columnspan => 2,
0502    -sticky     => 'ew',
0503   );
0504 
0505 ### THIS IS THE MPS_KILL SECTION ###
0506 $row_offset=14;
0507 
0508 ### THIS IS THE MPS_RETRY SECTION ###
0509 $row_offset=16;
0510 
0511 # Widget retryID_label isa Label
0512 $ZWIDGETS{'retryID_label'} = $MW->Label(
0513    -text => 'jobSpec to retry:',
0514   )->grid(
0515    -row        => $row_offset,
0516    -column     => 0,
0517    -sticky     => 'ew',
0518   );
0519 
0520 # Widget retryID_entry isa Entry
0521 $ZWIDGETS{'retryID_entry'} = $MW->Entry(
0522     -textvariable => \$retryID_variable,
0523         -background => 'white',
0524     )->grid(
0525    -row        => $row_offset+1,
0526    -column     => 0,
0527    -sticky => 'ew',
0528   );
0529 
0530 
0531 # Widget retrymerge_label isa Label
0532 $ZWIDGETS{'retrymerge_label'} = $MW->Label(
0533    -text => 'Retry merge job: ',
0534   )->grid(
0535    -row        => $row_offset,
0536    -column     => 1,
0537    -sticky     => 'ew',
0538   );
0539 
0540 # Widget retrymerge_menu isa Optionmenu
0541 $ZWIDGETS{'retrymerge_menu'} = $MW->Optionmenu(
0542         -options => [["no"=>""], ["yes"=>"-m"]],
0543         -variable => \$retrymerge_variable,
0544     )->grid(
0545    -row        => $row_offset+1,
0546    -column     => 1,
0547    -sticky     => 'ew',
0548   );
0549 
0550 # Widget retryforce_label isa Label
0551 $ZWIDGETS{'retryforce_label'} = $MW->Label(
0552    -text => 'Force retry on OK jobs: ',
0553   )->grid(
0554    -row        => $row_offset,
0555    -column     => 2,
0556    -sticky     => 'ew',
0557   );
0558 
0559 # Widget retryforce_menu isa Optionmenu
0560 $ZWIDGETS{'retryforce_menu'} = $MW->Optionmenu(
0561         -options => [["no"=>""], ["yes"=>"-f"]],
0562         -variable => \$retryforce_variable,
0563     )->grid(
0564    -row        => $row_offset+1,
0565    -column     => 2,
0566    -sticky     => 'ew',
0567   );
0568 
0569 # Widget runmpsretry_button isa Button
0570 $ZWIDGETS{'runmpsretry_button'} = $MW->Button(
0571    -text => 'Run mps_retry',
0572    -command => \&mpsretry_cmd,
0573    -background => 'cyan',
0574   )->grid(
0575    -row        => $row_offset+1,
0576    -column     => 3,
0577    -columnspan => 1,
0578    -sticky     => 'ew',
0579   );
0580 
0581 
0582 ### THIS IS THE MPS_FETCH/MPS_STAT SECTION ###
0583 $row_offset=18;
0584 
0585  # Widget runmpsfetch_button isa Button
0586 $ZWIDGETS{'runmpsfetch_button'} = $MW->Button(
0587    -text => 'Run mps_fetch',
0588    -command => \&mpsfetch_cmd,
0589    -background => 'cyan',
0590   )->grid(
0591    -row        => $row_offset,
0592    -column     => 0,
0593    -columnspan => 2,
0594    -sticky     => 'ew',
0595   );  
0596 
0597 # Widget status_button isa Button
0598 $ZWIDGETS{'status_button'} = $MW->Button(
0599    -text => 'Run mps_stat',
0600    -command => \&mpsstat_cmd,
0601    -background => 'cyan',
0602   )->grid(
0603    -row        => $row_offset,
0604    -column     => 2,
0605    -columnspan => 2,
0606    -sticky     => 'ew',
0607   );
0608 
0609 ### THIS IS THE MPS_SAVE SECTION ###
0610 $row_offset=19;
0611 
0612 # Widget savedir_label isa Label
0613 $ZWIDGETS{'savedir_label'} = $MW->Label(
0614    -text => 'Save to Directory:',
0615   )->grid(
0616    -row        => $row_offset,
0617    -column     => 0,
0618    -sticky     => 'ew',
0619   );
0620 
0621 # Widget pathsave_entry isa Entry
0622 $ZWIDGETS{'pathsave_entry'} = $MW->Entry(   
0623     -textvariable => \$pathsave_variable,
0624         -background => 'white',
0625     )
0626    ->grid(
0627    -row    => $row_offset+1,
0628    -column => 0,
0629    -columnspan => 2,
0630    -sticky => 'ew',
0631   );
0632 
0633 # Widget save_button isa Button
0634 $ZWIDGETS{'save_button'} = $MW->Button(
0635    -text => 'Run mps_save',
0636    -command => \&mpssave_cmd,
0637    -background => 'cyan',
0638   )->grid(
0639    -row        => $row_offset+1,
0640    -column     => 2,
0641    -columnspan => 2,
0642    -sticky     => 'ew',
0643   );
0644 
0645 
0646 ### THIS IS THE OUTPUT SECTION ###
0647 $row_offset=21;
0648 
0649 # Widget output_label isa Label
0650 $ZWIDGETS{'output_label'} = $MW->Label(
0651    -text => 'Command output:',
0652   )->grid(
0653    -row        => $row_offset,
0654    -column     => 0,
0655    -columnspan => 4,
0656    -sticky     => 'ew',
0657   );
0658 
0659 # Widget MPS Setup Output isa ROText
0660 $ZWIDGETS{'ROText1'} = $MW->Scrolled('ROText',
0661   -scrollbars => 'e',
0662   -height => 15,
0663   -width => 40,
0664   -wrap => 'char',
0665   -background => 'white',
0666   -selectbackground => 'blue'
0667   )
0668   ->grid(
0669    -row        => $row_offset+1,
0670    -column     => 0,
0671    -columnspan => 4,
0672    -sticky     => 'ew',
0673   );
0674 
0675 
0676 ### QUIT SECTION ###
0677 $row_offset=23;
0678 
0679 # Widget quit_button isa Button
0680 $ZWIDGETS{'quit_button'} = $MW->Button(
0681    -anchor  => 'center',
0682    -justify => 'center',
0683    -text    => 'Quit',
0684    -command => sub{exit(0)},
0685   )->grid(
0686    -row        => $row_offset,
0687    -column     => 0,
0688    -columnspan => 4,
0689    -sticky     => 'ew',
0690   );
0691 
0692 ###############
0693 #
0694 # MainLoop
0695 #
0696 ###############
0697 
0698 
0699 reset_var(); # Reset all variables
0700 MainLoop;
0701 printf "Prova\n";
0702 
0703 #######################
0704 #
0705 # Subroutines
0706 #
0707 #######################
0708 
0709 sub ZloadImages {
0710 }
0711 
0712 sub ZloadFonts {
0713 }
0714 
0715 sub open_file_v3 ($$$) {
0716   my $infile = shift; # Original input file name
0717   my $title  = shift; # Title of the browse window
0718   my $fext   = shift; # File extension
0719   my $ftyp;
0720 
0721   switch ($fext) {
0722     case "sh" {$ftyp = [ ['zsh scripts', '.sh'], ['All Files',  '*'] ];}
0723     case "py" {$ftyp = [ ['py files',    '.py'], ['All Files',  '*'] ];}
0724     case "cfg" {$ftyp = [ ['cfg files',   '.cfg'], ['All Files',  '*'] ];}
0725     else {$ftyp = [ ['All Files',  '*'] ];}
0726   }
0727 
0728   my $open = $MW->getOpenFile(-filetypes => $ftyp,
0729                               -title => $title,
0730                  );
0731 
0732   if (!defined($open)) {
0733     $open = $infile;
0734   }
0735 
0736   return $open;
0737 }
0738 
0739 sub reset_var {
0740 
0741   $workdir = `pwd`;
0742   $ZWIDGETS{'ROText2'}->delete("1.0", 'end');
0743   $ZWIDGETS{'ROText2'}->insert('end',$workdir);
0744 
0745 # Read mps.db
0746   if (-e "mps.db") {
0747     read_db();
0748 #
0749     $pathmillescript_variable =$batchScript;
0750     $pathcfg_variable         =$cfgTemplate;
0751     $pathdata_variable        =$infiList;
0752     $pathpedescript_variable  =$mergeScript;
0753     $pathcastor_variable      =$mssDir;
0754     if ($mssDirPool ne "") {
0755       $pathcastor_variable    =$mssDirPool.":".$pathcastor_variable;
0756     }
0757     $jobname_variable         =$addFiles;
0758     $njobs_variable           =$nJobs;
0759 #
0760     $batchclass_variable =$class;
0761     $milleclass_variable ="";
0762     $pedeclass_variable  ="";
0763     $pedemem_variable = $pedeMem;
0764   }
0765 #
0766   $setuppedejob_variable    ="1"; #The default is "yes".
0767   $appendmillejob_variable  ="2"; #The default is "no".
0768   $firemerge_variable       ="";  #The default is to merge nothing
0769   $njobsfir_variable        ="1"; #This is the default anyway
0770 #
0771   $retryID_variable=0;
0772   $retrymerge_variable="";
0773   $retryforce_variable="";
0774 #
0775   $mpssetup_output="";
0776   $mpsfire_output="";
0777   $mpskill_output="";
0778   $mpsretry_output="";
0779   $mpsfetch_output="";
0780   $mpsstat_output="";
0781   $mpssave_output="";
0782 }
0783 
0784 sub setup_cmd {
0785   my $setup_cmd = "";
0786   my $setup_opt = "";
0787 
0788 
0789 #  if (-e "jobData") {
0790   if (-e "jobData" && $appendmillejob_variable != 1) {
0791 
0792     my $popup=$MW->DialogBox(-title=>"Confirm Setup",
0793                  -buttons=>["Confirm","Cancel"],);
0794     $popup->add("Label", -text=>"Are you sure? This will erase the existing jobData directory.")->pack;
0795 
0796     my $button = $popup->Show;
0797 
0798     if ($button ne "Confirm") {
0799       return;
0800     }
0801   }
0802 
0803   if ($appendmillejob_variable == 1) {
0804     $setup_opt .= " -a";
0805   }
0806 
0807   if ($setuppedejob_variable != 1) {
0808 # Do not setup Pede job
0809     $setup_cmd = sprintf "mps_setup.pl %s %s %s %s %d %s %s",$setup_opt,
0810       $pathmillescript_variable,$pathcfg_variable,$pathdata_variable,
0811       $njobs_variable,$batchclass_variable,$jobname_variable;
0812     $mpssetup_output=`$setup_cmd 2>&1`;
0813   } else {
0814 # Setup Mille and Pede
0815     $setup_opt .= " -m";
0816     if (length($pedemem_variable)) {
0817       $setup_opt .= " -M ".$pedemem_variable;
0818     }
0819     $setup_cmd = sprintf "mps_setup.pl %s %s %s %s %d %s %s %s %s",$setup_opt,
0820       $pathmillescript_variable,$pathcfg_variable,$pathdata_variable,
0821       $njobs_variable,$batchclass_variable,$jobname_variable,
0822       $pathpedescript_variable,$pathcastor_variable;
0823     $mpssetup_output=`$setup_cmd 2>&1`;
0824   }
0825 
0826 ## This 2 lines put the output in the main terminal (not in the gui window) and should probably be removed after gui-development is over
0827 #  printf $setup_cmd . "\n"; 
0828 #  printf $mpssetup_output ."\n";
0829 
0830   $ZWIDGETS{'ROText1'}->insert('end',"$mpssetup_output \n");
0831   $ZWIDGETS{'ROText1'}->see('end');
0832 }
0833 
0834 sub mpssave_cmd {
0835   my $save_cmd = "";
0836   
0837   $save_cmd = sprintf "mps_save.pl %s",$pathsave_variable;
0838   $mpssave_output=`$save_cmd 2>&1`;
0839 
0840   $ZWIDGETS{'ROText1'}->insert('end',"$mpssave_output \n");
0841   $ZWIDGETS{'ROText1'}->see('end');
0842 }
0843 
0844 sub mpsstat_cmd {
0845   my $status_cmd = "";
0846   
0847   $status_cmd = sprintf "mps_stat.py";
0848   $mpsstat_output=`$status_cmd 2>&1`;
0849 
0850   $ZWIDGETS{'ROText1'}->insert('end',"$mpsstat_output \n");
0851   $ZWIDGETS{'ROText1'}->see('end');
0852 }
0853 
0854 
0855 sub mpsfire_cmd {
0856   my $fire_cmd = "";
0857   
0858   $fire_cmd = sprintf "mps_fire.py %s %s",$firemerge_variable,
0859     $njobsfir_variable;
0860   $mpsfire_output=`$fire_cmd 2>&1`;
0861 
0862   $ZWIDGETS{'ROText1'}->insert('end',"$mpsfire_output \n");
0863   $ZWIDGETS{'ROText1'}->see('end');
0864 }
0865 
0866 sub mpsretry_cmd {
0867   my $mpsretry_cmd = "";
0868   
0869   $mpsretry_cmd = sprintf "mps_retry.pl %s %s %s",$retrymerge_variable,
0870     $retryforce_variable,$retryID_variable;
0871   $mpsretry_output=`$mpsretry_cmd 2>&1`;
0872 
0873   $ZWIDGETS{'ROText1'}->insert('end',"$mpsretry_output \n");
0874   $ZWIDGETS{'ROText1'}->see('end');
0875 }
0876 
0877 sub mpsfetch_cmd {
0878 
0879   my $fetch_cmd = "";
0880   
0881     $fetch_cmd = sprintf "mps_fetch.py";
0882     $mpsfetch_output=`$fetch_cmd 2>&1`;
0883 
0884   $ZWIDGETS{'ROText1'}->insert('end',"$mpsfetch_output \n");
0885   $ZWIDGETS{'ROText1'}->see('end');
0886 }
0887 
0888 #This should clean the text output window, right now is not implemented in any button or call
0889 sub cleanwindow{
0890   $ZWIDGETS{'ROText1'}->delete("1.0", 'end');
0891 }
0892 
0893 #Create $batchclass_variable from $milleclass_variable and $pedeclass_variable
0894 sub createbatchclass{
0895 #  if (!defined($milleclass_variable)) {$milleclass_variable="";}
0896 #  if (!defined($pedeclass_variable))  {$pedeclass_variable="";}
0897 
0898   if (!defined($milleclass_variable)) {return;}
0899   if (!defined($pedeclass_variable))  {return;}
0900 
0901   if ($milleclass_variable ne "" && $pedeclass_variable ne "") {
0902     $batchclass_variable=$milleclass_variable .":". $pedeclass_variable;
0903   } elsif ($milleclass_variable ne "") {
0904     $batchclass_variable=$milleclass_variable;
0905   } elsif ($pedeclass_variable ne "") {
0906     $batchclass_variable=$pedeclass_variable;
0907   }
0908 }
0909 
0910 #Test routine
0911 sub prova{
0912   printf "Prova.\n";
0913 }