summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-07-05 19:05:31 -0700
committerBen Sima <ben@bsima.me>2019-07-05 19:05:31 -0700
commiteea68711b5187178895ed1cf784e8c336b760574 (patch)
tree318f81ca52e9d9c90174e14a968ecc4436ae2b81 /chip
parentfb86a62e4bee9ac7f8ff7bfc0a034793c87fd1cf (diff)
[chip/push] better error handling/logging
Diffstat (limited to 'chip')
-rwxr-xr-xchip/push14
1 files changed, 9 insertions, 5 deletions
diff --git a/chip/push b/chip/push
index 1b8c1f8..f7114ed 100755
--- a/chip/push
+++ b/chip/push
@@ -5,13 +5,17 @@ import os
import subprocess
import tempfile
import importlib.util
+import sys
def shell(*args):
"Run a shell command and capture the output."
try:
proc = subprocess.run(args, check=True, capture_output=True)
except subprocess.CalledProcessError as e:
- raise RuntimeError(f'{e.cmd} error {e.returncode}: {e.output}')
+ print(f'! fail {e.returncode}')
+ print(f'! {" ".join(e.cmd)}')
+ print(f'! {e.stderr.strip().decode("utf8")}')
+ sys.exit(1)
return proc.stdout.strip().decode('utf8')
cli = argparse.ArgumentParser(description='deploy a thing')
@@ -29,16 +33,16 @@ out = f"{bild_dir}/{args.depo}"
# bild
shell("nix-build", "-A", f"depo.{args.depo}", "--out-link", out)
-print("bilt")
+print("+ bilt")
# push
shell("nix", "copy", "--to", f"ssh://root@{args.depo}", f"{out}")
-print("sent")
+print("+ sent")
# switch
shell("ssh", f"root@{args.depo}", "sudo",
f"{os.readlink(out)}/bin/switch-to-configuration",
"switch")
-print("switched")
+print("+ switched")
-print(f"pushed {args.depo}")
+print(f"+ pushed {args.depo}")