Using Python 3.12.3 on Ubuntu 24.04
I've converted a legacy python2 script to python3. All went well.
However, a glitch from python2 remains.
The script uses dmenu to create menus to pick applications. Applications
are then invoked from python
using subprocess.Popen(). I have never been able to successfully launch audacity using this approach,
which does work for other apps.
I can launch audacity successfully using dmenu_run (on its own, outside
of the script)
Below is the pertinent code:
Popen(choice, stdout=PIPE, stderr=PIPE,
stdin=PIPE, close_fds=True)
My guess is my argument list is either insufficient or an argument is
causing the problem, but am unsure of which.
I have been retired from python programming for ten years, and am pretty rusty, but it is still fun. There are plenty
of other ways to successfully launch audacity but it would be great to
make it work from this script.
using subprocess.Popen(). I have never been able to successfully launch audacity using this approach,
On 1/10/25 11:32, MRAB via Python-list wrote:
,,, snipped
Below is the pertinent code:
Popen(choice, stdout=PIPE, stderr=PIPE,
stdin=PIPE, close_fds=True)
My guess is my argument list is either insufficient or an argument is
causing the problem, but am unsure of which.
I have been retired from python programming for ten years, and am pretty >>> rusty, but it is still fun. There are plenty
of other ways to successfully launch audacity but it would be great to
make it work from this script.
What is the value of 'choice'?
You could try printing out the value of 'choice' for one that works
and the one that doesn't and then try them again interactively from
the Python prompt with the given values. That should eliminate all but
the essential code for easier debugging.
choice is /usr/local/bin/audacity, which is the correct path for
audacity on my system. As far as I can see, that string has no hidden
bytes.
Invoking /usr/local/bin/audacity from the command line launches audacity
and so does choosing with dmenu_run. which -a audacity shows only that item.
Maybe I need to isolate the function call and start stripping out
parameters. I should have time to do that later today.
from subprocess import run
run('/usr/bin/audacity')
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 453 |
Nodes: | 16 (2 / 14) |
Uptime: | 28:39:04 |
Calls: | 9,282 |
Calls today: | 2 |
Files: | 13,515 |
Messages: | 6,072,759 |