Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/acs_cor_sched_check.py
Дата изменения: Fri Feb 28 14:46:08 2014
Дата индексирования: Sat Mar 1 22:05:57 2014
Кодировка:
#
# MODULE acs_cor_sched_check
#
#******************************************************************************
"""This tool performs a calendar check that the appropriately tagged ACS
Coronagraphy SUs contained within Timing Linksets contain no other ACS
SUs scheduled withing the gaps of the ACS/COR linkset.

TITLE: acs_cor_sched_check.py
DEVELOPER: Merle Reinhart, 31-Jan-2003

PURPOSE: Verify the correct lack of ACS SUs between ACS Coronagraphy
SUs within the same Timing Linkset.

USAGE: do acs_cor_sched_check

where is the name of the saved calendar that you
wish to check. NOTE: this tool will
overwrite the current map files when run
in standalone mode.

RETURNS: Nothing when run in standalone mode.
pf_status when run as part of the calendar checklist.

MOD HISTORY:
9/28/09 drc modified for candlist -disp output issue with spss build 49.9
1/04/10 drc modified for candlist -disp output issue with spss build 50.0
"""
#******************************************************************************

__version__ = "1/4/10"

from abstract_check import *
import os
import get_linkset_gap_nosched_windows, file_util, spss_sys_util
import time_util

class acs_cor_sched_check(abstract_check):
"""Verify correct scheduling of ACS SUs around the scheduled ACS/COR SUs.
"""

# Works with the current map files.

def run(self):
abstract_check.run(self)
file_pointer = open(self.outfile, 'w')

self.pf_status = PASS

# First, let's get the ACS no-sched windows
acs_nosched_windows = get_linkset_gap_nosched_windows.run('ACS')

# If there are no ACS no-sched windows, then by default,
# the check passes
if (not acs_nosched_windows):
file_pointer.write('No problems found relative to ACS/COR SUs. \n')
file_pointer.flush()
return self.pf_status
# endif

# Now let's get all the scheduled SUs, times and SIs
cand_file = file_util.tempfile()
cmnd = 'candlist -display all -output=%s' % cand_file
#cand_file = cand_file + '.candlist'
status,output = spss_sys_util.command(cmnd)
if (status != spss_sys_util.SUCCESS):
raise RuntimeError(status, output)
# endif
sched_sus = \
get_linkset_gap_nosched_windows.get_candlist_sched_sus(cand_file)
os.remove(cand_file)

# Now remove all the visits that don't contain ACS
sched_acs_sus = []
for i in sched_sus:
for j in i['sis_used']:
if (j == 'ACS'):
sched_acs_sus.append(i)
# endif
# end for j
# end for i

# Now let's see if any of the individual SUs overlap the non-sched
# windows
bad_sus = []
for k in sched_acs_sus:
check_window = time_util.window_list( \
time_util.window(k['start'], k['end']))
inter_wind = check_window.intersection(acs_nosched_windows)
if (inter_wind):
self.pf_status = FAIL
file_pointer.write( \
'SU %s scheduled at %s - %s overlaps ACS/COR\n' \
% (k['su'], k['start'], k['end']))
bad_sus.append(k)
# endif
# end for k

if (self.pf_status == FAIL):
file_pointer.write('\nWindows where ACS may NOT be scheduled:\n')
file_pointer.write('%s\n' % acs_nosched_windows)
else:
file_pointer.write('No problems found relative to ACS/COR SUs.\n')
# end if

file_pointer.flush()
return self.pf_status
# end def run
# end class acs_cor_sched_check

def run(calendar):
"""Run the check stand alone.
"""
import calchecklist
clist = calchecklist.cal(calendar, 'none', 1)
check = acs_cor_sched_check(clist)
print "\n Output sent to file " + check.outfile
check.run()
# end def run