telldus / tellstick-server-plugins

Plugins for TellStick Server
13 stars 8 forks source link

How to fix broken "./tellstick.sh setup" on Mac #10

Open atchoo78 opened 4 years ago

atchoo78 commented 4 years ago

There isn't currently possible to post issues in Tellstick Server, so I post this here for now:

I've had major problems running ./tellstick.sh setup on macOS 10.15 with Python 2 & 3 installed from Homebrew. I managed to fix it, and here's how I did it, if anyone else is having issues with the same thing:

First of all, make sure you have Homebrews "pip2" and "pip3" symlinked & working (just check that both "pip2" and "pip3" are valid commands).

Then run sudo easy_install virtualenv, ./tellstick.sh shell and ./tellstick.sh setup.

Let it install until it eventually stops and you get error messages all over the place.

  1. Insert alias pip="/usr/local/bin/pip2" in .zshconfig. Or whatever way you prefer to do this. I found this to be a LOT easier than symlinking etc.
  2. In "/api", edit setup.py and change
    from distutils.core import setup

    to

from setuptools import setup
  1. Run

    /PATH-TO/tellstick-server/build/env/bin/pip install setuptools
    /PATH-TO/tellstick-server/build/env/bin/pip install lupa
    /PATH-TO/tellstick-server/build/env/bin/pip install watchdog
  2. Run ./tellstick.sh setup again, and (hopefully) it will fix any "Unknown distribution option" errors, and install everything sandboxed.

Enjoy.

mickeprag commented 4 years ago

Thank you for these instructions. For step number three, if you run tellstick.sh shell first you can simply just type:

pip install setuptools
pip install lupa
pip install watchdog
atchoo78 commented 1 year ago

Hi again (from 3 years into the future)!

@mickeprag : I get this error message when I try to build/sign a plugin:


AttributeError: 'GPG' object has no attribute 'sign_file'. 

It seems that everything except writing the ASC signature file (and creating the zip file) is working though, but I suspect that GPG somehow isn't working like it used to…
¯_(ツ)_/¯

atchoo78 commented 1 year ago

@mickeprag Nevermind, I "fixed" it this way:


sudo rm -rf ~/.config/python-gnupg
gpg2 --refresh-keys 
gpg2 --update-trustdb
brew unlink node
brew install node@14
brew link --overwrite node@14
rm -rf lua/node_modules
rm -rf plugin-loader/node_modules
rm -rf build
./tellstick.sh shell
pip install python-gnupg
pip install setuptools
pip install lupa
pip install watchdog
./tellstick.sh setup

And out of the blue...


./tellstick.sh build-plugin plugins/Some_plugin

was running like Forrest Gump.

As usual, I have no idea which of the above commands made it work. Desperate measures calls for desperate bash scripts.

/Andreas

mickeprag commented 1 year ago

Hi,

Great to hear you sorted it out. If you get stuck again I would probably to to get a development environment working inside a docker instead.

atchoo78 commented 1 year ago

Updated instructions (2023):

These instructions apply to macOS only

Disclaimer:

I won’t take any responsibility if these instructions crash your computer, makes your shell inresponsive etc. These instructions are not official, and are in no way endorsed, connected to, written on behalf of or approved by Telldus Technologies™ of Sweden. Puh 😮‍💨

First:

Install Python 2.7

Details

install nvm so you can run the node modules provided:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

or

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Add this to .zshrc or .bashrc, depending on which shell you use (~/.zshrc is default in macOS). Save the file.

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

ZSH:

source ~/.zshrc

Bash:

source ~/.bashrc

Then:

cd to tellstick-server root (assuming you have installed to ~/tellstick-server):

cd ~/tellstick-server

In the API/ folder, add "PyJWT==1.7.1" to requirements.txt

Check that python symlinks to /usr/local/bin/python2. Uninstall virtualenv just to make sure there is no prior virtualenv on your system.

which python
pip uninstall virtualenv 
pip --version 

Make sure the version reports 20.3.4 (python 2.7)

pip install virtualenv
virtualenv --python=python2.7 ./build/env
source build/env/bin/activate
nvm install 11
nvm use 11
pip install watchdog
mkdir ./build/scripts/lua
mkdir ./build/plugins

In "plugin-loader/src/pluginloader/WebFrontend.py", line 242, change to:

    yaml.load(open('%s/plugins.yml' % Board.pluginPath(), 'r').read(), Loader=yaml.FullLoader)

In "api/src/api/ApiManager.py", line 24, change to:

    import jwt

In "plugin-loader/src/pluginloader/Loader.py", line 36, change to:

    self.manifest = yaml.load(open(manifest, 'r').read(), Loader=yaml.FullLoader)

# change line 216 to:

    cfg = yaml.load(zipF.read('manifest.yml'), Loader=yaml.FullLoader)

# and change line 252 to:

    cfg = yaml.load(zipF.read('manifest.yml'), Loader=yaml.FullLoader)

Save the file, exit to shell and

cd ~/tellstick-server
pip install rauth
pip install pycryptodome
pip install paramiko

./tellstick.sh install lua
./tellstick.sh install plugin-loader
./tellstick.sh install telldus
./tellstick.sh setup

Finally, to run the server:

./tellstick.sh run

@mickeprag:

Hi,

Great to hear you sorted it out. If you get stuck again I would probably to to get a development environment working inside a docker instead.

As soon as I had it up and running (per these instructions), I did a full export of the Virtualenv, downloaded all external modules + Python 2.7 installer and created a zip file with everything in (where the loose cannon on deck being the node.js dependencies and npm 🤪). Now I’m reading up on docker containers.