Skip to content

Instantly share code, notes, and snippets.

@sehugg
Last active May 20, 2016 23:36
Show Gist options
  • Save sehugg/6098ccfb5a0bee897f41147ceee7016f to your computer and use it in GitHub Desktop.
Save sehugg/6098ccfb5a0bee897f41147ceee7016f to your computer and use it in GitHub Desktop.
Random MAME launcher script for RetroPie
#!/usr/bin/python
import random, subprocess, time, sys, os, os.path
roms = os.listdir(os.path.expanduser('~/RetroPie/roms/mame-mame4all/'))
roms = [x.split('.')[0] for x in roms]
random.shuffle(roms)
MAME4ALL = '/opt/retropie/emulators/mame4all/mame'
for rom in roms:
print(rom)
p = subprocess.Popen([MAME4ALL, rom])
time.sleep(2)
code = p.poll()
if code is None:
time.sleep(120)
try:
p.kill()
p.wait()
except KeyboardInterrupt:
raise
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment