From 42935cca8ce4d5905846710c75c7694fd9f4617a Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sun, 14 Jan 2024 21:52:11 -0500 Subject: [PATCH] Add commands to enable/disable the NI webserver - Fixes #96 --- robotpy_installer/cli_installer.py | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/robotpy_installer/cli_installer.py b/robotpy_installer/cli_installer.py index 0b9833f..f6eebcc 100644 --- a/robotpy_installer/cli_installer.py +++ b/robotpy_installer/cli_installer.py @@ -306,6 +306,48 @@ def run( ) +class InstallerNiWebEnable(_BasicInstallerCmd): + """ + Enables the NI web server and starts it + """ + + def on_run(self, installer: RobotpyInstaller): + installer.ssh.exec_bash( + "update-rc.d -f systemWebServer defaults", + "/etc/init.d/systemWebServer start", + check=True, + print_output=True, + ) + + +class InstallerNiWebDisable(_BasicInstallerCmd): + """ + Stops the NI web server and disables it from starting + """ + + def on_run(self, installer: RobotpyInstaller): + installer.ssh.exec_bash( + "/etc/init.d/systemWebServer stop", + "update-rc.d -f systemWebServer remove", + check=True, + print_output=True, + ) + + +class InstallerNiWeb: + """ + Manipulates the NI web server + + The NI web server on the RoboRIO takes up a lot of memory, and isn't + used for very much. Use these commands to enable or disable it. + """ + + subcommands = [ + ("enable", InstallerNiWebEnable), + ("disable", InstallerNiWebDisable), + ] + + class InstallerList(_BasicInstallerCmd): """ Lists Python packages present on RoboRIO @@ -367,6 +409,7 @@ class Installer: ("install", InstallerInstall), ("install-python", InstallerInstallPython), ("list", InstallerList), + ("niweb", InstallerNiWeb), ("uninstall", InstallerUninstall), ("uninstall-python", InstallerUninstallPython), ("uninstall-robotpy", InstallerUninstallRobotPy),