Yes, you need to unmarshall the result to access individual fields in the 
result.result variable.  The STAF Python User's Guide at 
http://staf.sourceforge.net/current/STAFPython.htm provides information on 
unmarshalling, as well as examples.  Note that you don't have to 
unmarshall the STAFResult's result string returned by the submit() method 
(assuming auto-unmarshalling is enabled for the handle which it is by 
default).  Instead, you can directly access the result's marshalling 
context in variable result.resultContext, and/or the root object of the 
result's marshalling context in variable result.resultObj.

For example, here's a snippet of Python code that submits a PROCESS START 
request to run "java -version" and prints the stdout/stderr data 
containing the Java version if it succeeded:

command = 'java -version'
request = 'START SHELL COMMAND %s RETURNSTDOUT STDERRTOSTDOUT WAIT' % 
(wrapData(command))
print '\nSTAF %s PROCESS %s' % (machine, request)
result = handle.submit(machine, 'PROCESS', request)

if result.rc != STAFResult.Ok:
    print 'STAF local PROCESS %s failed, RC=%s Result=%s' % (request, 
result.rc, result.result)
    sys.exit(1)

# The result object is a map (aka Python dictionary) containing fields 
such as "rc" and "fileList"

processMap = result.resultObj

if processMap['rc'] != '0':
    # The process failed
    # The formatObject API "pretty" prints the marshalled result in a 
formatted manner
    print 'Process failed since returned non-zero RC: %s\n%s' % 
(processMap['rc'], formatObject(result.resultContext))
    sys.exit(1)

# You can use the formatObject API to "pretty" print the marshalling 
context for the result in a formatted manner
print '\nResult:\n%s' % (formatObject(result.resultContext))

# The process's stdout/stderr is provided in the fileList field in the 
result object. 
# The value for 'fileList' is a list of the returned files where each 
entry in the list consists of a map that contains keys 'rc' and 'data'.
# In this PROCESS START request, we returned one file, stdout, and 
returned stderr to this same file.
# Note that the STAF User's Guide defines the result for each request 
submitted to an internal STAF service.

print 'java -version: %s' % (processMap['fileList'][0]['data'])

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




blbmdsm...@verizon.net 
07/20/2010 11:12 AM

To
Sharon Lucas/Austin/i...@ibmus
cc

Subject
Re: Re: [staf-users] Question about trust level settings between machines 
and running PROCESS







Sharon,

You are wonderful.  I thought it might be something simple.  I can now run 
my command and get the result.results. 

Question:  Now that I can run the command successfully I see result.result 
has what I expected at the end of the output.
                My question, how do I get everything from "java -version" 
to the end of result.result and not all the characters before "java 
-version"?

For example in my Python debugger I have the following:

(Pdb) print result.result

