UniversalDevicesInc/polyglot-v2

2.2.8 nodeserver installation issue for Sonos and HarmonyHub

psmith3 opened this issue · 16 comments

2.2.8 fixes the customparameters problem, but I see this error in the log when installing Sonos and another error for Harmonyhub.

2/21/2019, 7:29:11 PM [polyglot] debug: NSChild: Sonos /bin/sh ./install.sh: ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-byjvvzvx/netifaces/setup.py'"'"'; __file__='"'"'/tmp/pip-install-byjvvzvx/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d8efm0ob/install-record.txt --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.

For Harmonyhub...

12/21/2019, 7:25:40 PM [polyglot] debug: NSChild: HarmonyHub /bin/sh ./install.sh: ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-82vfmhwz/netifaces/setup.py'"'"'; __file__='"'"'/tmp/pip-install-82vfmhwz/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ncuhdkue/install-record.txt --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.

12/21/2019, 7:25:40 PM [polyglot] debug: NSChild: HarmonyHub /bin/sh ./install.sh: ERROR: pip3 failed, see above

12/21/2019, 7:25:40 PM [polyglot] debug: NSChild: HarmonyHub /bin/sh ./install.sh exited with cause code: 1

If I manually git clone the Sonos Nodeserver, I see the following error with "polyinterface " when I try to start it.

12/21/2019, 7:47:27 PM [polyglot] debug: NSChild Exit: Sonos exited with cause code: 1 and signal: null
12/21/2019, 7:47:27 PM [polyglot] info: Sonos(1): NodeServer Disconnected.
12/21/2019, 7:47:28 PM [polyglot] debug: MQTTP: nsCommand Message: {"status":{"address":"controller","driver":"ST","value":"1","uom":2},"node":"5"}
12/21/2019, 7:47:28 PM [polyglot] info: Tesla(5): Processing command: status
12/21/2019, 7:47:28 PM [polyglot] debug: ISY: 200 - http://172.30.17.247:80/rest/ns/5/nodes/n005_controller/report/status/ST/1/2
12/21/2019, 7:47:28 PM [polyglot] info: Tesla(5): n005_controller ST set sucessfully to 1 : UOM 2
12/21/2019, 7:47:32 PM [polyglot] debug: MQTTP: nsCommand Message: {"node":"1","start":""}
12/21/2019, 7:47:32 PM [polyglot] info: Sonos(1): Processing command: start
12/21/2019, 7:47:32 PM [polyglot] info: NS: Starting Local NodeServer Sonos profile number 1 :: Version 2.0.7
**12/21/2019, 7:47:32 PM [polyglot] error: NSChild STDERR: Sonos: Traceback (most recent call last):
  File "./sonos-poly.py", line 7, in <module>
    import polyinterface
ModuleNotFoundError: No module named 'polyinterface'**

These are issues with nodeserver so should be reported to the nodeserver git, not Polyglot. See the forum for answer to the Harmony hub issue. I assume this is on Polisy...

@jimboca are you suggesting I need to open an issue with the Sonos & HarmonyHub nodeservers and not here? With this all working fine with 2.2.3 and the updates that have occurred to 2.2.8, it feels like the might be Polyglot related.

Is likely a nodeserver issue, but run the install.sh manually to see why the modules are not being installed

Is likely a nodeserver issue, but run the install.sh manually to see why the modules are not being installed

When I cloned the Sonos node server directly into my Local docker host nodeserver directory and then ran it, I got the polyinterface error. I will try to load it manually in the container from the ash prompt and see what it says.

There's an error installing modules, please run the install.sh manually.

each nodeserver

Is likely a nodeserver issue, but run the install.sh manually to see why the modules are not being installed

Thanks. Will do this shortly. Interesting that the Tesla nodeserver loaded with no issue.

Teslia NS is nodejs based, not Python.

Also, I upgraded my dev box to 2.2.8 which is an RPi on Stretch and HarmonyHub worked fine.

