Forum Discussion

DanBuck's avatar
DanBuck
Icon for Contributor rankContributor
3 months ago

Elevated Privileges for Python3 Libraries

We are stuck trying to recreate some of the metrics we collect in our current Python2 snippets using pipes. The specific example is 'ping', which required subprocesses, no longer allowed. We don't b...
  • MattH's avatar
    3 months ago

    Dan,

    I can address the first question. You should be able to pull in that ping3 wheel/library using these instructions: https://docs.sciencelogic.com/latest/Content/Web_Content_Dev_and_Integration/ScienceLogic_Libraries/chapter_02_managing_libraries.htm?Highlight=science%20logic%20library#manually-building-a-sciencelogic-library

    That library is fairly simple to pull in because it doesn't require to be compiled and it has no other dependent libraries or wheels. The instructions should boil down:

    • Saving that wheel from pypi
    • Creating a metadata.json file describing the library and the wheels is contained in the SL library (see below)
    • Creating a tar file that contains the wheel(s) and the metadata.json file.

    Your metadata.json should look like this...

    {
        "meta_version": "0.2",
        "fields": {
            "description": "Ping3 Library",
            "manifest": [
                "ping3-4.0.8-py3-none-any.whl"
            ],
            "name": "ping3",
            "type": "py_package",
            "version": "4.0.8",
            "requires_python": ">=3.5"
        }
    }

    From there you should be able to import and align the SL library into your SL1.

    Your tar file listing should look like this...

    [workspace]# tar tvf ping3+4.0.8.py36.tar
    -rw-r--r-- root/root       287 2024-06-20 13:35 metadata.json
    -rw-r--r-- root/root     14007 2024-06-20 13:33 ping3-4.0.8-py3-none-any.whl

    Some gotchas is that you need to prepare the SL library on an OracleLinux or RedHat variant.

    Hope that helps and let me know how it goes!