db9_gpio_rpi driver script
-
Hi there,
im working on my retropie right now. I installed the db9_gpio_rpi driver for SEGA genesis gamepads an it is working no problem what so ever.
Im writing my script for a driverchange right now and in this script i want to unload the driver.
from the documentation: "sudo modprobe --first-time -r db9_gpio_rpi" unloads the driver.this is working in the command line. No problem what so ever.
But the same line in the python script without sudo (running the script with "sudo python driverchange.py") gives me a SyntaxError: invalid syntax...def unloaddriver(channel):
print('unloaddriver')
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]for pid in pids: try: commandpath = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read() # if commandpath[0:24] == '/opt/retropie/supplementary/emulationstation': # unload db9_gpio_rpi driver (SEGA, ATARI) modprobe --first-time -r db9_gpio_rpi print('unloaded db9_gpio_rpi')
somebody any hint how to fix that? What am I doing wrong?
-
@Jeddo python isn't bash; you can't just use the same commands you'd use at the bash shell.
This URL has a few examples of how to call external programs (i.e., modprobe) from python
http://stackoverflow.com/questions/89228/calling-an-external-command-in-python
-
Ah ok thank you. So basicly i neet to change the command to
subprocess.call("modprobe --first-time -r db9_gpio_rpi", shell=True)
and import the subprocess?!
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.