Python scripting not returning a response

Hi there,

We recently upgraded our DF instance to 2.1.2 in order to use the Python custom scripting feature. When trying to run the example “Math” custom scripting service, no content is sent in the response. When I set the log level to DEBUG, I get the following output in the logs when I call the custom script using a GET request at /api/v2/math/add?n1=4&n2=5:

{'resource': 'add', 'script_result': {'result': 9.0}, '__tag__': 'exposed_event', 'request': {'parameters': {'n1': '4', 'n2': '5'}, 'payload': [], 'content': '', 'headers': {'postman-token': ['redacted'], 'content-length': ['0'], 'accept-language': ['en-US'], 'accept-encoding': ['gzip, deflate'], 'cache-control': ['no-cache'], 'x-dreamfactory-api-key': ['redacted'], 'content-type': [''], 'host': ['redacted'], 'accept': ['*/*'], 'user-agent': ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Postman/4.1.1 Chrome/47.0.2526.73 Electron/0.36.2 Safari/537.36']}, 'content_type': None, 'method': 'GET', 'api_version': '2.0'}, 'response': {'content': None, 'status_code': 200, 'content_type': None}}

In the output, I can see the “script_result” is what I wanted, which leads me to believe that DF is passing the script to Python correctly. However, the “response”: “content” is set to none, which is what’s confusing me; I have no idea why that is.

Not sure if this is related, but the following errors are generated from the admin web-interface for our DF instance:

* System error building event map for service 'system'.
Service configuration class name lookup failed for resource DreamFactory\Core\Resources\System\Setting
* System error creating swagger file for service 'system'.
Service configuration class name lookup failed for resource DreamFactory\Core\Resources\System\Setting

I’ve included our DF details below. Any help would really be appreciated! Thank you!


DreamFactory Instance
Admin Application Version: 2.1.6
DreamFactory Version: 2.1.2
System Database: mysql

Server
Operating System: linux
Release: 3.10.0-327.13.1.el7.x86_64
Version: #1 SMP Mon Feb 29 13:22:02 EST 2016
Machine: x86_64

we’re taking a look. will post soon.

Python scripting in 2.1.2 is currently in beta and unfortunately there is a bug that blocks the response. We have already addressed this issue and the fix will be available in the next release. However, if you really need to get this going before the next release comes out then feel free to make this small modification and it should work for you.

Edit file vendor/dreamfactory/df-core/src/Scripting/Engines/Python.php and drop the following code before the closing curly braces ( } ) near the end of this file.

/** @inheritdoc */ protected function checkOutputStringForData($output) { return ((strlen($output) > 10) && (false !== strpos($output, 'request'))); } </code
1 Like

Thanks, looks like that fixed what I was trying to do. I appreciate the help!