SKCore,SKTestSupport: adjust test server handling

The test system depended on the shebang to locate the python
interpreter.  However, this is not a portable system.  Instead, prefer
to explicitly search for the interpreter prior to the execution.  This
enables supporting execution of the script support on all platforms. A
secondary change of the printed string is required for Windows. Python
will replace `\n` with `\r\n` resulting in `\r\n` being emitted as
`\r\r\n` on Windows breaking the expectations on the receiver.  Adjust
this by explicitly writing out a binary string to the raw underlying
buffer to avoid the translation.
This commit is contained in:
Saleem Abdulrasool
2022-07-17 20:18:46 -07:00
parent d4c6e2c0c6
commit 79105208d5
8 changed files with 43 additions and 26 deletions

View File

@@ -1,5 +1,3 @@
#!/usr/bin/env python3
import json
import os
import sys
@@ -8,7 +6,7 @@ import sys
def send(data):
dataStr = json.dumps(data)
try:
sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(dataStr), dataStr))
sys.stdout.buffer.write(f"Content-Length: {len(dataStr)}\r\n\r\n{dataStr}".encode('utf-8'))
sys.stdout.flush()
except IOError:
# stdout closed, time to quit