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

Поисковые слова: arp 220
#
#MODULE history_file_check
#
#***********************************************************************
"""

**PURPOSE** --
Examine the history file for any special calendar, SMS, PASS, or delivery
letter instructions.

**DEVELOPER** --
Don Chance

**MODIFICATION HISTORY** --

o Initial implementation 7/29/14
o fix how week id is determined. drc 10/10/14
o code cleanup drc 12/7/15
"""
#***********************************************************************
from abstract_check import abstract_check
from history_file_parser import find_text, BEGIN_TAG_DICT
import spss_sys_util
import os

__version__ = '15.12.07'


class history_file_check(abstract_check):
"""Examine the history for any special instructions.
"""
def run(self):
abstract_check.run(self)
if self.my_checklist.type == "Calendar":
w = self.my_checklist.calendar.get_begin_time().strftime('%y%j')
Types = ['cal']
elif self.my_checklist.type == "SMS":
w = self.my_checklist.my_sms.get_begin_time().strftime('%y%j')
Types = ['sms']
else:
# PASS checklist.
w = self.my_checklist.mscl.my_ms.sms.get_begin_time().strftime('%y%j')
Types = ['pass', 'delivery']
hfile_path = os.path.join(spss_sys_util.resolver('CAL_BUILD_ROOT', w), w + '.his')

outtext = ""
if os.path.exists(hfile_path):
for Type in Types:
if Type == 'pass':
outtext += "\nPASS notes:\n"
elif Type == 'delivery':
outtext += "\nDelivery letter notes:\n"
outtext += "\n".join(find_text(Type, hfile_path))
else:
outtext = "Unable to find history file: %s" % hfile_path

open(self.outfile, 'w').write(outtext)

return self.pf_status


def run(name='', Type='cal'):
"""Run the check stand alone.
"""
if Type not in BEGIN_TAG_DICT.keys():
raise ValueError('unknown type: %s' % Type)
if name:
if Type == 'cal':
import calchecklist
clist = calchecklist.cal(name, stand_alone=True)
elif Type == 'sms':
import smschecklist
clist = smschecklist.sms(name, stand_alone=True)
else:
import passchecklist
clist = passchecklist.Pass(name, stand_alone=True)
check = history_file_check(clist)
print "\n Output sent to file " + check.outfile
check.run()


if __name__ == '__main__':
import sys
if len(sys.argv) > 1:
run(*tuple(sys.argv[1:]))
else:
run()