Why does popen crash eventghost

Do you have questions about writing plugins or scripts in Python? Meet the coders here.

Why does popen crash eventghost

Postby jbworks » Tue Nov 29, 2011 5:15 pm

First off, I know nothing about python, so please accept my apologies if this is a stupid question, but I am a bit stumped.

What is wrong with this code?
Code: Select all
import os
os.system("taskkill /im squeezeplay.exe /f")
os.popen('"C:\Program Files\Squeezebox\SqueezePlay\squeezeplay.exe"')


EventGhost locks up as soon as popen is run. The script works but it crashes eventghost
jbworks
 
Posts: 3
Joined: Tue Sep 06, 2011 11:16 pm

Re: Why does popen crash eventghost

Postby Pako » Wed Nov 30, 2011 5:52 pm

I do not know what it is squeezeplay.exe.
However, I see a bug.
Maybe that way it could work:
Code: Select all
import os
os.system("taskkill /im squeezeplay.exe /f")
os.popen("C:\Program Files\Squeezebox\SqueezePlay\squeezeplay.exe")
Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Why does popen crash eventghost

Postby jbworks » Fri Dec 02, 2011 12:50 am

Unless I'm mistaken I have to use the single quote because the path name has a space in it. Without the quote yields the path not being found.
jbworks
 
Posts: 3
Joined: Tue Sep 06, 2011 11:16 pm

Re: Why does popen crash eventghost

Postby Pako » Fri Dec 02, 2011 6:37 am

jbworks wrote:Without the quote yields the path not being found.
Yes, of course. That I should have known. I'm sorry.
But it might help to use eg.plugins.System.Execute:
Code: Select all
import os
os.system("taskkill /im squeezeplay.exe /f")
eg.plugins.System.Execute(u'C:\\Program Files\\Squeezebox\\SqueezePlay\\squeezeplay.exe', u'', 0, False, 2, u'', False)
Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Why does popen crash eventghost

Postby eatmeimadanish » Mon Jan 23, 2012 10:10 pm

Do not use os, instead use
import subprocess
subprocess.popen ("taskkill /im squeezeplay.exe /f")

But I agree with Pako, use the eg.plugins.system.execute. To make it easy, just configure the "Start Application" action and cut n paste it into your code, and remove the XML tags and data.
eatmeimadanish
Experienced User
 
Posts: 96
Joined: Thu Oct 01, 2009 5:11 pm


Return to Coding Corner

Who is online

Users browsing this forum: No registered users and 1 guest