Unable to print the log in Robot Framework

Viewed 1217

I am calling python program in my robot framework and trying to get the output in the console. I tried a lot but could not solve this issue as i am new to Robot framework.

Issue: Print statement coded in python program is not reflecting in the log console .

My robot file contains the below lines of codes

*** Keywords ***
Run App1 Health Check
     [Documentation]    Runs App1 Health check
     ${result} =  Run Process  python  -c ./statuspgm.py app1 timeout=10s
     Log To Console  ${result.stdout}
     [Return]        Pass

Program: statuspgm.py

import string
import time
…
def RetrievePodsForStatus(pod_srch):
      out_list.append([i.name, i.status])
  print ("Starting the script execution….")
  print("Return value:", ret_val) 
  return out_list

..
# Main Area
arg1 = sys.argv[1]
print ("arg1:", arg1)
component_status = RetrievePodsForStatus(arg1)
print("Out:",component_status)

My robot output is:

KEYWORD ${result} = Process . Run Process python, -c /home/ubuntu/testpgm.py app1
Documentation:  
Runs a process and waits for it to complete.

Start / End / Elapsed:  20200914 20:01:50.327 / 20200914 20:01:50.356 / 00:00:00.029
20:01:50.327    INFO    Starting process:
python "-c /home/ubuntu/testpgm.py app1"    
20:01:50.332    INFO    Waiting for process to complete.    
20:01:50.356    INFO    Process completed.  
20:01:50.356    INFO    ${result} = <result object with rc 1>   
00:00:00.001KEYWORD BuiltIn . Log To Console ${result.stdout}
Documentation:  
Logs the given message to the console.

Start / End / Elapsed:  20200914 20:01:50.357 / 20200914 20:01:50.358 / 00:00:00.001
20:01:50.358    INFO    ${healthStatus} = Pass
1 Answers

Try:

${result} =  Run Process  python -c ./statuspgm.py app1 timeout=10s  shell=true

There was a double space between "python" and "-c". So delete one space and set the shell argument to True.

Related