mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
mod-script-pipe python scripts working on linux too.
- Pipe names are different on Linux. - End of line is different on linux. - The pipe must be opened with 'w+' not just 'w'.
This commit is contained in:
parent
8e0cffb7f2
commit
ce697d052a
@ -1,16 +1,46 @@
|
||||
# get-gui-structure.py
|
||||
# Obtains all menus and all box locations from the currently running Audacity.
|
||||
# This is useful for wit.audacityteam.org, where we need these lists when we
|
||||
# draw the menus and create the image maps.
|
||||
|
||||
# Make sure Audacity is running first and that mod-script-pipe is enabled
|
||||
# before running this script.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
toname = '\\\\.\\pipe\\ToSrvPipe'
|
||||
fromname = '\\\\.\\pipe\\FromSrvPipe'
|
||||
if( sys.platform == 'win32' ):
|
||||
print( "get-gui-structure.py, running on windows" )
|
||||
toname = '\\\\.\\pipe\\ToSrvPipe'
|
||||
fromname = '\\\\.\\pipe\\FromSrvPipe'
|
||||
EOL = '\r\n\0'
|
||||
else:
|
||||
print( "get-gui-structure.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'
|
||||
|
||||
tofile = open( toname, 'wt' )
|
||||
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, 'wt+' )
|
||||
print( "-- File to write to has been opened" )
|
||||
fromfile = open( fromname, 'rt')
|
||||
print( "-- File to read from has now been opened too\r\n" )
|
||||
|
||||
def sendCommand( command ) :
|
||||
print( "Send: "+command )
|
||||
tofile.write( command + '\r\n\0' )
|
||||
print( "Send: >>> "+command )
|
||||
tofile.write( command + EOL )
|
||||
tofile.flush()
|
||||
|
||||
def getResponse() :
|
||||
@ -24,15 +54,19 @@ def getResponse() :
|
||||
def doCommand( command ) :
|
||||
sendCommand( command )
|
||||
response = getResponse()
|
||||
print( "Rcvd: " + response )
|
||||
print( "Rcvd: <<< " + response )
|
||||
return response
|
||||
|
||||
def do( command ) :
|
||||
doCommand( command )
|
||||
|
||||
|
||||
def getStructure() :
|
||||
#do( 'Help: CommandName=Help' )
|
||||
#do( 'Help: CommandName=SetPreference' )
|
||||
#do( 'SetPreference: PrefName=GUI/Theme PrefValue=light' )
|
||||
#do( 'Screenshot: CaptureMode=menus' )
|
||||
do( 'GetBoxes' )
|
||||
#doCommand( 'Screenshot: CaptureMode=menus' )
|
||||
do( 'GetMenusPlus' )
|
||||
|
||||
getStructure()
|
||||
|
@ -4,16 +4,45 @@
|
||||
# You can make more complicated longer tests to test other functionality
|
||||
# or to generate screenshots etc in other scripts.
|
||||
|
||||
# Make sure Audacity is running first and that mod-script-pipe is enabled
|
||||
# before running this script.
|
||||
|
||||
toname = '\\\\.\\pipe\\ToSrvPipe'
|
||||
fromname = '\\\\.\\pipe\\FromSrvPipe'
|
||||
import os
|
||||
import sys
|
||||
|
||||
tofile = open( toname, 'wt' )
|
||||
|
||||
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, 'wt+' )
|
||||
print( "-- File to write to has been opened" )
|
||||
fromfile = open( fromname, 'rt')
|
||||
print( "-- File to read from has now been opened too\r\n" )
|
||||
|
||||
|
||||
def sendCommand( command ) :
|
||||
print( "Send: "+command )
|
||||
tofile.write( command + '\r\n\0' )
|
||||
print( "Send: >>> "+command )
|
||||
tofile.write( command + EOL )
|
||||
tofile.flush()
|
||||
|
||||
def getResponse() :
|
||||
@ -22,18 +51,21 @@ def getResponse() :
|
||||
while line != '\n' :
|
||||
result += line
|
||||
line = fromfile.readline()
|
||||
#print(" I read line:["+line+"]")
|
||||
return result
|
||||
|
||||
def doCommand( command ) :
|
||||
sendCommand( command )
|
||||
response = getResponse()
|
||||
print( "Rcvd: " + response )
|
||||
print( "Rcvd: <<< " + response )
|
||||
return response
|
||||
|
||||
def quickTest() :
|
||||
doCommand( 'Help: CommandName=Help' )
|
||||
doCommand( 'Help: CommandName=SetPreference' )
|
||||
doCommand( 'SetPreference: PrefName=GUI/Theme PrefValue=light' )
|
||||
def do( command ) :
|
||||
doCommand( command )
|
||||
|
||||
def quickTest() :
|
||||
do( 'Help: CommandName=Help' )
|
||||
do( 'Help: CommandName=SetPreference' )
|
||||
do( 'SetPreference: PrefName=GUI/Theme PrefValue=light' )
|
||||
|
||||
quickTest()
|
||||
|
Loading…
x
Reference in New Issue
Block a user