Jelajahi Sumber

better subcommand handling

Tobias Simetsreiter 4 tahun lalu
induk
melakukan
ddc3e1b567

+ 1 - 1
src/bootstrap_captive/form/32-raspi-zero-waveshare.json

@@ -36,7 +36,7 @@
         },
         {
             "key": "install",
-            "inlinetitle": "Install Raspi Waveshare"
+            "inlinetitle": "Install crontab entry"
         },
         "branch",
         "cron_timer",

+ 7 - 5
src/bootstrap_captive/form/32-raspi-zero-waveshare.py

@@ -22,20 +22,20 @@ def submit_form(inp, form):
     branch = os.path.basename(inp["branch"])
     ref = "origin/"+branch
     cron_timer = inp["cron_timer"]
+    proc = None
     try:
-        proc = None
         if not os.path.isdir(install_dir):
             CMD = ["apt-get", "install", "-y", "git"]
-            proc = runck(CMD)
-            os.path.makedirs(install_dir, exist_ok=True)
+            proc = runck(CMD, check=False)
+            os.makedirs(install_dir, exist_ok=True)
             CMD = ["git","init"]
             proc = runck(CMD, cwd=install_dir)
             CMD = ["git","remote","add","origin",git_remote]
             proc = runck(CMD, cwd=install_dir)
             CMD = ["git","branch", branch]
-            proc = runck(CMD, cwd=install_dir)
+            proc = runck(CMD, cwd=install_dir, check=False)
             CMD = ["git","checkout", branch]
-            proc = runck(CMD, cwd=install_dir)
+            proc = runck(CMD, cwd=install_dir, check=False)
         if inp["update"] == True:
             CMD = ["git","fetch"]
             proc = runck(CMD, cwd=install_dir)
@@ -47,6 +47,8 @@ def submit_form(inp, form):
             proc = runck(CMD, cwd=install_dir)
             CMD = ["make","deps"]
             proc = runck(CMD, cwd=install_dir)
+            CMD = ["make"]
+            proc = runck(CMD, cwd=install_dir)
         if inp["install"] == True:
             CMD = ["make","install", "CRON_T="+cron_timer, "DEPLOY_DIR="+install_dir, "CRON_SUBCOMMAND="+ subcommand]
         else:

+ 7 - 1
src/bootstrap_captive/helper.py

@@ -2,5 +2,11 @@
 
 def runck(*args, **kwargs):
     from subprocess import run, PIPE
-    return run(*args, stderr=PIPE, stdout=PIPE, check=True, **kwargs)
+    if not "check" in kwargs:
+        kwargs["check"] = True
+    if not "stdout" in kwargs:
+        kwargs["stdout"] = PIPE
+    if not "stderr" in kwargs:
+        kwargs["stderr"] = PIPE
+    return run(*args, **kwargs)