Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/return_snaps.py
Дата изменения: Fri Feb 28 14:46:11 2014
Дата индексирования: Sat Mar 1 16:17:17 2014
Кодировка:

Поисковые слова: annular solar eclipse
"""Returns the reserved SUs to the 'pool' from which they came.

#******************************************************************************
# TITLE: return_snaps.py
# DEVELOPER: Merle Reinhart, 7-Mar-2000
#
# PURPOSE: This tool will scan wistat_sunit for various pool and snap SUs
# on the given ccl and return those that are reserved and
# unscheduled to the useable pool.
#
# If, on the other hand, GLOBAL is passed as the ccl, then the
# GLOBAL baseline is scanned and all useable SU that appear are
# set to a status of scheduled and the week_id updated.
#
# USAGE: do return_snaps
# where: is either the cclist name or GLOBAL
#
# MOD HISTORY:
# 9/23/04 dc Remove hard-code 'planinst'.
#
#******************************************************************************
"""

def run(ccl=None):

import os, string, spss_sys_util, db_util, file_util

if (ccl is None):
raise IOError('Usage: do return_snaps |GLOBAL')
# end if

if (string.upper(ccl) == 'GLOBAL'):
print 'You have chosen to update the pool from the GLOBAL baseline...'

temp_output = file_util.tempfile()
isql_file = spss_sys_util.resolver('PMREP','return_snaps_global.isql',1)
db_util.isql_report(isql_file, temp_output)

tmp = open(temp_output, 'r')
out_str = tmp.read()
tmp.close()
print ' '
print out_str
os.remove(temp_output)

else:
# verify if the input cclist exists
test = string.lower(ccl) + '.dat_1'
ccl_file = spss_sys_util.resolver('SPSSCCL', test)
if (ccl_file == ''):
raise IOError('CCL %s does not exist...' % ccl)
# end if

# special calendars for baselining purposes that contain a
# spacecraft payload safing always have a naming convention
# of Byydddlvv
if (string.upper(ccl[0]) == 'B'):
week_id = ccl[1:6]
else:
week_id = ccl[0:5]
# end if

temp_output = file_util.tempfile()
isql_file = spss_sys_util.resolver('PMREP', 'return_snaps_cal.isql',1)
params = [('CAL', string.upper(ccl)),
('WEEK', week_id)]
db_util.isql_report(isql_file, temp_output, params)

tmp = open(temp_output, 'r')
out_str = tmp.read()
tmp.close()
print ' '
print out_str
os.remove(temp_output)

# delete the *.gimme files in the calendar working directory
# remember, the 2nd parameter to resolver must be a 'relative' path
# not an 'absolute path (ie, it cannot start with a '/') and resolver
# doesn't handle wildcards
cal_dir = spss_sys_util.resolver('SPSS_DATA_DK',
os.path.join(os.environ['LOGNAME'], week_id))
gimme_file = os.path.join(cal_dir, '*.gimme')

# use special function to delete the files since os.remove doesn't
# handle wildcards and on VMS will only delete the highest version
status1, status2 = file_util.delete_file(gimme_file)
if (status2 != []):
print 'The following files could not be deleted:'
for q in status2:
print q[1][1]
# end for
# end if

# end if

return

# end def run