JuryA / landscape_api_py3

Client for the Landscape API (Python 3)
https://landscape-api-py3.readthedocs.io/
MIT License
2 stars 3 forks source link

[BUG] - data type arguments are not parsed correctly #839

Open CharleeSF opened 1 month ago

CharleeSF commented 1 month ago

Describe the bug create-script doesn't work because parse_data is wrong.

To Reproduce

  1. Install landscape-api python module
  2. export LANDSCAPE_API_KEY, LANDSCAPE_API_SECRET and LANDSCAPE_API_URI like described in documentation
  3. Create a file with a script that should be uploaded
  4. python3 -m landscape_api create-script Test2 300 $PATH_TO_YOUR_SCRIPT

You get an error:

Couldn't parse value '$PATH_TO_YOUR_SCRIPT' as data

Expected behavior Script gets uploaded to landscape API

Environment:

  1. Ubuntu 22.04
  2. Python 3.10.12

Suggested fix:

    def parse_data(self, parameter, value):
        return value

I already fixed it and will create a PR

CharleeSF commented 1 month ago

I am not allowed to push to this repository, but the fix I wanted to suggest also checks if the file exists:

    def parse_data(self, parameter, value):
        if not os.path.exists(value):
            raise FileNotFoundError(value)
        return value