dell / iDRAC-Redfish-Scripting

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

<!DOCTYPE html> SyntaxError: invalid syntax #211

Closed spicerlabs closed 2 years ago

spicerlabs commented 2 years ago

S:>GetSetPowerStateREDFISH.py root password File "S:\GetSetPowerStateREDFISH.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax

texroemer commented 2 years ago

Hi @spicerlabs

Can you tell me which version of python you're running? I have version 3.9 installed and using version 4 of the script, no issues.

C:\Python39>GetSetPowerStateREDFISH_test.py -ip 192.168.0.130 -u root -p calvin -g

- INFO, Current server power state is: On

- Supported values for server power control are:

On
ForceOff
ForceRestart
GracefulRestart
GracefulShutdown
PushPowerButton
Nmi
PowerCycle

Thanks Tex

ajya commented 2 years ago

@spicerlabs could it be that your S:\GetSetPowerStateREDFISH.py is an HTML file and not a Python file? Instead of downloading https://github.com/dell/iDRAC-Redfish-Scripting/blob/master/Redfish%20Python/GetSetPowerStateREDFISH.py, get the raw version from https://raw.githubusercontent.com/dell/iDRAC-Redfish-Scripting/master/Redfish%20Python/GetSetPowerStateREDFISH.py or clone the repo.

spicerlabs commented 2 years ago

@texroemer I've installed python-3.10.4-amd64 and I'm getting so many warnings and errors. @ajya I think while importing the modules it's getting an error. I'm just a beginner at this kind of script.

texroemer commented 2 years ago

Hi @spicerlabs

Are you using the raw link to to download the script from GitHub? If you don't use the raw link you'll run into multiple issues.

Example below of downloading raw link.

[root@localhost /]# python3
Python 3.6.8 (default, Mar 18 2021, 08:58:41)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> get_script = requests.get("https://raw.githubusercontent.com/dell/iDRAC-Redfish-Scripting/master/Redfish%20Python/GetSetPowerStateREDFISH.py")

>>>
>>> with open("GetSetPowerStateREDFISH.py", "w") as x:
...     x.writelines(get_script.text)
...
>>> exit()
[root@localhost /]# chmod +x GetSetPowerStateREDFISH.py
[root@localhost /]# python3 GetSetPowerStateREDFISH.py -h
usage: GetSetPowerStateREDFISH.py [-h] -ip IP -u U -p P
                                  (--script-examples | -g | -r R)

Python script using Redfish API to either get current server power state and
possible power state values or execute server power state change

optional arguments:
  -h, --help         show this help message and exit
  -ip IP             iDRAC IP address
  -u U               iDRAC username
  -p P               iDRAC password
  --script-examples  Prints a set of examples for this script.
  -g                 Get current power state of the server and possible values
                     for ComputerSystem.Reset.
  -r R               Pass in the computer system reset type you want to
                     perform. To get supported possible values, execute the
                     script with -g argument
[root@localhost /]#