each nodeserver

Here is what I got when I tried to install from the container...

~/.polyglot # ls                                                                                                                                                                 
log           nodeservers   polyglot.pid  ssl                                                                                                                                    
~/.polyglot # cd nodeservers/                                                                                                                                                    
~/.polyglot/nodeservers # ls                                                                                                                                                     
Sonos                                                                                                                                                                            
~/.polyglot/nodeservers # cd Sonos/                                                                                                                                              
~/.polyglot/nodeservers/Sonos # ./install.sh                                                                                                                                     
Requirement already satisfied: soco>=0.17 in /root/.local/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (0.18.1)                                               
Collecting polyinterface>=2.0.29                                                                                                                                                 
  Using cached https://files.pythonhosted.org/packages/25/76/c94b35111b479e8a9d72a345b4269def576af754045a5fe0bfb84daf005d/polyinterface-2.0.34.tar.gz                            
Requirement already satisfied: xmltodict in /root/.local/lib/python3.8/site-packages (from soco>=0.17->-r requirements.txt (line 1)) (0.12.0)                                    
Requirement already satisfied: requests in /root/.local/lib/python3.8/site-packages (from soco>=0.17->-r requirements.txt (line 1)) (2.22.0)                                     
Requirement already satisfied: paho-mqtt in /root/.local/lib/python3.8/site-packages (from polyinterface>=2.0.29->-r requirements.txt (line 2)) (1.5.0)                          
Requirement already satisfied: python-dotenv in /root/.local/lib/python3.8/site-packages (from polyinterface>=2.0.29->-r requirements.txt (line 2)) (0.10.3)                     
Requirement already satisfied: markdown2 in /root/.local/lib/python3.8/site-packages (from polyinterface>=2.0.29->-r requirements.txt (line 2)) (2.3.8)                          
Collecting netifaces                                                                                                                                                             
  Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz                                
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /root/.local/lib/python3.8/site-packages (from requests->soco>=0.17->-r requirements.txt (line 1)) (1.2
5.7)                                                                                                                                                                             
Requirement already satisfied: idna<2.9,>=2.5 in /root/.local/lib/python3.8/site-packages (from requests->soco>=0.17->-r requirements.txt (line 1)) (2.8)                        
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /root/.local/lib/python3.8/site-packages (from requests->soco>=0.17->-r requirements.txt (line 1)) (3.0.4)               
Requirement already satisfied: certifi>=2017.4.17 in /root/.local/lib/python3.8/site-packages (from requests->soco>=0.17->-r requirements.txt (line 1)) (2019.11.28)             
Installing collected packages: netifaces, polyinterface                                                                                                                          
    Running setup.py install for netifaces ... error                                                                                                                             
    ERROR: Command errored out with exit status 1:                                                                                                                               
     command: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xqlch27q/netifaces/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xq
lch27q/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record /tmp/pip-record-me7lwpgx/install-record.txt --single-version-externally-managed --compile --user --prefix=                                       
         cwd: /tmp/pip-install-xqlch27q/netifaces/                                                                                                                               
    Complete output (16 lines):                                                                                                                                                  
    running install                                                                                                                                                              
    running build                                                                                                                                                                
    running build_ext                                                                                                                                                            
    checking for getifaddrs...not found.                                                                                                                                         
    checking for getnameinfo...not found.                                                                                                                                        
    checking for socket IOCTLs...not found.                                                                                                                                      
    checking for optional header files...none found.                                                                                                                             
    checking whether struct sockaddr has a length field...no.                                                                                                                    
    checking which sockaddr_xxx structs are defined...none!                                                                                                                      
    checking for routing socket support...no.                                                                                                                                    
    checking for sysctl(CTL_NET...) support...no.                                                                                                                                
    checking for netlink support...no.                                                                                                                                           
    building 'netifaces' extension                                                                                                                                               
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0
x100000 -fPIC -DNETIFACES_VERSION=0.10.9 -I/usr/include/python3.8 -c netifaces.c -o build/temp.linux-x86_64-3.8/netifaces.o                                                      
    unable to execute 'gcc': No such file or directory                                                                                                                           
    error: command 'gcc' failed with exit status 1                                                                                                                               
    ----------------------------------------                                                                                                                                     
ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xqlch27q/netifaces/setup.py'"'"'; 
__file__='"'"'/tmp/pip-install-xqlch27q/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close()
;exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-me7lwpgx/install-record.txt --single-version-externally-managed --compile --user --prefix= Check
 the logs for full command output.                                                                                                                                               
