Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect python code crash problem - fixed in cutting edge release #606

Closed
muratcim opened this issue Oct 31, 2019 · 6 comments
Closed
Labels

Comments

@muratcim
Copy link

muratcim commented Oct 31, 2019

Hi Ken

Application be locked when there is an error in a Python block.

py begin
a= 4/0
py finish

Is there a method of terminating when an error is thrown with a python block?

I'm applying a method like this for

py begin
import traceback
try:
    print(4/0)
except Exception:
    print('PYTHON ERROR ' + traceback.format_exc())
py finish


if ( py_result.indexOf('ERROR') !=  -1 )
{
  js begin
  	throw new Error(py_result)
  js finish
  
}

echo 'anything'
@kensoh
Copy link
Member

kensoh commented Oct 31, 2019

Hi Murat, I'm afraid not. The assumption is valid Python code is sent to the Python integration.

If you really want to explore this, you can try modifying tagui\src\tagui_py\tagui_py.py file. Inside there is this line exec(params,globals()) which executed the Python instruction sent from TagUI. You can try modifying to catch exception and return some error message.

@kensoh kensoh changed the title Incorrect python code crash problem Incorrect python code crash problem - assumption is valid code is sent Oct 31, 2019
@kensoh kensoh added the query label Oct 31, 2019
@muratcim
Copy link
Author

muratcim commented Nov 1, 2019

Thank you Ken
I'll examine and try to find a solution.Closing issue
when i find a solution i will be sharing here

@muratcim muratcim closed this as completed Nov 1, 2019
@kensoh
Copy link
Member

kensoh commented Nov 2, 2019

Ok Murat, I will also see if there is something that can be changed in below file which can be committed to the codebase without affecting backward compatibility - tagui\src\tagui_py\tagui_py.py

@kensoh
Copy link
Member

kensoh commented Nov 2, 2019

Going to make a commit that works with Python 2 and 3, and also the following test -

script

py begin
a = 1
b = 2
print(a+b)
py finish
echo py_result

py begin
a = 1
b = 2
print(ava+b)
py finish
echo py_result

result

START - automation started - Sat Nov 02 2019 14:57:35 GMT+0800 (+08)

py a = 1
b = 2
print(a+b)
3
py a = 1
b = 2
print(ava+b)
name 'ava' is not defined

FINISH - automation finished - 0.5s

@kensoh kensoh reopened this Nov 2, 2019
kensoh added a commit to tebelorg/TagUI that referenced this issue Nov 2, 2019
see aisingapore#606 for more details. with this commit, when invalid Python code is called by user, TagUI continues operation and the error message is stored in py_result. before this change, TagUI hangs as the Python process does not return response.
kensoh added a commit that referenced this issue Nov 2, 2019
see #606 for more details. with this commit, when invalid Python code is called by user, TagUI continues operation and the error message is stored in py_result. before this change, TagUI hangs as the Python process does not return response.
@kensoh kensoh changed the title Incorrect python code crash problem - assumption is valid code is sent Incorrect python code crash problem - fixed in cutting edge release Nov 2, 2019
@kensoh
Copy link
Member

kensoh commented Nov 2, 2019

This is now available in the cutting edge release. With above commit, when invalid Python code is called by user, TagUI continues operation and the error message is stored in py_result. Before this change, TagUI hangs as the Python process does not return response. Works for Python 2 & 3 and the test case above.

Thanks Murat for raising this feedback! Running your example on a = 4/0 and echo py_result will now show 'integer division or modulo by zero' message, instead of hanging there.


https://github.com/kelaberetiv/TagUI#set-up

To try cutting edge version with the latest features, download master.zip to overwrite your existing packaged installation (be sure to manually select and move the folders & files inside master.zip's TagUI-master/src folder to replace your existing tagui/src folder, some OSes will delete existing target folders that are missing from source folder)

kensoh added a commit to tebelorg/TagUI that referenced this issue Nov 2, 2019
see aisingapore#606 for details. adding this to be consistent with TagUI error messages, and also have something meaningful for user to know if the execution of Python code runs into error.
kensoh added a commit that referenced this issue Nov 2, 2019
see #606 for details. adding this to be consistent with TagUI error messages, and also have something meaningful for user to know if the execution of Python code runs into error.
@kensoh
Copy link
Member

kensoh commented Nov 2, 2019

Adding a further commit so that when error happens running the Python code from user, there is an 'ERROR - ' in front of the error message. Without this, py_result is ambiguous.

This is both for consistency in TagUI error messages and also for user to be able to validate without ambiguity whether the response returned is due to error running the code.

Thus running py a = 4/0 will return py_result as ERROR - integer division or modulo by zero


Available in cutting edge version - https://github.com/kelaberetiv/TagUI#set-up

To try cutting edge version with the latest features, download master.zip to overwrite your existing packaged installation (be sure to manually select and move the folders & files inside master.zip's TagUI-master/src folder to replace your existing tagui/src folder, some OSes will delete existing target folders that are missing from source folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants