Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Why does popen crash eventghost

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
jbworks
Posts: 3
Joined: Tue Sep 06, 2011 11:16 pm

Why does popen crash eventghost

Post by jbworks »

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
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Why does popen crash eventghost

Post by Pako »

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
jbworks
Posts: 3
Joined: Tue Sep 06, 2011 11:16 pm

Re: Why does popen crash eventghost

Post by jbworks »

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.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Why does popen crash eventghost

Post by Pako »

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
eatmeimadanish
Experienced User
Posts: 118
Joined: Thu Oct 01, 2009 5:11 pm

Re: Why does popen crash eventghost

Post by eatmeimadanish »

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.
Post Reply