Skip to content

Commit

Permalink
added some updates to the python3 app
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleBinghamSoteriaSoft committed Aug 13, 2024
1 parent 9ec72f9 commit 21ed554
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
3 changes: 2 additions & 1 deletion applications/python3/cgi-bin/getSystemPackageRecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
# make the URL strings an actual URL
htmlCode = html.unescape(htmlCode)
# make the links off the system package record here from the systemKey in the JSON object above
htmlMenu = "<p><a href='listSystemPackageChecklists.py?systemKey=" + json_object['systemKey'] + "'>List Checklists</a><br />"
htmlMenu = "<p><a href='getSystemPackagePatchScore.py?systemKey=" + json_object['systemKey'] + "'>Patch Score Listing</a><br />"
htmlMenu += "<a href='listSystemPackageChecklists.py?systemKey=" + json_object['systemKey'] + "'>List Checklists</a><br />"
htmlMenu += "<a href='listSystemPackageHardware.py?systemKey=" + json_object['systemKey'] + "'>List Hardware</a><br />"
htmlMenu += "<a href='listSystemPackageSoftware.py?systemKey=" + json_object['systemKey'] + "'>List Software</a><br />"
htmlMenu += "<a href='listSystemPackagePPSM.py?systemKey=" + json_object['systemKey'] + "'>List Ports/Protocols/Services</a><br />"
Expand Down
2 changes: 1 addition & 1 deletion applications/python3/cgi-bin/listSystemPackageHardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
hardwareTable = PrettyTable(["HostName", "Operating System"])
# Just get the fields want
for element in json_object: # iterate on each element of the list
hardwareTable.add_row([element['hostname'], "<a href='getSystemPackageHardwareRecord.py?systemKey=" + element['systemKey'] + "&hardwareid=" + element['internalIdString'] + "'>" + str(element['operatingSystem']) + "</a>"])
hardwareTable.add_row(["<a href='getSystemPackageHardwareRecord.py?systemKey=" + element['systemKey'] + "&hardwareid=" + element['internalIdString'] + "'>" + str(element['hostname']) + "</a>", str(element['operatingSystem'])])
# call to make this an HTML table and put into a new variable
htmlCode = hardwareTable.get_html_string(attributes={"class":"table"}, format=True)
# make the URL strings an actual URL
Expand Down
2 changes: 1 addition & 1 deletion applications/python3/cgi-bin/listTeamSubpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
systemPackageTable = PrettyTable(["Team Package", "Team Key", "Checklists", "Devices", "Last Updated"])
# Just get the fields we want
for element in json_object: # iterate on each element of the list
systemPackageTable.add_row([element['title'], "<a href='getListOfTeamSubpackages.py?systemKey=" + element['systemKey'] + "'>" + element['teamKey'] + "</a>", element['numberOfChecklists'], element['numberOfDevices'], element['updatedDateString']])
systemPackageTable.add_row([element['title'], element['teamKey'], element['numberOfChecklists'], element['numberOfDevices'], element['updatedDateString']])
# call to make this an HTML table and put into a new variable
htmlCode = systemPackageTable.get_html_string(attributes={"class":"table"}, format=True)
# make the URL strings an actual URL
Expand Down
2 changes: 1 addition & 1 deletion applications/python3/cgi-bin/listTemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["Authorization"] = "Bearer" + myVariables.bearerToken
headers["Authorization"] = "Bearer " + myVariables.bearerToken

resp = requests.get(url, headers=headers)
json_object = json.loads(resp.text)
Expand Down
28 changes: 28 additions & 0 deletions applications/python3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Soteria Software | OpenRMF Professional Python API Application</title>
</head>

<body>
<h1>Python3 example application using simple cgi-bin</h1>
To launch the application, from the ./applications/python/ folder run the below command. And access with a browser to http://localhost:8000/cgi-bin/listTemplates.py for example.

<pre>python3 -m http.server --cgi</pre>

This includes a myVariables.py file that has the 3 below variables in it for the root URL, application key, and bearer token generated. This is in place of ENVIRONMENT variables in a framework or however you wish to pass and use the information securely.

<pre>
rootURL = "http://openrmfpro.mycompany.com:8080"
applicationKey = "myApplicationKey"
bearerToken = "hvs.CAESIBP1QjNLqckAk1PlNyMqqJTlxxxxxxxxxxqTDV6Y05uOVhkTXREdlZlSHpjOUt0Q0U"
</pre>
<hr width="90%" />
<h2>Start Here</h2>
<p><a href="/cgi-bin/listSystemPackages.py">List System Packages</a></p>
<p><a href="/cgi-bin/listTeamSubpackages.py">List Team Subpackages</a></p>
<p><a href="/cgi-bin/listTemplates.py">List Templates</a></p>
</body>
<hr width="90%" />
Reference: <a href="https://github.com/SoteriaSoftwareLLC/openrmfpro-automation/tree/main/applications/python3" target="_blank">OpenRMF<sup>&reg;</sup> Professional Automation Repo</a>
</html>

0 comments on commit 21ed554

Please sign in to comment.