monitoring-plugins icon indicating copy to clipboard operation
monitoring-plugins copied to clipboard

All Plugins: venv handling does not work anymore

Open markuslf opened this issue 3 years ago • 2 comments

Describe the bug As of today, when creating a Python venv for the monitoring plugins, there is no bin/activate_this.py anymore, but only bin/activate. This shell script is not directly executable. To start the venv, the shell script must be called with source bin/activate, which is not possible with exec('source ...').

So the code block # considering a virtual environment has to be refactored.

https://stackoverflow.com/questions/25020451/no-activate-this-py-file-in-venv-pyvenv

markuslf avatar Mar 11 '22 10:03 markuslf

First guess: If putting https://raw.githubusercontent.com/pypa/virtualenv/main/src/virtualenv/activation/python/activate_this.py into /path/to/venv/monitoring-plugins-venv3/ and doing an export MONITORING_PLUGINS_VENV3=/path/to/venv/monitoring-plugins-venv3/, it fails with

Traceback (most recent call last):
  File "mycheck3", line 28, in <module>
    exec(open(ACTIVATE_THIS).read(), {'__file__': ACTIVATE_THIS}) # pylint: disable=W0122
  File "<string>", line 28, in <module>
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

which is clear because of Python2 code. Seems that we have to deliver a new activate_this.py by ourselves?

markuslf avatar Jun 19 '22 18:06 markuslf

Get the bin/activate from Python 2, adapt this and put it in assets.

markuslf avatar Jul 05 '22 08:07 markuslf

Since we are focusing on the compiled plugins on target systems, this may not be necessary anymore.

markuslf avatar Feb 15 '23 20:02 markuslf

Code removed.

markuslf avatar Feb 19 '23 07:02 markuslf