Runcommand usage from python script not working
-
Hello, noobie here.
Im trying to use runcommand to start snes game from python script on rapsbian. I am using popen for it with no luck. When i use popen for dosbox it opens new terminal window and starts the game given from argument. When i hry to start runcommand no error is given but nothing happens.
Can anyone give advise or post working code example.
-
I think it's you that has to show some code here to show how are you calling
runcommand
. Paste the relevant code in code blocks and some context of how you call the python script. -
Sorry...
heres my code... Iam building custom GUI with tkinter. However this is my whole code for testing in single test.py file, and does nothing when run via IDE nor via terminal python test.py. When I run the cmd itself from terminal it starts the game. If I run it from test.py it does nothing at all, but doesnt even throw exception or nothing.
cmd = "/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ snes '/home/pi/RetroPie/roms/snes/Super_Mario.smc'" process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) outout, error = process.communicate() while 1: print(output) print(error)
prints looks as:
b''
None- when I enter wrong path to rom it gives no such file found error, so it does something :)
ive tryed with shell=True and many other options. this is just my last one
-
Hm, one thing that I notice is that
split
doesn't un-quote the last parameter (the ROM path) and the path still contains'
. Plus, if the ROM path contains spaces, thensplit
will mess it up. Here's an example using the ROM name "True Lies (USA).zip"Parameters: Executing: /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-snes9x2010/snes9x2010_libretro.so --config /opt/retropie/configs/snes/retroarch.cfg "'/home/pi/RetroPie/roms/snes/True" --appendconfig /dev/shm/retroarch.cfg Failed to open '/home/pi/RetroPie/roms/snes/True: No such file or directory
I think you should manually create the 1st argument to Popen and not rely on
split
to generate a correct list of arguments. -
I would suggest
p = subprocess.Popen(['/opt/retropie/supplementary/runcommand/runcommand.sh','0', '_SYS_', 'snes', '/home/pi/RetroPie/roms/snes/Super_Mario.smc'])
-
@cyperghost said in Runcommand usage from python script not working:
p = subprocess.Popen(['/opt/retropie/supplementary/runcommand/runcommand.sh','0', 'SYS', 'snes', '/home/pi/RetroPie/roms/snes/Super_Mario.smc'])
I've tried that. Does the same thing but the prints changed to:
None
None
... -
@mesym Well I don't know what's wrong but this worked for me. It starts Tetris and shows me pointer adress. Something wrong with your py-fu?
import os import time import subprocess p = subprocess.Popen(['/opt/retropie/supplementary/runcommand/runcommand.sh','0', '_SYS_', 'gb', '/home/pi/RetroPie/roms/gb/Tetris (JUE) (V1.0) [!].gb']) while 1: print(p) time.sleep(5)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.