~/.polyglot/nodeservers/Sonos # 

I've never used containers, but looks like gcc is not part of your container, so you either need gcc to compile the netifaces module, or manually install the compiled version of netifaces for your platform from pip3

I've never used containers, but looks like gcc is not part of your container, so you either need gcc to compile the netifaces module, or manually install the compiled version of netifaces for your platform from pip3

Found the issue. apk add linux-headers is needed in the Docker Container. It fails the installation in the dockerfile. Will post fix once I know.

I've never used containers, but looks like gcc is not part of your container, so you either need gcc to compile the netifaces module, or manually install the compiled version of netifaces for your platform from pip3

So the problem was the build-base and linux-headers dependencies were being removed in the current dockerfile and are needed to install Sonos nodeserver using gcc in the install.sh script. Not purging these dependencies does make the polyglot docker image bigger at 458 MB, up from ~280 MB. Maybe @Einstein42 could look at this and see if there is a way to make smaller. I tried to manually install gcc and running the Sonos install.sh manually and it failed until I added build-base and linux-headers with apk add --no-cache --virtual .build-deps linux-headers build-base. I also added an install of mongoose to clear up a vulnerability and then ran npm audit fix to further clean up. The polyglot-pkgs volume to /usr/lib/python3.8/site-packages.

I did notice in the log that the local ISY is actually discovered on the network, but the UI says it was not discovered and the settings still show the default IP of 192.168.1.10. You will need to update the IP address of your ISY and set the username and password. That does seem to be a bug.

For the docker-compose up -d to work properly, ./mongodb and ./dot-polyglot directories need to be added.

I have updated the dockerfile and the docker-compose.yml to the following. These changes need to get checked in.

New dockerfile

FROM node:10-alpine

EXPOSE 3000
WORKDIR /opt/polyglot-v2/

RUN apk add --no-cache linux-headers build-base && \
    apk add --no-cache python3 python3-dev py3-pip bash git ca-certificates wget tzdata openssl && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
    rm -r /root/.cache && \
    cd /opt && \
    git clone --depth=1 --single-branch --branch master https://github.com/UniversalDevicesInc/polyglot-v2.git && \
    cd /opt/polyglot-v2 && \
    npm install mongoose@5.8.2 && \
    npm audit fix && \
    npm install

VOLUME /root/.polyglot
VOLUME /usr/lib/python3.8/site-packages

# Run Polyglot
CMD npm start

New docker-compose that sets up both polyglot and mongo to use the host network and discover devices on the docker host network.

version: '2'
services:
    mongo:
        image: "mongo:latest"
        container_name: "mongodb"
        network_mode: host
        volumes:
         - ./mongodb:/data/db
        ports:
         - "27017:27017"
        restart: always
    polyglot:
        stdin_open: true
        tty: true
        build: .
        container_name: polyglotv2
        network_mode: host
        ports:
         - "3000:3000"
        volumes:
         - ./dot-polyglot:/root/.polyglot
         - polyglot-pkgs:/usr/lib/python3.8/site-packages
        depends_on:
         - mongo
        environment:
         - PYTHON=/usr/bin/python
         - PYTHON3=/usr/bin/python3
         - NODE_ENV=development
        restart: always
        
volumes:
  polyglot-pkgs:

Changes applied in my git package at https://github.com/psmith3/polyglot-v2. Follow instructions to install via script.