Cleanup
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 19:33:39 +0000 (15:33 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 19:33:39 +0000 (15:33 -0400)
libremanage.py

index 06f904b8304cc77ae64c9f690a78c5fcca54131d..f28cd974fba16f90b3b83e3143bdec82b553a155 100644 (file)
@@ -17,11 +17,6 @@ You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <https://www.gnu.org/licenses/>.
 """
 
-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])