dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
598 stars 276 forks source link

packaging the python scripts: a proof of concept #246

Closed parmentelat closed 1 year ago

parmentelat commented 1 year ago

as a proof of concept regarding issue #245, here's a change that would expose the script InsertEjectVirtualMediaREDFISH.py as a properly installed command that I arbitrarily chose to name redfish-insert-eject-virtual-media (the naming can be adapted of course)

the first commit is about cleaning up the .py script in terms of trailing spaces and extra empty lines at the end of the file; it brings no change at all, but makes the next move (introduce a main() function) less confusing

of course this would need to be applied on all the scripts, but it is something that can be relatively easily automated

let me know what you think of this approach

parmentelat commented 1 year ago

fyi I've gone ahead and did the job on a slightly larger scale with the 6 commands that I'm likely to use most, this can be found in the commands branch in my fork

note that the global variables used in the main part, now a function, need to be declared global, otherwise the logic is broken

texroemer commented 1 year ago

Hi @parmentelat

Did you setup test pypi and confirm this works, installs individual python scripts when running pip to install IdracRedfishSupport? I was trying it today and no luck getting it to work.

parmentelat commented 1 year ago

I can confirm that

pip install -e .

(in the folder where is setup.py of course) does the job to expose the commands in my path, I've been using this all day already

I have not uploaded on pypi though, this will trigger issues of its own for sure, but in my experience it should be no big deal

texroemer commented 1 year ago

I got it working but only need to make changes to setup.py (no changes needed to each individual script adding main()), added line below:

scripts=["AssignHotSpareREDFISH.py","BiosChangePasswordREDFISH.py"]

Example after running pip the scripts are located in same directory.

image

texroemer commented 1 year ago

Let me know if this works for you, i can make the code changes so it will upload all scripts from Python directory (example above i just ran it to test out pypi, confirm it works installing scripts from Python directory).

parmentelat commented 1 year ago

Hey, thanks for looking into this my only concern is to be able to use the scripts with an easy installation step, so whatever method is best for you, fine by me I guess I could have done with a more finger-friendly (read, lowercase only) naming scheme, but that's another story entirely...

parmentelat commented 1 year ago

this is no longer relevant as of 0.0.8 see also #245 closing