Thanks for the detailed explanation, now i got how can i use STAF. i wen
through the documentation in the official site but i feel its not for novice
. Your explanation really helped me.
Where can i get list of services that  STAF supports and some explanation
about these services as how they are useful.
Can i use STAF for running the python script and collecting the logs on the
same machine

thanks a lot

/santosh

On Mon, Jul 18, 2011 at 11:10 PM, Sharon Lucas <luc...@us.ibm.com> wrote:

> Or, maybe you wanted to log the result from your database select to a file
> on another machine.  You could use the STAF LOG service and submit the
> request within your Python script.  For example, you could update your
> Python script as follows to do this:
>
> from PySTAF import *
> import sys
>
> # Create a STAF handle works to use to submit STAF service requests
>
> try:
>     handle = STAFHandle("Test1")
> except STAFException, e:
>     print "Error registering with STAF, RC: %d" % e.rc
>     sys.exit(e.rc)
>
> # Connect to a database on get a phone number for sam
>
> import MySQLdb
> db = MySQLdb.Connect("localhost","root","san123","phone")
> cursor = db.cursor()
> cursor.execute("SELECT * FROM phonebook WHERE Name ='san'")
> get_contact = cursor.fetchall()
> print get_contact
> db.close
>
> # Log the phone number in a log on machine machine1
>
> message = "Phone# for San: %s" % (get_contact)
> request = 'LOG GLOBAL LOGNAME Test1 LEVEL Info MESSAGE "%s"' % (message)
> result = handle.submit("machine1", "LOG", request)
>
> if (result.rc != STAFResult.Ok):
>     print "Error on STAF machine1 LOG %s" % (request)
>     print "Expected RC: 0"
>     print "Received RC: %d, Result: %s" % (result.rc, result.result)
>     sys.exit(1)
>
> print "\n*** Test successful ***"
>
> # Un-register the STAF handle
>
> result = handle.unregister()
>
> if (result != STAFResult.Ok):
>     print "Error unregistering with STAF, RC: %d" % result
>     sys.exit(result)
>
> sys.exit(0)
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin,   luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
> ----- Forwarded by Sharon Lucas/Austin/IBM on 07/18/2011 12:20 PM -----
>
> From:        Sharon Lucas/Austin/IBM
> To:        santosh hs <santosh.tron...@gmail.com>
> Cc:        staf-users@lists.sourceforge.net
> Date:        07/18/2011 12:19 PM
> Subject:        Re: [staf-users] Can some one tell me as how can i use
> STAF in python.
> ------------------------------
>
>
> What is it that you want to do via STAF?  It's difficult to answer how you
> can use STAF if we don't know what it is that you are trying to accomplish
> via test automation.
>
> For example, you could use STAF's PROCESS service to run your Python script
> on a different machine (or on many different machines) if you wanted.  For
> example, perhaps from machine1 you wanted to be able to run this Python
> script on machine2.  You could use STAF's FS (File System) service to copy
> your sample script file from machine1 to machine2 and then use STAF's
> PROCESS service to run this script.  Here are STAF command line line
> examples of how to do this:
>
> STAF machine1 FS COPY FILE "/tmp/test.py" TOFILE /tmp/test.py" TOMACHINE
> machine2
> STAF machine2 PROCESS START SHELL COMMAND "/tmp/test.py" RETURNSTDOUT
> STDERROTSTDOUT WAIT
>
> STAF also provides APIs for submitting STAF service requests via Java,
> C/C++, Python, Perl, and Tcl or you can use STAX.
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin,   luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
>
>
>
> From:        santosh hs <santosh.tron...@gmail.com>
> To:        staf-users@lists.sourceforge.net
> Date:        07/18/2011 10:42 AM
> Subject:        [staf-users] Can some one tell me as how can i use STAF in
> python.
> ------------------------------
>
>
>
> Can some one tell me as how can i use STAF in python.
> suppose i have script which connects to DB and fetches the data , in this
> case how can i use STAF.
>
> below is sample script
>
> import MySQLdb
> db=MySQLdb.Connect("localhost","root","san123","phone")
> cursor=db.cursor()
> cursor.execute("SELECT * FROM phonebook WHERE Name ='san')
> get_contact=cursor.fetchall()
> print get_contact
> db.close()
>
>
> please let me know how ca i use STAF here, any other simple example for
> STAF usage other than the above script is also appreciated.
>
>
> ------------------------------------------------------------------------------
> AppSumo Presents a FREE Video for the SourceForge Community by Eric
> Ries, the creator of the Lean Startup Methodology on "Lean Startup
> Secrets Revealed." This video shows you how to validate your ideas,
> optimize your ideas and identify your business strategy.
> http://p.sf.net/sfu/appsumosfdev2dev
> _______________________________________________
> staf-users mailing list
> staf-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/staf-users
>
>
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to