I got RC6 portable. I haven't done that for such long that I'm not sure whether I've missed any stepsteve wrote: ↑Thu Mar 04, 2021 12:42 amIf you feel comfortable doing so, there's a "release candidate" for Audacity 3.0.0 available for testing. See: viewtopic.php?f=49&t=116221
I enabled mod-script-pipe, restarted and double checked enabled. When I ran my script I got nothing returned:
Code: Select all
PS E:\work\python\Audacity> python .\pipe_utf-8.py
pipe-test.py, running on windows
Write to "\\.\pipe\ToSrvPipe"
Read from "\\.\pipe\FromSrvPipe"
-- Both pipes exist. Good.
-- File to write to has been opened
-- File to read from has now been opened too
Send: >>>
GetInfo: Type=Labels Format=JSON"
I read line:[
]
Rcvd: <<<
Code: Select all
PS E:\work\python\Audacity> python .\pipe_utf-8.py
pipe-test.py, running on windows
Write to "\\.\pipe\ToSrvPipe"
Read from "\\.\pipe\FromSrvPipe"
-- Both pipes exist. Good.
-- File to write to has been opened
-- File to read from has now been opened too
Send: >>>
GetInfo: Type=Labels Format=JSON"
I read line:[[
]
I read line:[ [ 0,
]
I read line:[ [
]
I read line:[ [ 0, 0, "Hello" ] ] ] ]
]
I read line:[BatchCommand finished: OK
]
I read line:[
]
Rcvd: <<<
[
[ 0,
[
[ 0, 0, "Hello" ] ] ] ]
BatchCommand finished: OK
The script:
Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import os
import sys
if sys.platform == 'win32':
print("pipe-test.py, running on windows")
TONAME = '\\\\.\\pipe\\ToSrvPipe'
FROMNAME = '\\\\.\\pipe\\FromSrvPipe'
EOL = '\r\n\0'
else:
print("pipe-test.py, running on linux or mac")
TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid())
FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid())
EOL = '\n'
print("Write to \"" + TONAME +"\"")
if not os.path.exists(TONAME):
print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.")
sys.exit()
print("Read from \"" + FROMNAME +"\"")
if not os.path.exists(FROMNAME):
print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.")
sys.exit()
print("-- Both pipes exist. Good.")
TOFILE = open(TONAME, 'w')
print("-- File to write to has been opened")
#FROMFILE = open(FROMNAME, 'rt')
FROMFILE = io.open( FROMNAME,'r', encoding='utf8', newline='\n')
print("-- File to read from has now been opened too\r\n")
def send_command(command):
"""Send a single command."""
print("Send: >>> \n"+command)
TOFILE.write(command + EOL)
TOFILE.flush()
def get_response():
"""Return the command response."""
result = ''
line = ''
while line != '\n':
result += line
line = FROMFILE.readline()
print(" I read line:["+line+"]")
return result
def do_command(command):
"""Send one command, and return the response."""
send_command(command)
response = get_response()
print("Rcvd: <<< \n" + response)
return response
def quick_test():
"""Example list of commands."""
# do_command('Help: Command=Help')
# do_command('Help: Command="GetInfo"')
do_command('GetInfo: Type=Labels Format=JSON"')
#do_command('SetPreference: Name=GUI/Theme Value=classic Reload=1')
quick_test()