-
Notifications
You must be signed in to change notification settings - Fork 1
/
lr
executable file
·1434 lines (1224 loc) · 47.3 KB
/
lr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/env perl
use Getopt::Std;
use Getopt::Long;
use POSIX qw(uname);
use File::Path;
use File::Copy;
use Cwd;
use Archive::Tar;
use Plucknames;
#Save time executing Load Reviews
#Creates neccesary directories for current load.
#SFTP's to lucky, user enters name and pwd and
#manually gets the zipped tarball.
#DO NOT specify any directory path in FTP copying, quit FTP and script
#finds, extracts and runs ACIS LR script on backstop file.
#If print option used: prints ACIS-LoadReview.txt file to chosen printer.
#Default is no print, "hp0" print to hp0, "happy" will print to happy
#History file will not work if symbolic link to "ofls" has
#not been made for previous week, even if only one version of load!
#written by: Joe DePasquale
#started: Sept 2001
#to see updates, please go the CVS version
#last update: 08 OCT 2009
#
#
# Update: ??? Some time in 2016
# Royce Beuhler
# Mods to allow the code to run LR-BAK
#
# Update: September 15 2016
# Gregg Germain
# 1) Modify LR code to use the new CTI-report format converter
#
# First step was to do a diff between the version of lr obtained from the
# GIT repo and the one in /data/acis/LoadReviews/script/lr-v1.61 (the latest)
# /data/acis/LoadReviews/script/lr -> lr-v1.61
#
# Update: Jan 13, 2017
# Gregg Germain
# 1) Fixed ACIS table reporting such that it now reports .DAT
# as well as .CFG
#
# Update: February 21, 2017
# Gregg Germain
# Added the creation of a file: ACIS-Continuity.txt
# which contains ONLY the user-supplied continuity
# file name (e.g. FEB0517) and a carriage return
#
# Update: April 14, 2017
# Gregg Germain
# Added echos for all user inputs that didn't have them
# Also added lines to ACIS-Continuity.txt:
# - Continuity load (already in the file)
# - <type of load> <interrupt time>
# Type of load can be "Normal", "TOO", "SCS107"
#
# Update: July 18, 2017
# Gregg Germain
# MERGER of Production LR (lr_v1.63) with MIRROR LR
# Copied Production LR (lr_v1.63) to MERGER lr_v1.64
#
# From Production -> Mirror
# Continuity Tracking - ACIS-Continuity.txt
#
# From MIRROR -> PRODUCTION LR
#
# Update: Aug 9, 2017
# Gregg Germain
# Capture the command line and print it so that it
# appears on screen as well as in the log file.
# Does not capture the Tee-off to the log file
#
#
# Update: April 25, 2018
# Gregg Germain
# Added Check_Power_Cmds.py to the stream of LR checks.
#
# Repo Update: November 28, 2018
# Merged v3.2 with Master to align the repo with production
#
# Repo Update: November 28, 2018
# V3.3
# GIT - 662c0f7
# - Set up sdtout buffer autoflush
# - Eliminated process fork so that the LR
# stdoutput to the screen looks right
# - Collected status from the system/sftp call
# and arranged a clean exit in case lucky
# is not accessible.
#
# Update: December 20, 2018
# V3.4
# GIT - e22ed76
# - Changed run_models_acis.pl to run_models.pl
#
# Update: August 28, 2019
# V3.5
# GIT - 2aaad37
# - copy ACIS-LoadReview.txt.ERRORS to ACIS-LoadReview.txt so
# that we have only one file to check during load reviews.
# - pointed to ska3/flight instead of ska/bin for ska Python 3
#
# Update: December 11, 2019
# V3.6
# - Moved the code which generates the HTML version
# of ACIS-LoadReview.txt, to after the Check power
# commands code.
# - Removed the earth-acis-fov code
#
# Update: September 25, 2020
# V3.7
# - Use Python3 for Window_check.py
# - Added and/or modified comments
#
# Update: February 25, 2021
# v3.8
# - Store production NLET file as a dated file
# to accomodate using for tests
# - Modified call to Check_Power_Cmds.py
#
#
# Update: August 23, 2021
# v3.8.5
# - Update to copy the bright-source list employed to ofls.
#
#
# Update: September, 21, 2021
# V3.9
# - Move CHECK_POWER_COMMANDS and WINDOW_CHECK to before
# run_models call
#
# Update: November 24, 2021
# V4.0
# - Added -VO argument to the command line which will allow
# the user to force the use of the Vehicle Only load
# when reading in the Review Load, the Continuity Load
# or both (VOR, VOC, VOB)
# - User can include the letter in the Continuity load argument.
# This will allow the user to force an earlier load, if the same name, to be the continuity load.
# - Clarified the questions which, when -break is used, determine what the
# load type is (TOO, SCS-107, STOP).
# - added --nomodels switch to run LR without running the thermal models
# - Added comments and fixed typos
#
# Update: February 10, 2022
# V4.1
# - Activated hooks for VOB and VOR switches
#
# Update: March 15, 2022
# V4.2
# - Modified lr to include the DO*.orp file in the file extraction from the tarball
#
# Update: June 13, 2022
# V4.3
# - Changes to accomodate DS10.11/Red Hat 8, and the change in txings
# - Removed code that called fptemp_sens_finder.pl
#
# Update: December 3, 2022
# V4.4
# - Added Idle Dwell Check program to LR
# - Added the extraction of mps/or/<filename>.or from the tar file
# - This was done by introducing Tar_Extract.py as a utility in order
# to continue the migration from Perl to Python.
# - Added HRC/TXING time delta check
#
###########################################################
# usage: lr [present load] [previous week] #
# example: lr AUG2701A AUG2001 #
###########################################################
#
# Set up autoflush
$| = 1;
# Capture the command line and print it out so that there's
# a record of what the user typed in:
my $commandline = $0 . " " . (join " ", @ARGV);
print "\nlr - Command Line: $commandline \n\n";
#
# Some inits for the ACIS-Continuity file
my $load_type = "Normal";
my $interrupt_time = "";
#Check for options: will remove options from argv
$nlet_file = "/data/acis/LoadReviews/NonLoadTrackedEvents.txt";
$server="ocatsqlsrv";
$hostname="acis.cfa.harvard.edu"; #for PSMC
$skiplucky = 0;
$break = 0;
$easy_clean = 0;
GetOptions('break' => \$break, #run lr_break options,
's=s' => \$server, #to be passed to acisparams.pl
'n=s' => \$hostname, #to be passed to run_PSMC.pl
'nolucky' => \$skiplucky, # acquire backstop manually
'clean' => \$easy_clean,
't=s' => \$test_dir, # Test directory
'nlet_file=s' => \$nlet_file, # NLET file name
'nomodels' => \$nomodels,
'VO=s', \$VO_choice); # Vehicle Only switch [VOC, VOR, VOB]
$argc = @ARGV;
$argc >= 2 or die "ERROR! AT LEAST TWO INPUTS REQUIRED!\nUSAGE: lr {present load} {preceeding week} [-s alternate database server] [-n alternate PSMC code node] [-t test directory name] [-nlet_file alternative NLET file LR should use] [-b or --break use for a replan or interrupt]\n";
# Create an array of valid -VO switch values. If the user supplies a value and
# if it's not in the array then write an error message (listing the valid ones)
# and then end execution before any subdirectories are created
@VO_types = ("VOC", "VOR", "VOB");
# If $VO_choice has no value, then the user didn't supply a --VO argument
# so there's nothing to check
if ($VO_choice ne "")
{
# But since they did supply one, check to see if the supplied argument
# is in the list. We want to check this and, if the input is invalid, exit.
if( not( grep( /^$VO_choice$/, @VO_types)))
{
die("FATAL ERROR - $VO_choice is an invalid value for the VO switch.\nValid values are: VOC, VOR, VOB\n");
}
else
{ print "\n The VO value is: $VO_choice";}
}
# Record the NLET file being used in the log
print "\n LR I am using NLET FILE: : $nlet_file\n";
# If the Production NLET file is being used, record a dated copy of
# it in the /data/acis/LoadReviews/TEST_NLET_FILES directory
if ( (! $test_dir) && ($nlet_file eq "/data/acis/LoadReviews/NonLoadTrackedEvents.txt"))
{
print "\n Production run with the Production NLET file - I will create a dated entry in the test NLET file dir\n";
`cp $nlet_file /data/acis/LoadReviews/TEST_NLET_FILES/@ARGV[0]_NonLoadTrackedEvents.txt`;
}
else
{print "\nRunning in --TEST mode or not using the Production NLET file - No NLET file save required\n";}
#----------------------------------------
# Prepare for i/o control from python subprocess
#----------------------------------------
$| = 1; # Autoflush after every stdout print, write
#--------------------------------------------------------------------
# NEW CODE to allow one lr to run in regular and backup
# modes
# SET UP the directory for the scripts
#--------------------------------------------------------------------
$appx = `lr_suffix.pl`; # Null or "_bak"
if($0 =~ /bak/) {
$base_dir=</data/acis-bak>;
}
else{
$base_dir=</data/acis>;
}
#----------------------------------------
#directory definitions
#----------------------------------------
$lr_dir = <${base_dir}/LoadReviews>;
$lr_bak_dir = </data/acis-bak/LoadReviews>;
$script_store_dir = <${base_dir}/LoadReviews/script>;
# PRODUCTION Define call to acis-backstop.
$backstop = <${base_dir}/LoadReviews/script/acis-backstop.pl>;
#------------------------------
# Get the directory to use for the C++ code
#------------------------------
my ($uname_s, $uname_r) = (POSIX::uname())[0,2];
#Set up the Linux executable paths
if (($uname_s eq "Linux"))
{
$cc_directory=<${base_dir}/LoadReviews/Linux/bin>;
$tar=</bin/tar>;
$gzip=</bin/gzip>;
$sftp=</usr/bin/sftp>;
$ftp=</usr/bin/ftp>;
$gunzip=</bin/gunzip>;
}
else
{
die("$0 is only supported on Linux: This version $uname_r\n");
}
###FIND THIS AND MOVE IT TO LOADREVIEWS
$cur_load_dir=<${base_dir}/LoadReviews/>; #needed for ACE Update
#directory generation and tar file copying
#
# REVIEW load
$cur_load=@ARGV[0];
# Continuity load
$prev_load=@ARGV[1];
# The basic command line for lr is: lr Review_load Continuity_load
# e.g. lr OCT3021A OCT2821
# These arguments are stored in $cur_load and $prev_load respectively.
#
# This code addition allows for the inclusion of the letter to the
# Continuity load week in the LR command. e.g. lr OCT3021A OCT2821B
#
# Up until now we never included it. LR doesn't expect a letter there, and the thermal
# models (via ACIS-Continuity.txt - created by lr) default to the .../ofls directory.
# Turns out that it's possible that a Continuity load week might have an A, B, or C
# load but the actual continuity load used was A or B. ofls will point to C. This
# code update allows for that. It also allows for not specifying a letter
# If the user does not specify a letter then the ACIS-Continuity.txt file
# will default to the ofls directory for that previous week.
#
# In either case, $prev_load will end up containing the 7 character load week without
# the load letter so that the rest of lr will not have to be changed.
# Find the length of the preview load name. Syntax was fixed at 7 letters
# i.e. MMMDDYY (OCT2821). But now it can be either 7 or 8: OCT2821 or OCT2821A
$ofls_val = "";
$len_prevload = length($prev_load);
# Get the last token in the preview load name
$last_token = substr($prev_load, -1);
print("\n The Previous load variable contains: $prev_load");
# If the length was 8 and the last token was a capital letter
# Then remove the letter from $prev_load, and add the lower case of that letter
# to the ofls string.
if ($len_prevload == 8 && $last_token =~ m/^[A-Z]/)
{
# Remove the letter from $prev_load
$prev_load = substr($prev_load, 0, $len_prevload - 1);
# add the lower case of the load letter to the ofls string
$ofls_val = $ofls_val.lc($last_token);
}
print("\nThe Previous load variable now contains: $prev_load");
print("\nThe ofls value that will be used is: $ofls_val");
print("\n");
# Initialize variables used to point to current and previous load directory years.
$load_dir="";
$prev_dir="";
$prev_year="";
$cur_year="";
$load_version="";
$load_name="";
#PARSE THE LOAD INFORMATION
find_names($cur_load,$prev_load,$test_dir);
#------------------------------
#Set the directories & files
#------------------------------
# ---- OFLS_DIR is where the load files eventually go. ------------- OFLS dir
# e.g. /data/acis/Loadreviews/2016/SEP2416/oflsa
$ofls_dir="${lr_dir}/20${cur_year}/$load_dir/ofls${load_version}";
# e.g. /data/acis/Loadreviews/2016/SEP2416/ ------------- load dir
$cur_load_dir="${lr_dir}/20${cur_year}/$load_dir/";
# e.g. /data/acis/Loadreviews/2016/SEP0616 --------- Prev Load dir
$prev_load_dir="${lr_dir}/20${prev_year}/$prev_dir/ofls";
$back_ofls_dir="${lr_bak_dir}/20${cur_year}/$load_dir/ofls${load_version}";
$back_dir="${lr_bak_dir}/20${cur_year}/$load_dir/";
$web_dir = $ENV{"WEB_ACIS"};
$web_lr_dir = "${web_dir}/lr_texts";
# Location of web pages on the backup machine (colossus-v).
$web_bak = "/data/anc/apache/htdocs/acis";
# $web_lr_dir = "/proj/web-cxc-dmz/htdocs/acis/lr_texts";
$ace_helper="${cur_load_dir}ofls";
$hist = "$prev_load_dir/ACIS-History.txt";
$old_perigee= <$prev_load_dir/ACIS-Perigee.txt>;
$old_crm = `ls $prev_load_dir/*CRM*`;
chomp($old_crm);
@ocrm = split(/\//, $old_crm);
$ocrm_file = $ocrm[7];
#--------------------
#Check user
#--------------------
$acisdude_uid=getpwnam acisdude;
$acisdude_uid == $< or die "Error: Must be logged in as acisdude. You are $<\n";
#--------------------
#check directory existance
#--------------------
if (-d $lr_dir) {
$work_dir = $lr_dir;
$script_dir = $script_store_dir;
}
else{
die "ERROR: ${lr_dir} is unreachable. Use backup script.\n";
}
#CLEAN DIRECTORIES
#------------------------------------------------------------
# Command line included a -clean switch. Recursively delete
# $lr_dir and $back_ofls_dir, if present.
#------------------------------------------------------------
if ($easy_clean == 1) {
if (-d $back_ofls_dir) {
print "system: rm -r ${back_ofls_dir}\n";
system("rm -r ${back_ofls_dir}");
}
if (-d $ofls_dir) {
print "system: rm -r ${ofls_dir}\n";
system("rm -r ${ofls_dir}");
}
exit(0);
}
#BUILD THE DIRECTORIES
#------------------------------
# mkpath will build the entire path IF NEEDED. This eliminates the need to
# do several mkdirs in if/else loops
#------------------------------
unless( -d $ofls_dir){
mkpath($ofls_dir, 1, 0775);
}
else{
die "The directory $ofls_dir already exists. Code exiting\n";
}
# Only do the backup if this is not a test
# and we're not already on the backup system
if( (! $test_dir) &&
($base_dir eq "/data/acis"))
{
unless( -d $back_ofls_dir)
{
mkpath($back_ofls_dir, 1, 0775);
}
else
{
die "The directory $back_ofls_dir already exists. Code exiting\n";
}
}
#------------------------------------------------------
# Transfer file from Lucky after making the directories
#------------------------------------------------------
# CD to the newly-created ofls<x> directory.
# CD to /data/acis/LoadReviews/<YEAR>/LOAD/ofls<a,b,c etc> -------------------------------- IN OFLS DIR
chdir("${ofls_dir}") || die "Cannot change directories to $ofls_dir\n";
if ($skiplucky)
{
print "\nIn another window, please copy desired backstop tarball\n";
print "into load directory $ofls_dir\n";
print "DO NOT unzip the tarball.\n";
print "\n\nfile copied, ready to continue?(Y/N)\: ";
$user=<STDIN>;
unless ($user =~/y/ || $user =~/Y/)
{
die "No backstop.tar.gz file available, exiting.\n";
}
} # ENDIF if ($skiplucky)
else
{ # using sftp lucky -------------- GET TARBALL
print "\nCopy zipped tarball file from lucky\n";
print "get /home/SOT_Transfer/$load_name/${cur_load}_backstop.tar.gz \n";
#----------------------------------------
# Fork a process to sftp to lucky
#----------------------------------------
print "\n\nSFTP to lucky: Please enter username to connect: ";
$user=<STDIN>;
chop($user);
print "\n Ok as soon as I get your password I will copy the tarball file into $cur_load_dir - be back in a second.....\n";
$my_sftp_status = system("${sftp} ${user}\@lucky.harvard.edu:/home/SOT_Transfer/$load_name/${cur_load}_backstop.tar.gz");
# if the status is non-zero, end it all right here.
# The status values returned are:
# 0 = success (system success not Perl success)
# 65280 = bad username and/or bad password
# or if if lucky is unavailable
if ($my_sftp_status != 0)
{
die "Cannot connect to lucky for some reason. Status = $my_sftp_status";
}
else # Otherwise assume the backstop file was collected and proceed
# If the backstop file was NOT collected, lr will fail downstream
# from here. However if lucky is alive, you get the file.
{
print "\nOk attempted transfer of the backstop file is complete....\n";
}
} # END ELSE if ($skiplucky)
#--------------------------------------------------------------------------------------------------
# TARFILE EXTRACTION - Unzip the file an extract the items we need.
#--------------------------------------------------------------------------------------------------
# You are in the OFLS directory ---------- IN OFLS DIR
@zip = Plucknames->findNames($ofls_dir, "backstop.tar.gz");
$zip = $zip[0];
print "unzipping: $zip ...\n";
# GUNZIP the tarball ------------------------------------------- GUNZIP
# This progam gzips the .tar file at the end of execution.
`${gunzip} $zip`;
# Get tar file
$file = (Plucknames->findNames(".", "backstop.tar"))[0];
# Extract both the CR*.backstop file and the .../vehicle/VR*.backstop file
# backstop extraction and acis script
@tarTOC = Archive::Tar->list_archive($file, 0);
@bck = Plucknames->tarNames(\@tarTOC, "backstop");
foreach $b (@bck){
@field = split(/\s+/, $b);
$bfile=pop(@field);
if($bfile =~ /^CR/){
$backfile=$bfile;
chomp ($backfile);
}
if($bfile =~ /VR/){
$vfile=$bfile;
chomp ($vfile);
@vfield2 = split(/\//, $vfile);
$v_name=pop(@vfield2);
chomp($v_name);
}
chomp ($backfile);
} #end each backstop file found
if ($backfile eq ""){
die "ERROR: can't extract backstop file.";
}
if($vfile eq ""){
warn "Warning: No VR backstop file.\n";
}
print "\n You are in directory: ", `pwd`;
# Run the CTI_report to CTI_REP Pad Time file converter.
# This file is used in comparing backstop pad time against cti_rep pad time
# Create the CTI report file exists flag. It starts out
# "No". It will either be changed to "Yes" if the file
# turns out to exist in the ...mps/er dirctory, or it will stay "No"
my $cti_rep_file_exist = "No";
@cti_rep_file_list = Plucknames->tarNames(\@tarTOC, "CTI");
# Check to see if the cti_rep_file_list is empty
# If it isn't empty we use the CTI_report file supplied in the tarball
# If it's empty we tell the use and exit the program
if (scalar @cti_rep_file_list != 0)
{ # The list is not empty so we have a CTI_report file
# set the exists flag to "Yes"
$cti_rep_file_exist = "Yes";
# Grab the first entry in the list
@field2 = split(/\s+/, $cti_rep_file_list[0]);
$cti_rep_file=pop(@field2);
chomp ($cti_rep_file);
@field3 = split(/\//, $cti_rep_file);
$cti_rep_file_name=pop(@field3);
chomp ($cti_rep_file_name); # file name only
}
else # List is empty inform the user. Give the user the chance to specify one
{
# The list IS empty so we don't have a CTI_report file
# set the exists flag to "No". It was initialized to No
# but do it anyway.
$cti_rep_file_exist = "No";
# Tell the user there is no CTI report file in this backstop tarball
print "\nERROR: can't extract CTI REPORT file.";
# Allow the user to specify one if they want; ask the user
print "\n Do you want to specify your own CTI_report file? (1=Yes, 2=No)\n";
$cti_in=<STDIN>;
chomp($cti_in);
# If the user typed a 1, get the file
if ($cti_in eq 1)
{
print "Please specify the CRM input filename with no directory paths\n\t (and be sure to copy it into the load directory):\n";
$ocrm_file = <STDIN>;
chomp($ocrm_file);
}
else
{
die "\nERROR: No CTI REPORT file exists in the tarball and the user did not wish to copy one in.\n EXITING PROGRAM";
}
} # END ELSE List is empty inform the user and exit the program
# ORLIST - Extract the ORLIST for this week's file
# This block of code finds the name and location of
# the orlist .or file. That path is forwarded to Tarfile_Extract.py
# Load version in ORLIST .or files are always uppercase
# Create the upper case.
$uc_load_version = uc $load_version;
# Formulate the name of the ORLIST lor file for this load and version
$orlist_file_name = $load_name."_".$uc_load_version.".or";
# Find out where the file exists in the tarfile directory hierarchy
@or_file = Plucknames->tarNames(\@tarTOC, $orlist_file_name);
@or_field = split(/\s+/, $or_file[0]);
$or=pop(@or_field);
chomp($or);
# Warn the user if the file cannot be extracted.
if ($or eq ""){
print "WARNING: can't extract .or file.\n";
}
# Now extract the name of the file from the path. This is used when
# listing the files, as lr output for the user, extracted from the tarfile
@or_field2 = split(/\//, $or); #short name
$or_name = pop(@or_field2);
#file used in determining bad pitch angle observations
@mm_sum = Plucknames->tarNames(\@tarTOC, "sum", "mps", "mm");
@field2 = split(/\s+/, $mm_sum[0]);
$mmfile=pop(@field2);
chomp ($mmfile);
if ($mmfile eq ""){
die "ERROR: can't extract mm*.sum file.";
}
@field3 = split(/\//, $mmfile);
$mm_name=pop(@field3);
chomp ($mm_name); #mmfile short name
#file used in displaying version of ACIS tables used in load
@ms_sum = Plucknames->tarNames(\@tarTOC, "sum", "mps", "ms");
@field4 = split(/\s+/, $ms_sum[0]);
$msfile=pop(@field4);
chomp($msfile);
if ($msfile eq ""){
die "ERROR: can't extract ms*.sum file.";
}
@field5 = split(/\//, $msfile); #msfile short name
$ms_name=pop(@field5);
chomp($ms_name);
# Extract the ORP file from mps/er/DO*.orp
@orp_file = Plucknames->tarNames(\@tarTOC, "mps", "er", "DO");
@orp_field = split(/\s+/, $orp_file[0]);
$orp=pop(@orp_field);
chomp($orp);
if ($orp eq ""){
print "WARNING: can't extract DO*.orp file.\n";
}
@orp_field2 = split(/\//, $orp); #short name
$orp_name = pop(@orp_field2);
#Get NIL er file
@nil_file = Plucknames->tarNames(\@tarTOC, "mps", "er", "C${load_name}");
@nil_field = split(/\s+/, $nil_file[0]);
$nil=pop(@nil_field);
chomp($nil);
if ($nil eq ""){
print "\nWARNING: can't extract C${load_name} NIL file.\n";
}
@nil_field2 = split(/\//, $nil); #short name
$nil_name=pop(@nil_field2);
chomp($nil_name);
#Get MNVR file name
@mnvr_file = Plucknames->tarNames(\@tarTOC, "output", "MNVR");
@mnvr_field = split(/\s+/,$mnvr_file[0]);
$mnvr=pop(@mnvr_field);
chomp($mnvr);
if ($mnvr eq ""){
print "WARNING: can't extract MNVR Summary file.\n";
}
@mnvr_field2 = split(/\//, $mnvr);
chomp($mnvr_field2[1]);
#Get the name of ofls directory where we are running
$localdir = getcwd();
print "\nUNTARRING the backstop file";
# UNTAR THE BACKSTOP TAR FILE --------------------------------------- TAR -XVF
# Untar the backstop tar file to extract the necessary files using Tarfile.Extract.py
system("python3 /data/acis/LoadReviews/script/Tarfile_Extract.py --nargs $file $backfile $mmfile $msfile $nil $mnvr $vfile $cti_rep_file $orp");
#----------------------------------------
# LR BREAK PROCESSING - Run ONLY if the -b flag is set
#----------------------------------------
if ($break == 1)
{
# lr_break returns the load type and the interrupt time
$load_type,$interrupt_time = lr_break();
$hist=$edit_hist;
}
# ------------------ CONTINUITY TRACKING -----------------------------
# You now know everything you need to know in order to write
# out the ACIS-Continuity.txt file
# Open the ACIS-Continuity.txt file
open(CONTFILE, ">$ofls_dir/ACIS-Continuity.txt");
# Now that you know the location of the previous load, write that full
# directory path to the ACIS-Continuity.txt file
print CONTFILE $prev_load_dir.$ofls_val, "\n";
# Now, if the user specified either "VOC" or "VOB"for the VO command line argument,
# then append "VO_" to the load type. This will inform the models
# that when the continuity load is read, the Vehicle Only version
# should be used. Otherwise load_type should be just the present
# value
#
# VOB stands for (V)ehicle (O)nly (B)oth, meaning that the VR*.backstop vehicle only file
# should be read for both the Review and the Continuity load. But this piece of code
# handles what gets written to the ACIS-Continuity.txt file. So in both cases (VOC and VOB)
# You want ACIS-Continuity.txt to indicate vehicle-only for the Continuity load.
# Reading the VR*.backstop file for the review load is handled by the call to run-models.pl.
if ( ($VO_choice eq "VOC") || ($VO_choice eq "VOB") )
{
# User selected VOC for the VO switch. Tell the model to read
# the vehicle only load for the Continuity. Append "VO_"
# to the recognized load type
$load_type = "VO_".$load_type;
}
# Now if $VO_choice is either VOB or VOR, then the REVIEW Load is to be run Vehicle Only.
# In this case copy the CR*.backstop file to ORIG_CR*.backstop, and the .../vehicle/VR*.backstop
# is to be copied to CR*_V.backstop.
#
if ( ($VO_choice eq "VOR") || ($VO_choice eq "VOB") )
{
# Save the full backstop file as ORIG_CR*.backstop
print "\nReceived the $VO_choice switch. Copying $backfile to ORIG_${backfile}";
system("mv $backfile ORIG_${backfile}");
# Formulate the modified name for the CR backstop file to include "_V" in the name
# Index of the beginning of the extension: ".backstop"
$ext_index = index($backfile, ".backstop");
# Extract the file name without the extension
$old_CR_file_name = substr($backfile, 0, $ext_index);
# Compose a new name by concatenating the "_V" to the name and include the extension
$new_CR_file_name = "${old_CR_file_name}_V.backstop";
# Perform the copy of the Vehicle-Only file to tne CR file with the new name.
print "\n ...and now copying $vfile to $new_CR_file_name";
system( "cp $vfile $new_CR_file_name");
# Lastly, change the variable $backfile so that it points to the new CR*_V.backstop file
# Other applications need to access this file and they need to know the new name
$backfile = $new_CR_file_name;
}
# Write out the type of load: Normal, TOO, SCS107
if ($break == 1)
{
print CONTFILE $load_type, " ", $interrupt_time, "\n";
}
else
{
print CONTFILE $load_type, "\n";
}
# Close the continuity file
close(CONTFILE);
# Inform the user of the load type LR has determined from your answers
print "\nLR has determined that the review load is of type: $load_type\n";
#--------------------------------------------------------------------
#Let's go!
#--------------------------------------------------------------------
#------------------------------
#Print files in use
#------------------------------
print "\n\tFOR LOAD ${load_name}\n";
print "\tNew Directory: $localdir\n";
print "\tCombined Backstop File: $backfile\n";
print "\tVehicle Backstop: $vfile\n";
print "\tmm*.sum File: $mm_name\n";
print "\tms*.sum File: $ms_name\n";
print "\tCRM Pad Time file: $crm_name\n";
print "\tHistory File Used: $hist\n";
print "\tManuever File Used: $mnvr\n";
print "\tCTI_Report File Used: $cti_rep_file_name\n";
print "\tOrbit Events File Used: $orp_name\n";
print "\tORLIST file extracted: $or_name\n";
#unlink ("*.tar");
# Move files to the right locations.
rename("$mmfile","./$mm_name");
rename("$msfile","./$ms_name");
rename("$orp", "./$orp_name");
# If we found a CTI report file then copy it over into the
# operational ofls directory.
if ($cti_rep_file_exist eq "Yes")
{
print "\n Copying over the CTI Report file";
rename("$cti_rep_file","./$cti_rep_file_name");
}
else
{
print "\nNo CTI Report file was found - I sure hope you copied one in";
}
# Now that you've copied over the CTI_report file into the ofls
# directory, run the converter on it. Remember, if you got here it's
# because either the tarball had a CTI_report file in it or the user
# copied one in.
print "\nRunning the converter to go from CTI to CRM";
print "\nThe Converter command I'm running is: ";
print "\n python3 $script_store_dir/Convert_CTI_to_CRM.py $ofls_dir\n";
`python3 $script_store_dir/Convert_CTI_to_CRM.py $ofls_dir`;
if(-e "$nil")
{
rename("$nil","$nil_name");
}
if(-e "./er")
{
system("mv er/* .");
rmdir("er");
}
# Remove the extra directories you created with the tar command
rmtree("./mps");
#------------------------------
#Informational
#------------------------------
#Run the Health and Safety script
print "\tRunning Health and Safety Script...\n\n";
# PRODUCTION
system("python3 ${script_store_dir}/LRHS $localdir/${backfile} ${hist} > ${ofls_dir}/LRHS.output ");
print "\tRunning ACIS Load Review Script...\n\n";
# RUN ACIS-BACKSTOP
# PRODUCTION
$backstop_str = "$backstop -s ${server} ${localdir}/${backfile} ${hist}";
print "\nRunning $backstop_str...\n";
system("$backstop_str");
print "\nACIS-backstop completed.\n";
#------------------------------
# Set up soft links
#------------------------------
chdir("$cur_load_dir") || die "cannot change to ${cur_load_dir}\n"; # -------------------------------- CHDIR IN .../YYYY/MMMDDYY DIR
if(-e "./ofls")
{
unlink("./ofls");
}
# Point ofls to /data/acis/Loadreviews/2017/THE_LOAD/ofls<a,b,c...>
symlink( "${ofls_dir}", "./ofls");
# CD to the OFLS dir
chdir("${ofls_dir}") || die "Cannot change to {$ofls_dir}"; # -------------------------------- CHDIR IN OFLS DIR
#determine and display version of ACIS tables used:
open(DAT, $ms_name) || die "ERROR! can't open ms*.sum file";
open(OUT, ">ACIS-Tables.txt");
while (<DAT>)
{
@row = split (/\s+/, $_);
if (@row != " ")
{
$description = $row[0];
chomp($description);
if ($description eq "ACIS" && $row[1] eq "Configuration:")
{
@cfg_list = split (/\//, $row[2]);
$cfg_file = $cfg_list[8];
chomp($cfg_file);
}
if($description eq "ACIS" && $row[1] eq "Data:")
{
@dat_list = split (/\//, $row[2]);
$dat_file = $dat_list[8];
chomp($dat_file);
}
}
}
print OUT "$cfg_file\n$dat_file\n";
close(OUT);
close(DAT);
#------------------------------
# Check for bad sun angle observations: changed to take
# previous directory string
#------------------------------
print "\nRunning saa_checker.pl...$script_dir/saa_checker.pl ${prev_load_dir}\n";
system ("$script_dir/saa_checker.pl ${prev_load_dir}");
open(SAA,"saa_check.txt") || warn "\nNo Observations with bad Sun Angles\n";
print "\nATTENTION! Observations with bad sun angles:\n";
while(<SAA>){
print $_;
}
close(SAA);
#------------------------------
#run bright-source violations:
#------------------------------
print "Running bright-source...\n";
print "$cc_directory/bright-source ${localdir}/${mnvr}\n";
system("$cc_directory/bright-source ${localdir}/${mnvr}");
if(-f "violations.txt") { # only if file exists
open(VIO,"violations.txt") || warn "Error opening violations.txt\n" ;
$count=0;
while(<VIO>){
$count++;
}
if($count > 2){
seek(VIO,0,0);
while(<VIO>){
print $_;
}
}
else{
print "\n***No bright-source violations in this load.***\n";
}
close(VIO);
}
else
{
print "\nBright source code failed. Email nadams\@cfa with above errors.\n";
}
#---------------------------------------------------------------
#
# Any function that can be done prior to the execution of the
# Thermal Model run should be included here.
#
# At this point we are in the $ofls_dir - e.g. /data/acis/LoadReviews/2021/SEP2021/oflsa
# so any function you place here should either execute in this directory, or
# you can chdir to a different directory but be SURE to chdir back to
# $ofls_dir when done.
#
#---------------------------------------------------------------
#
# Run Check_Power_Cmds.py
print "\nEXECUTING THE CHECK POWER COMMAND PROGRAM";
# PRODUCTION
system("python3 /data/acis/LoadReviews/script/CHECK_POWER_COMMANDS/Check_Power_Cmds.py");
# Now execute the Window Check program
print "\nEXECUTING THE WINDOW CHECK PROGRAM.";
system('python3 /data/acis/LoadReviews/script/WINDOW_CHECK/Window_Check.py');
# Next execute the SCS-155 Deadman Check
print "\nEXECUTING THE SCS-155 DEADMAN CHECK PROGRAM";
system("python3 /data/acis/LoadReviews/script/DEADMAN_SCS_155/Deadman_Check.py ${ofls_dir} ${nlet_file}");
# Next execute the HETG Check
print "\nEXECUTING HETG CHECK PROGRAM";
system("python3 /data/acis/LoadReviews/script/HETG_CHECK/HETG_Check.py ${ofls_dir} ${nlet_file}");
# Execute the Idle Dwell check
print "\nEXECUTING THE IDLE DWELL CHECK PROGRAM.\n";
if ($VO_choice eq "")
{system("python3 /data/acis/LoadReviews/script/IDLE_DWELL/Find_Idle_Dwells.py ${ofls_dir} ");}
else
{system("python3 /data/acis/LoadReviews/script/IDLE_DWELL/Find_Idle_Dwells.py ${ofls_dir} --vo ${VO_choice} ");}
# Execute the HRC/TXINGING Timing check
print "\nEXECUTING THE HRC TXING TIMING CHECK PROGRAM.";
system("python3 /data/acis/LoadReviews/script/HRC_TXING_CHECK/HRC_Txing_Check.py ${ofls_dir} ");