Hello World¶
The “Hello World” script provided below illustrates the basic structure of an imperix Python script and provides a simple way to verify that the scripting environment works correctly.
This script instructs Cockpit to refresh its target list (which performs an Ethernet network scan), iterate through all detected controllers and displays their hostnames and IP addresses.
from imperix import Cockpit
with Cockpit() as cockpit:
# Instructs Cockpit to run an Ethernet network scan and refresh its target list
print("Refreshing target list...")
cockpit.targets.refresh()
# Retrieves the list detected targets
targets = cockpit.targets.list()
print(f"{len(targets)} target(s) found:")
# Display their hostnames and IP addresses
for target in targets:
print(f" {target.hostname} ({target.ip})")