@SDT/*:893:@SDT/{:587::13:map-class-...@sdt/{:559::35:STAF/Service/Process/completioni...@sdt/{:261::4:k...@sdt/[3:189:@SDT/{:56::12:display-n...@sdt/$S:11:Return
 
Code:3:k...@sdt/$S:2:r...@sdt/{:48::12:display-n...@sdt/$S:3:Key:3:k...@sdt/$S:3:k...@sdt/{:55::12:display-n...@sdt/$S:5:Files:3:k...@sdt/$S:8:fileList:4:n...@sdt/$S:35:STAF/Service/Process/CompletionInfo:35:STAF/Service/Process/returnfilei...@sdt/{:198::4:k...@sdt/[2:126:@SDT/{:56::12:display-n...@sdt/$S:11:Return
 
Code:3:k...@sdt/$S:2:r...@sdt/{:50::12:display-n...@sdt/$S:4:Data:3:k...@sdt/$S:4:data:4:n...@sdt/$S:35:STAF/Service/Process/returnfilei...@sdt/%:284::35:STAF/Service/Process/completioni...@sdt/$S:1:0...@sdt/$0:0:@SDT/[1:212:@SDT/%:201::35:STAF/Service/Process/returnfilei...@sdt/$S:1:0...@sdt/$S:139:java
 
version "1.6.0_0"

OpenJDK Runtime Environment (IcedTea6 1.6) (fedora-30.b16.fc11-i386)
OpenJDK Server VM (build 14.0-b16, mixed mode)


I believe it has something to do with marshalling structured data, but I 
have not read enough of the users guide to know how I would remove all the 
extra stuff before the "java version" output from result.result.

Any help would be appreciated.  Probably something easy like the above 
trust configuration issue.

Many thanks,

Regards,
Bill
Jul 20, 2010 10:47:18 AM, luc...@us.ibm.com wrote:
> 
>You didn't give trust level 5 to machine 10.11.29.117 on bbox. 
> 
>Instead, you set trust level 5 for machine 10.11.29.117.* on bbox. 
> The ip address of 10.11.29.117 does not matach 10.11.29.117.* (as it 
doesn't 
>have a . after the 117). 
>You should set trust level 5 for 10.11.29.117 (not 10.11.29.117.*) on 
>bbox. For example: 
> 
>STAF local TRUST SET MACHINE 10.11.29.117 LEVEL 5 
> 
>or if setting in the STAF.cfg file: 
> 
>trust machine 10.11.29.117 level 5 
> 
>Or, if you want to give trust level 5 to all IP addresses that begin 
>with 10.11.29, you could use the wildcard and specfiy 10.11.29.* (and 
that 
>would include 10.11.29.117). 
> 
>You are using machine trust, not user trust, so the default user of 
>none://anonymous is fine. 
> 
>Note that you can check the trust level another machine gives you by 
>submitting a WHOAMI request to the MISC service on the machine. For 
example, 
>if you submitted the following request from machine bxx to machine bbox, 
then the 
>result would include the trust level that machine bbox really gives 
machine bxx: 
> 
>[r...@bxx staf]# STAF bbox MISC WHOAMI 
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin, luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
> 
> 
> 
> 
blbmdsm...@verizon.net 
07/20/2010 09:14 AM 


To
staf-users@lists.sourceforge.net 
cc

Subject
[staf-users] Question about trust level settings 
>between machines and running PROCESS

> 




>

> 
> 
>Hello,
> 
> I am trying to run a remote process between to machines. I have checked 
the 
>STAF Users Guide. I have setup both machines to have a trust level of 5 
between 
>the two machines.
> 
> #######
> First machine: bxx...ip 10.11.29.117
> 
> [r...@bxx ~]# staf local trust list
> Response
> --------
> Type Entry Trust Level
> ------- ----------------- -----------
> Default 2 
> 
> Machine *://10.11.31.38.* 5 
> Machine local://local 5 
> 
> ########
> Second machine: bbox...ip 10.11.31.38
> 
> [r...@bbox staf]# staf local trust list
> Response
> --------
> Type Entry Trust Level
> ------- ------------------ -----------
> Default 3 
> 
> Machine *://10.11.29.117.* 5 
> Machine local://local 5 
> 
> 
> I am seeing that both boxes have a trust level of 5 for each other 
above.
> I then run "process start shell" from bxx to bbox. I am getting 
>the following error:
> 
> [r...@bxx staf]# staf bbox process start shell command "java -vesion" 
> Error submitting request, RC: 25
> Additional info
> ---------------
> Trust level 5 required for the PROCESS service's START request
> Requester has trust level 3 on machine bbox
> Requesting machine: tcp://bsmith (tcp://10.11.29.117)
> Requesting user : none://anonymous
> 
> What have I missed in the trust level configuation? Why is the request 
being 
>denied with "Requesting user : none://anonymous"? 
> Do I need to setup user anonymous with a trust level of 5 or would this 
be 
>a security issue?
> 
> Regards,
> Bill
------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- 
>class="parsedLink" target="_blank">
http://p.sf.net/sfu/sprint-com-first_______________________________________________

> staf-users mailing list
> staf-users@lists.sourceforge.net
> 
>target="_blank">https://lists.sourceforge.net/lists/listinfo/staf-users
> 
> 
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to