cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

MKS command automation Python

SOLVED
Highlighted
Newbie

MKS command automation Python

Hi,

I am trying to automate MKS commands using python. Please help me to capture the error message.

Example:

import subprocess

import time

viewproject_cmd='im issues'
proc = subprocess.Popen(viewproject_cmd,stdout=subprocess.PIPE,shell=True)

(out, err) = proc.communicate()

The above script is throwing me following error,

*** MKS124814: Cannot show view information: MKS124808: This command requires operands: item id

I am unable to capture the above error in any variable. Also I see this error only if I execute the above python script in the cmd.exe

Please help me to handle the above error in python script itself.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: MKS command automation Python

I have got the answer to my question, The below code returns error message if there is any error on execution of si command

import subprocess

viewproject_cmd='im issues'
process = subprocess.Popen(viewproject_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

(out, err) = process.communicate()

print '!!!!ERROR:',err

View solution in original post

4 REPLIES 4
Highlighted

Re: MKS command automation Python

I dont know nothing about python but the command line perspective 2 informations may help you.

1.)

The error text is output to stderr. To capture it you could do something like

    im issues 2> err.txt

2.)

the error code may be visible in the environment variable %errorlevel% after the command has finished

    echo %errorlevel%

Regards

     Juergen

Highlighted

Re: MKS command automation Python

Thanks Juergen,

Highlighted

Re: MKS command automation Python

I have got the answer to my question, The below code returns error message if there is any error on execution of si command

import subprocess

viewproject_cmd='im issues'
process = subprocess.Popen(viewproject_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

(out, err) = process.communicate()

print '!!!!ERROR:',err

View solution in original post

Highlighted

Re: MKS command automation Python

Hi,

Can you please tell me from where I can get the list of Python APIs for MKS?

Announcements