os.execv or os.spawnv doesn't work in scripts
#1
hello,
I'm trying to improve emuLauncher script so it could be used under windows platform to run an emulator's roms.

all I did is to replace those lines :
Code:
SHORTCUT = HOME_DIR + CUT_FILE
            f=open(SHORTCUT, "wb")
            f.write("<shortcut>\n")
            f.write("    <path>" + self.emupath[self.index] + "</path>\n")
            f.write("    <custom>\n")
            f.write("       <game>" + title + '.' + self.romext[self.index] + "</game>\n")
            f.write("    </custom>\n")
            f.write("</shortcut>\n")
            f.close()
            xbmc.executebuiltin('XBMC.Runxbe(' + SHORTCUT + ')')
with those lines:
Code:
if sys.platform == 'win32':
            print "launching..." + self.emupath[self.index] + " " + title + '.' + self.romext[self.index]
            os.spawnv(self.emupath[self.index], [self.emupath[self.index], title + '.' + self.romext[self.index]])
            print "ended"
        else:
            SHORTCUT = HOME_DIR + CUT_FILE
            f=open(SHORTCUT, "wb")
            f.write("<shortcut>\n")
            f.write("    <path>" + self.emupath[self.index] + "</path>\n")
            f.write("    <custom>\n")
            f.write("       <game>" + title + '.' + self.romext[self.index] + "</game>\n")
            f.write("    </custom>\n")
            f.write("</shortcut>\n")
            f.close()
            xbmc.executebuiltin('XBMC.Runxbe(' + SHORTCUT + ')')
unfortunately the xbmc does nothing when reached to os.spawnv line.
the log output :
Code:
12:22:21 T:3440 M:1098502144    INFO: launching...D:\Games\Mame\ZetaMAME32\ZetaMAME32en.exe D:\Games\Mame\Roms\amidar.zip
12:22:21 T:3440 M:1098502144    INFO:
and nothing more. (the "ended" line is never reached)
I also tried it with os.execv function, but nothing works.
the os.spanv command works good on python console.

I would be happy to get some help with this...
thanks,
leo
Reply
#2
found some solution:
i replaced: os.spawnv command with:
Code:
xbmc.executebuiltin( "System.Exec("+self.emupath[self.index]+" "+ title + '.' + self.romext[self.index]+")" )

and it works. (but opens an ugly cmd window in the background)

does anyone know why the os.spawnv command doesn't work?
is it a real python interpreter inside xbmc?
Reply
#3
take a look at subprocess instead, imo much better.

http://docs.python.org/lib/module-subprocess.html
Reply
#4
Thanks Blittan Smile

Unfortunately that doesn't work in xbmc either.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
Nuka1195 Wrote:Thanks Blittan Smile

Unfortunately that doesn't work in xbmc either.

why doesn't xbmc allow all of the python calls?
Reply
#6
it works on linux .. atleast the quick tests i done Smile
Reply
#7
not sure if it will help but ajje got it working under Linux, how-to instructions are here => http://forum.xbmc.org/showthread.php?tid=30659

Eek
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#8
Gamester17 Wrote:not sure if it will help but ajje got it working under Linux, how-to instructions are here => http://forum.xbmc.org/showthread.php?tid=30659

Eek

doesn't work under windows.
i'm staying with the System.Exec command.
Reply

Logout Mark Read Team Forum Stats Members Help
os.execv or os.spawnv doesn't work in scripts0