guilbaults / infiniband-exporter

Prometheus exporter for a Infiniband Fabric
Apache License 2.0
55 stars 22 forks source link

Add header line for running the exporter as Python3 program directly #16

Closed gabrieleiannetti closed 3 years ago

gabrieleiannetti commented 3 years ago

Hi,

to execute the exporter directly I have added the required line as the header into the exporter program.

It has at least 2 reasons:

It is the main entry point and should be executable directly without involving the interpreter directly
We can run it directly for testing, ...

I assumed, that the exporter will run at least with version 3, so I specified explicitly. Would not keep compatibility with version 2 anyway, so I think it is a good call here.

What do you think, will you merge it into the master?

Best Gabriele

guilbaults commented 3 years ago

Hi, this is done in the specfile, the main intention was to keep compatibility with Centos 7 with the RPMs in EPEL by installing python2-prometheus_client instead of requiring a pip install.

This should also work with Centos 8 with python3-prometheus_client and a different specfile.

gabrieleiannetti commented 3 years ago

I am not installing any package here, since I would like to modify the program and test it right away... Besides that, I could imagine, that the exporter might be executed not on CentOS or with any package build...

guilbaults commented 3 years ago

I will modify the existing specfile so it does not conflict with the python3 shebang.

gabrieleiannetti commented 3 years ago

Would be nice to run the program right away...

You could probably drop that lines in the spec file, if you would merge my pull request:

sed -i -e '1i#!/usr/bin/python' infiniband-exporter.py
install -m 0755 %{name}.py %{buildroot}/%{_bindir}/%{name}