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

Поисковые слова: п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п
#! /usr/local/bin/python
#
#MODULE create_uscs
#
#***********************************************************************
"""

**PURPOSE** --
Create USCs (User Specified Constraints).

**DEVELOPER** --
Bill Workman

**KEY** --
args = a list containing the argumants from the command line.
queryOptions = a dictionary conaining optional db query parameters.
processOptions = a dictionary containing options such as listonly.
required_args = a dictionary of required arguments.
uscOptions = a dictionary containing USC specification options.
usc_name = Name of USC (see the assist relation usc for examples).
usc_keyword_args = a dictionary of USC specification options.
visitList = a list of visits obtained either from the command line
or a database query.
windowList = a list of dictionaries containing start and end times.

**CODE ALGORITHM** --
1. If no parameters, then print documentation string and exit.
2. Define options and parameters.
3. Set variables from required_args and uscOptions.
4. If visit list is defined use it, otherwise look it up in
the database.
5. If not running in list_only mode, use visit_util.apply_usc
to write the USC's into the database. If running in
list_only mode, print the visit list.

**NOTES** --
1. To create a USC for given visit(s), an example would be:
do create_uscs LRP_GTO_STIS 1999.001:00:00:00 2000.274:00:00:00 -visits="0756601"
2. To create USCs for a range of visits given by a database search,
an example would be (it is suggested to also include the -list_only option
to ensure the database changes proceed as intended):
do create_uscs LRP_GTO_STIS 1999.001:00:00:00 2000.274:00:00:00
-other_qualifiers="and (sut.sunit_id in (select sunit_id from usc where
sunit_id="0756601"))"
Note that a visit's status must be pi, implementation, or scheduling in order
for the database search capability to find a given visit.

**MODIFICATION HISTORY** --
Date Who What
==== === ====
01/31/01 Workman initial implementation
05/10/05 Bower re-testing and restructuring
05/18/05 Bower implement -exclude_usc option
05/20/05 Bower change call for populatefromdb
05/25/05 Bower add -verbose option
08/06/08 Bower add -parallels option
"""
#***********************************************************************
__version__ = "08/06/08"
import visit_util, spss_sys_util, sys

def run(args):
"""
Create USCs.

Usage:
do create_uscs usc_name window1_start window1_end
[[window2_start window2_end]...] [-options]

usc_name is the name of the USC to be inserted into assist relation
usc. It must be 50 characters or less in all caps.

window_start and window_end are the start and end times of the window
in SOGS format.

-options are one or more of:

Visit list DB query options (to define the DB search parameters):
-prime
-parallel
-internal
-pure_parallel
-visits= "01234v1 01234v2 01234v3 ..."
-si_modes= "stis_ccd stis_fuv_mama stis_nuv_mama wfpc2 fgs
nic1 nic2 nic3 acs_hrc acs_wfc acs_sbc"
-type= "GO GTO ENG SM..."
-cycle=
OR -min_cycle=
and/or -max_cycle=
-other_qualifiers= "any valid subquery of the form:"
"and (sut.sunit_id in (select sunit_id from ... where ...))"
OR "and (cp.prop_id in (select prop_id from ... where ...))"

USC specification Options:
-usc_mode= "combine" (default) | "override"
-usc_value= (default=1.0)
-usc_comment= "explanatory text" (default="No comment provided.")
-exclude_usc (To define the actual USC inserted into the DB to be
the logical complement of the window defined on the
command line.)
-list_only (When used, function only displays the list of visits
based on query options; USC's are not created.)

Verbose output Options:
-verbose
"""

if not args:
# Spew out the usage and quit when no parameters are provided.
print run.__doc__
return spss_sys_util.SUCCESS
else:
print "Begin create uscs with the following arguments:"
print args

# Define options and parameters.
visitList, required_args, uscOptions, queryOptions, processOptions = \
visit_util.parsecommandline()

if processOptions.has_key("verbose"):
print visitList, required_args, uscOptions, queryOptions, processOptions

usc_name = required_args["usc_name"]
windowList = required_args["windowList"]
usc_keyword_args = {}
if uscOptions.has_key("usc_mode"):
usc_keyword_args["usc_mode"] = uscOptions["usc_mode"]
if uscOptions.has_key("usc_value"):
usc_keyword_args["usc_value"] = uscOptions["usc_value"]
if uscOptions.has_key("usc_comment"):
usc_keyword_args["usc_comment"] = uscOptions["usc_comment"]
if uscOptions.has_key("exclude_usc"):
usc_keyword_args["exclude_usc"] = uscOptions["exclude_usc"]
if processOptions.has_key("verbose"):
usc_keyword_args["verbose"] = processOptions["verbose"]

if visitList and not queryOptions:
visitList = visit_util.visit_list(visitList)
else:
if processOptions.has_key("verbose"):
print "Getting visit list from database..."
print queryOptions
visitList = visit_util.populatefromdb(queryOptions,verbose='yes')
else:
visitList = visit_util.populatefromdb(queryOptions)

if processOptions.has_key("verbose"):
print visitList

if visitList.sulist:
if not processOptions.has_key("list_only"):
apply(visitList.apply_usc, (usc_name, windowList), \
usc_keyword_args)
else:
print visitList.format(["column", "spssversion"])
else:
print ""
print "No visits supplied or found in DB search; Create_uscs terminated."

print "create_uscs completed."

return spss_sys_util.SUCCESS


if __name__ == '__main__':
run(sys.argv[1:])