From 37021c3fa33da362e9ae7ee92a7ca6fc94930d8e Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Mon, 11 Oct 2021 21:42:19 -0600 Subject: [PATCH] Refactor into a single print() call --- projects/hatctl/src/python/hatctl/__main__.py | 107 +++++++++--------- 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/projects/hatctl/src/python/hatctl/__main__.py b/projects/hatctl/src/python/hatctl/__main__.py index 3c81c8e..8160c4f 100644 --- a/projects/hatctl/src/python/hatctl/__main__.py +++ b/projects/hatctl/src/python/hatctl/__main__.py @@ -114,61 +114,58 @@ nfsroot = "/var/lib/clusterctrl/nfs/" if __name__ == "__main__": args = len(sys.argv) - if ( args == 1 or sys.argv[1] == 'help' or sys.argv[1] == '--help' or sys.argv[1] == '-h' or sys.argv[1] == '/?' ): - print( "Usage :{} ".format(sys.argv[0]) ) - print( "" ) - print( "## Commands ") - print( "" ) - print( "# can be a single device 'p1' or a list 'p2 p3 p5'" ) - print( "# is the order listed by '" + sys.argv[0] + " status' (default 20)" ) - print( "" ) - print( "# Power on/off all or listed device(s)" ) - print( sys.argv[0] + " on|off []" ) - print( "" ) - print( "# Show status of ClusterHAT/CTRL" ) - print( sys.argv[0] + " status" ) - print( "" ) - print( "# Get number of controllable Pi" ) - print( sys.argv[0] + " maxpi" ) - print( "" ) - print( "# Create/update symlinks for rpiboot [root]" ) - print( "sudo " + sys.argv[0] + " init" ) - print( "" ) - print( "# Turn ALERT LED on/off for all or listed device(s)" ) - print( sys.argv[0] + " alert on|off []" ) - print( "" ) - print( "# Enable LED (Power/pX/etc.)" ) - print( sys.argv[0] + " led on" ) - print( "" ) - print( "# Disable LED (Power/pX/etc.)" ) - print( sys.argv[0] + " led off" ) - print( "" ) - print( "# Turns on/off or resets the USB HUB" ) - print( sys.argv[0] + " hub off|on|reset" ) - print( "" ) - print( "## The following are only available on ClusterCTRL devices") - print( "" ) - print( "# Set order on device to " ) - print( sys.argv[0] + " setorder " ) - print( "" ) - print( "# Get USB path to Px" ) - print( sys.argv[0] + " getpath " ) - print( "" ) - print( "# Turns FAN on/off for CTRL with " ) - print( sys.argv[0] + " fan on|off " ) - print( "" ) - print( "# Save current settings to EEPROM" ) - print( sys.argv[0] + " save " ) - print( "" ) - print( "# Save current order to EEPROM" ) - print( sys.argv[0] + " saveorder " ) - print( "" ) - print( "# Save current Power On State to EEPROM" ) - print( sys.argv[0] + " savepos " ) - print( "" ) - print( "# Save factory default settings to EEPROM" ) - print( sys.argv[0] + " savedefaults " ) - print( "" ) + if (args == 1 or sys.argv[1] == 'help' or sys.argv[1] == '--help' or sys.argv[1] == '-h' or sys.argv[1] == '/?' ): + print( """Usage :{0} + + can be a single device 'p1' or a list 'p2 p3 p5' + is the order listed by '{0} status' (default 20) + + # Power on/off all or listed device(s) + {0} on|off [] + + # Show status of ClusterHAT/CTRL + {0} status + + # Get number of controllable Pi + {0} maxpi + + # Create/update symlinks for rpiboot [root]" + sudo {0} init + + # Turn ALERT LED on/off for all or listed device(s)" + {0} alert on|off [] + + # Enable LED (Power/pX/etc.) + {0} led on + + # Disable LED (Power/pX/etc.) + {0} led off + + # Turns on/off or resets the USB HUB + {0} hub off|on|reset + + ## The following are only available on ClusterCTRL devices + # Set order on device to + {0} setorder + + # Get USB path to Px + {0} getpath + + # Turns FAN on/off for CTRL with + {0} fan on|off + + # Save current settings to EEPROM + {0} save + + # Save current order to EEPROM + {0} saveorder + + # Save current Power On State to EEPROM + {0} savepos + + # Save factory default settings to EEPROM + {0} savedefaults + """ .format(sys.argv[0])) sys.exit() # Read configruation file