From 22f864bb9b54c172ea3dec1a21ac3d406dbe5a05 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 25 Jun 2018 15:33:39 -0400 Subject: [PATCH] Cleanup --- libremanage.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libremanage.py b/libremanage.py index 06f904b..f28cd97 100644 --- a/libremanage.py +++ b/libremanage.py @@ -17,11 +17,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ -import sys -import json -import functools -import subprocess - USAGE = """ Usage: @@ -39,8 +34,10 @@ Valid commands are as follows: - tty: Open TTY in GNU Screen """ -with open("config.json") as f: - CONFIG = json.load(f) +import sys +import json +import functools +import subprocess def open_ssh(server, command): config = server["ssh"] @@ -51,9 +48,6 @@ def die_with_usage(message): print(USAGE) sys.exit(1) -if len(sys.argv) != 3: - die_with_usage("Incorrect number of arguments") - def get_server_handle(name): try: server = CONFIG["servers"][name] @@ -109,4 +103,12 @@ def issue_command(server_name, command): callback(server) +# Load configuration, get command, and go! + +with open("config.json") as f: + CONFIG = json.load(f) + +if len(sys.argv) != 3: + die_with_usage("Incorrect number of arguments") + issue_command(sys.argv[1], sys.argv[2]) -- 2.25.1