v18 [64-bit] subprocess.Popen raises error
#1
Hi!

I was testing my addon on the latest Kodi 18 alpha. It works with Kodi 32-bit, but I have a problem with 64-bit version when I want to run an external program using subprocess.Popen (tested on 64-bit Windows 8). In default.py file in the 35th line subprocess.Popen('ping google.com', shell=True, stdout=subprocess.PIPE) raises an error.

I have narrowed the code to the following small default.py:
Code:
# -*- coding: utf-8 -*-

import subprocess
import xbmc

if __name__ == '__main__':
    xbmc.log("----- Begin ----- ", level=xbmc.LOGERROR)
    result = subprocess.Popen('ping -n 3 google.com', shell=True, stdout=subprocess.PIPE).stdout.read()
    xbmc.log(str(result),          level=xbmc.LOGERROR)
    xbmc.log("------ End ------ ", level=xbmc.LOGERROR)

that raises this error when Kodi is run by a normal user:

Code:
EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: (13, 'Permission denied')
Traceback (most recent call last):
  File "C:\Users\iwis\AppData\Roaming\Kodi\addons\script.service.ping-addon\default.py", line 9, in <module>
    result = subprocess.Popen('ping -n 3 google.com', shell=True, stdout=subprocess.PIPE).stdout.read()
  File "C:\Program Files\Kodi\system\python\Lib\subprocess.py", line 420, in __init__
    self.stdout = os.fdopen(c2pread, 'rb', bufsize)
OSError: (13, 'Permission denied')
-->End of Python script error report<--

or this error when Kodi is run by an administrator:

Code:
EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: (2, 'No such file or directory')
Traceback (most recent call last):
  File "C:\Users\admin1\AppData\Roaming\Kodi\addons\script.service.ping-addon\default.py", line 9, in <module>
    result = subprocess.Popen('ping -n 3 google.com', shell=True, stdout=subprocess.PIPE).stdout.read()
  File "C:\Program Files\Kodi\system\python\Lib\subprocess.py", line 420, in __init__
    self.stdout = os.fdopen(c2pread, 'rb', bufsize)
OSError: (2, 'No such file or directory')
-->End of Python script error report<--

what is wrong with subprocess.Popen in 64-bit Kodi?

addon.xml:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.service.ping-addon" name="Ping addon" version="1.0.0" provider-name="iwis">
    <requires>
        <import addon="xbmc.python" version="2.25.0" />
    </requires>
    <extension point="xbmc.python.script" library="default.py" />
    <extension point="xbmc.addon.metadata">
        <summary lang="en_GB">Pings Google</summary>
        <description lang="en_GB">...</description>
        <platform>windx</platform>
        <license></license>
        <source></source>
        <forum></forum>
        <email></email>
        <assets>
        </assets>
    </extension>
</addon>
Reply
#2
I have the same issue https://forum.kodi.tv/showthread.php?tid=315122
I have tried to solve this in many different ways but no luck.
Reply
#3
I just ran into the same issue. Most likely not a Kodi issue but in the underlying implementation of python's subprocess.
It's related to the stdout part, leave the pipe out and it's working fine.
Reply

Logout Mark Read Team Forum Stats Members Help
[64-bit] subprocess.Popen raises error0