Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/begin_boundary_check.py
Дата изменения: Fri Apr 8 12:46:10 2016
Дата индексирования: Mon Apr 11 05:15:49 2016
Кодировка:
#
#MODULE begin_boundary_check
#
#***********************************************************************
"""

**PURPOSE** --
This module contains a class that checks the no-activity zone at
the start of a calendar.

**DEVELOPER** --
Don Chance

**MODIFICATION HISTORY** --

o Initial implementation 9/21/00
o write out explanation of the failure. drc 10/23/08
o move database query into run function. drc 11/18/15
"""
#***********************************************************************
from abstract_check import abstract_check
from checklist_init import PASS, FAIL, sogs_db
import stpydb
import re

__version__ = "15.11.18"


class begin_boundary_check(abstract_check):
"""Verify no activities or SI recons within 10 minutes of calendar start
"""
def run(self):
abstract_check.run(self)
file_pointer = open(self.outfile, "w")

# Uses the current map files.

# Get the no activity time for calendar starts
dbconn = stpydb.stpydb(dbmsName=sogs_db)
qstring = "select bou_buf_1 from wgtune_parms"
dbconn.query(qstring)
result = []
while dbconn.execute(result):
CAL_START_DELTA = result[0]
if dbconn.rowcount == 0:
raise IOError('Query "%s" returned zero rows.' % qstring)

disp = self.my_checklist.cal_display
callist = disp.parse_calendar_display("calendar -display -si -act ")
rcf_found = 0
cal_start_found = 0
self.pf_status = PASS

for line in callist:
if line['begin_time'] and (line['begin_time'] >= disp.begin_time + CAL_START_DELTA):
# Once we're into the calendar past the delta time, we're finished.
file_pointer.write("%s %s %s" % (line['begin_time'],
line['end_time'],
line['data_string']))
break
if (rcf_found and
not cal_start_found and
re.search("SI (UP)|(DOWN)", line['data_string'])):
# We're in between the RCF and the calendar start
# SI UP and DOWN transitions are not allowed here
file_pointer.write("%s %s %s" % (line['begin_time'],
line['end_time'],
line['data_string']))
file_pointer.write('SI UP and DOWN transitions are not allowed between RCF and the calendar start.\n')
self.pf_status = FAIL
if cal_start_found and re.search(r'\S', line['data_string']):
# After the calendar start, nothing is allowed until the delta time
# is reached. \S means match any non-whitespace
file_pointer.write("%s %s %s" % (line['begin_time'],
line['end_time'],
line['data_string']))
file_pointer.write("After the calendar start, nothing is allowed until the delta time is reached.\n")
self.pf_status = FAIL
if re.search("Calendar Start ", line['data_string']):
file_pointer.write("%s %s" % (line['begin_time'],
line['data_string']))
cal_start_found = 1

if re.search(r"\* M Sci.*RCF01-091:", line['data_string']):
file_pointer.write("%s %s %s" % (line['begin_time'],
line['end_time'],
line['data_string']))
rcf_found = 1

if self.pf_status == PASS:
file_pointer.write("\nLooks good .... Check passes.\n")
elif self.pf_status == FAIL:
file_pointer.write("\n***** CHECK FAILS ******\n")

return self.pf_status


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