Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.eso.org/projects/dfs/team/template-for-python-module.py
Дата изменения: Mon Apr 18 17:24:35 2005
Дата индексирования: Sun Apr 13 22:49:08 2008
Кодировка:

Поисковые слова: van allen
#!/opsw/util/python/bin/python

#******************************************************************************
# European Southern Observatory
# Data Management and Operations Division / Data Flow System department
#
# Module name:
#
# "@(#) $Id: .py,v 1.1 2000/11/14 07:38:41 khaggouc Exp $"
#
#******************************************************************************

# Who When What Why
# -------- ---------- -------- --------------------------------------------
# DD/MM/YYYY Created
# DD/MM/YYYY Modified (problem reports DFS0XXXX ...)



# --------------------------
# OVERALL MODULE DESCRIPTION
# --------------------------
"""


... (optional/mandatory)
... (optional/mandatory)
"""
#

# -----------
# PSEUDO CODE
# -----------
# summarize the treatment done by this module using the usual control structures
# provided by Python, but normal text or sentences instead of variables
# names or function calls.


# ------------
# DEPENDENCIES
# ------------
# sys is the most-used module which contains a set of system-level components.
# os provides functions like os.path.join() and os.environ[var] for interacting with the OS.
# glob.glob() finds all the pathnames matching a specified pattern according to the shell rules.
# re provides regular expression tools re.sub() and re.search() for advanced string processing.
# the Sybase module provides function like sybase.connect() to connect to sybase DB.
# time offers functionality like mktime() and strptime() for manipulating time.
# string offers functionality like lstrip(), rstrip(), replace() ...
# socket uses functions like gethostname().
import sys, os, glob, re, Sybase, time, string, socket



# ----------------
# INITIAL SETTINGS
# ----------------
myGlobalVar = None
dbConnect = None




# ---------
# FUNCTIONS
# ---------
# always indicate the type and range of values of every argument, in particular the return value.

# ---------------------------------------------------------------------------
def functionName1(,
,
...):
"""


: ().
: ().

Returns: X = if , Y = if ()
"""

# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
def setDbCon(dsquery,dbuser,dbpassword):

"""
Function to open the connection with a given database.

dsquery: usually associated to the DSQUERY environment variable, gives
the logical name of the database server to access (string)
dbuser: username to use to login to the database server (string)
dppassword: password to login to the database server (string)
Returns: none
"""

global dbConnect

dbConnect = Sybase.connect(dsquery,dbuser,dbpassword,delay_connect=1)

dbConnect.set_property(Sybase.CS_HOSTNAME, socket.gethostname())
dbConnect.set_property(Sybase.CS_APPNAME, 'SEGpropcheck')
dbConnect.autocommit = 1
dbConnect.connect()
reschain = dbConnect.execute('SET CHAINED OFF')
# ---------------------------------------------------------------------------

# ---------------------------------------------------------------------------
def execQuery(myQuery):

"""
Function to execute a query and return its results.

myQuery: the SQL query to execute (string)
Returns: string returned by Sybase when execution the query (string)
"""
global dbConnect

res = dbConnect.execute(myQuery)
# ... processing of result ...
res2 = dbConnect.execute('commit')
return res
# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
def getPrintEnv(var):

"""
Function to print the value of an environment variable and return it.
Environment variables are accessed through the os module's environ dictionary.
Because it's a dictionary, lookups are done with the os.environ[var] syntax.

var: name of environment variable (string).
Returns: value of environment variable (string).
"""
val = os.environ[var]

print "Value of environment variable is: " + val
return val
# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------




# -------
# CLASSES
# -------
# always indicate the type and range of values of every argument, in particular the return value.
class className1:
"""
.
"""
def __init__(self,
,
,
...):
"""
.

: ().
: ().
...
"""
pass


def (self,
,
,
...):
"""
.

: ().
: ().
...

Returns: Void | ().
"""
pass


#
# --------------------------------------------------------------------------









# --------------------------------------------------------------------------
# HERE IS THE MAIN
# --------------------------------------------------------------------------


if __name__ == '__main__':
"""
Main function details ...
"""

DSQUERY="TESTSRV"
DBUSER="opc"
DBPASSWORD="???"
SQLCONNECT="$SYBASE/bin/isql -X -S$DSQUERY -U$DBUSER -P$DBPASSWORD"

setDbCon(DSQUERY,DBUSER,DBPASSWORD)



#
#
# --------------------------------------------------------------------------



# --- oOo ---