OSError when running os.popen - only when run in xbmc
#1
Hello,

I get a very strange error while running in xbmc. When run from terminal it works fine. Is it a conflict with xbmc or is just becuase xbmc runs a different version of python? I guess I have to check if I can force a lower version when testing in terminal like in java.

I am a bit confused since I see that popen is the old way of doing it. Perhaps not old enough for xbmc?

Code:
09:45:44 T:2945805168 M:1041702912  NOTICE: TESTTEST= os.popen("dpkg -l")
09:45:44 T:2945805168 M:1041702912  NOTICE: OSError
09:45:44 T:2945805168 M:1041702912  NOTICE: :
09:45:44 T:2945805168 M:1041702912  NOTICE: (0, 'Error')
Reply
#2
try:

Code:
from popen2 import Popen3
TESTTEST= Popen3("dpkg -l")

dont ask me why os.popen() doesnt work Smile


Cheers,
amet
Reply
#3
Thank you. It works, although I now get an DeprecationWarning when running from terminal. I will re-visit this later and perhaps use the method from the bootable wizard.


Quote:def check_installed():
from popen2 import Popen3

(stdin, stdout, stderr) = os.popen3("dpkg -l")#, mode, bufsize)
s = stdout.read()

if s.find("wicd-curses") == -1:
return False
else:
return True
Reply
#4
I know its a bit hacky, but it should work.

NOTE: Untested!!

Code:
def check_installed():
  from popen2 import Popen3
  try:
    import xbmc
    running_xbmc = True
  except:
    running_xbmc = False

  if running_xbmc:
    (stdin, stdout, stderr) = os.popen3("dpkg -l")#, mode, bufsize)
    s = stdout.read()
  else:
    s = os.popen("dpkg -l").read()

  if s.find("wicd-curses") == -1:
    return False
  else:
    return True
Reply
#5
Ok, that is interesting. I was intending to find out if I could force ubuntu-python to run as the same level as xbmc-python. For testing this would be great. In java this is possible.

To create a multipurpose module an alternative to your code could be to just pass python version or some other signal as a paremter when calling from xbmc gui.
Reply
#6
I cant check the external python so I cant comment on it, but I dont think its the 2.4 python issue.

you could just query the python version and if > 2.4 assume its not in XBMC and that it would work

Cheers,
amet
Reply
#7
Thank you. For the moment I have what I need.
Already found next problem though...dbus does not seem to exist in xbmc python....
Reply
#8
Amet Wrote:try:

Code:
from popen2 import Popen3
TESTTEST= Popen3("dpkg -l")

dont ask me why os.popen() doesnt work Smile


Cheers,
amet
I think that's an xbox remnant, we define that function internally somewhere.
Reply

Logout Mark Read Team Forum Stats Members Help
OSError when running os.popen - only when run in xbmc0