Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No file 'mqttwarn.py' #396

Closed
LaborEtArs opened this issue Jan 16, 2020 · 13 comments
Closed

No file 'mqttwarn.py' #396

LaborEtArs opened this issue Jan 16, 2020 · 13 comments

Comments

@LaborEtArs
Copy link

In the docs and in some examples, a file 'mqttwarn.py' is referenced to. However, the repository doesn't contain this file. Do I have to create it? How?
Trying to install 'mqttwarn' as a systemd service on Raspbian, but the 'mqttwarn.service' fails to start, as the file 'mqttwarn.py' isn't available.

@jpmens
Copy link
Collaborator

jpmens commented Jan 16, 2020

Before we try to answer that question, please be aware that a lot is changing here, in particular you should now be able to

pip install mqttwarn

directly. The file you search for is then deep in the bowels of /usr/lib/python* somewhere.

In case of doubt, please report back with how you installed mqttwarn. In any case you do not create that file yourself. :)

@LaborEtArs
Copy link
Author

To be clearer: The file 'mqttwarn.py' isn't even included in the current github repository, neither in the 'master' branch, nor in the 'py38' branch

@LaborEtArs
Copy link
Author

I used the installation as mentioned in 'mqttwarn/etc/mqttwarn.service', so basically a 'git clone https://github.com/jpmens/mqttwarn'.
But just downloaded the repo as zip and searched for 'mqttwarn.py' with no success, but by grepping I found dozens of references to the file AND a hint in 'CHANGES.rst', that the code from 'mqttwarn.py' has been moved to 'core.py'...
Is it possible, the a lot of the documentation is outdated??
What would be the way to start mqttwarn?

@jpmens
Copy link
Collaborator

jpmens commented Jan 16, 2020

The current method to install mqttwarn is pip install mqttwarn. Bits of the documentation might well be outdated.

python3 -m venv /tmp/mwarn
source /tmp/mwarn/bin/activate
pip install mqttwarn

You will then find the program you are searching for as /tmp/mwarn/bin/mqttwarn and you can invoke it that way (no need to activate the virtualenv, this happens automatically.

@LaborEtArs
Copy link
Author

OK, that did it (after moving a lot files by hand, as I had to use 'pip --user'.
But can't get it to run as a systemd service; is there an updated 'systemd' doc somewere?

@jpmens
Copy link
Collaborator

jpmens commented Jan 17, 2020 via email

@LaborEtArs
Copy link
Author

LaborEtArs commented Jan 17, 2020

You're right :-)
To remove the dependency to 'activate', I extended '/etc/default/mqttwarn' by

MQTTWARNINI="/tmp/mwarn/bin/mqttwarn.ini"
MQTTWARN_OPTIONS=""
VIRTUAL_ENV="/tmp/mwarn"
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"

and changed '/etc/systemd/system/mqttwarn.service to
[...]

[Service]
Type=simple
User=mqttwarn
Group=mqttwarn
LimitNOFILE=65536
Environment='STDOUT=/var/log/mqttwarn/mqttwarn.log'
Environment='STDERR=/var/log/mqttwarn/mqttwarn.log'
EnvironmentFile=/etc/default/mqttwarn
WorkingDirectory=/tmp/mwarn/bin/
ExecStart=/tmp/mwarn/bin/mqttwarn ${MQTTWARN_OPTIONS} >>${STDOUT} 2>>${STDERR}
KillMode=control-group
Restart=on-failure
RestartSec=10

[...]

oing so, I'm getting unlogged error messages from 'journalctl -u mqttwarn'.

The problem seems to be the 'docopt' call in 'commands.py'.
If I do

    # Read commandline options
    options = {'make-config': False, 'make-samplefuncs': False, '--plugin': False, '--data': False}
    # docopt(commandline_schema, version=APP_NAME + ' ' + __version__)

the service/mqttwarn gets started and is responsive to MQTT test messages.

@LaborEtArs
Copy link
Author

Unfortunately the call to 'docopt(commandline_schema, version=APP_NAME + ' ' + version)' just doesn't return to 'commands.py' but breaks the execution without any message/log.

@amotl
Copy link
Member

amotl commented Jan 18, 2020

Dear @LaborEtArs,

sorry that you had troubles installing the systemd service for mqttwarn and thanks for writing in.

To be clearer: The file mqttwarn.py isn't even included in the current github repository, neither in the 'master' branch, nor in the 'py38' branch.

84c57c0 now removes every reference to mqttwarn.py within the documentation.

mqttwarn.service still isn't perfect as it gives the average user no clue about where to acquire the service-related files from. In order to improve packaging in general, I've just created #397.

With kind regards,
Andreas.

@amotl
Copy link
Member

amotl commented Jan 18, 2020

The problem seems to be the 'docopt' call in commands.py.

Unfortunately the call to 'docopt(commandline_schema, version=APP_NAME + ' ' + version)' just doesn't return to 'commands.py' but breaks the execution without any message/log.

It looks like the installation of mqttwarn is not clean somehow. Please ensure the mqttwarn installation is clean before even starting to daemonize it.

@LaborEtArs
Copy link
Author

@amotl It's running as a service now on my Raspi (without cmd line options; not needed there anyways).
Unfortunately I'm not that experienced with python at all, so I wasn't able to print the given command line parameters. There seem to be a lot of implicit actions in python (like printing the a 'how-to-use' info and parsed cmd line by some strangely quoted text block... (I'm more the C guy ;-)).
However, if I can help to improve mqttwarn, I'd be happy (as it seems to be a great solution for a lot of ideas, I've got).
BTW: Are there plans to update the 'apns' plugin to 'apns2'?

@amotl
Copy link
Member

amotl commented Jan 18, 2020

It's running as a service now on my Raspi.

Ok, good to hear.

Are there plans to update the 'apns' plugin to 'apns2'?

Feel free to open another issue if you are observing problems with this plugin. After we revamped mqttwarn to be installable from PyPI and to support Python 3, there might well be some fallout we should care about. Thanks already!

@jpmens
Copy link
Collaborator

jpmens commented Jan 18, 2020

@LaborEtArs specifically, we have no plans to update the 'apns' plugin to 'apns2', but you are very welcome to contribute such a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants