From a084c3dbbf2df5cb3390937244e0394f86ed0137 Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 20 Dec 2017 16:36:40 +0000 Subject: [PATCH] pipetest.py to test mod-script-pipe's pipe. First version in python (we used to use perl). --- scripts/pipetest.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scripts/pipetest.py diff --git a/scripts/pipetest.py b/scripts/pipetest.py new file mode 100644 index 000000000..6da4cf655 --- /dev/null +++ b/scripts/pipetest.py @@ -0,0 +1,39 @@ +# pipetest.py +# Tests the audacity pipe. Sends 3 commands. +# Keep pipetest.py short!! +# You can make more complicated longer tests to test other functionality +# or to generate screenshots etc in other scripts. + + +toname = '\\\\.\\pipe\\ToSrvPipe' +fromname = '\\\\.\\pipe\\FromSrvPipe' + +tofile = open( toname, 'wt' ) +fromfile = open( fromname, 'rt') + +def sendCommand( command ) : + print( "Send: "+command ) + tofile.write( command + '\r\n\0' ) + tofile.flush() + +def getResponse() : + result = '' + line = '' + while line != '\n' : + result += line + line = fromfile.readline() + return result + +def doCommand( command ) : + sendCommand( command ) + response = getResponse() + print( "Rcvd: " + response ) + return response + +def quickTest() : + doCommand( 'Help: CommandName=Help' ) + doCommand( 'Help: CommandName=SetPreference' ) + doCommand( 'SetPreference: PrefName=GUI/Theme PrefValue=light' ) + + +quickTest()