diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-08-11 16:51:35 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-08-11 16:51:35 +0300 |
commit | e37be55be6ea634bd34eab34d8344234da951434 (patch) | |
tree | 2e90c2f01ae1d2ff40af5e206ac3f70536eeaff2 /ick_helpers.py | |
parent | 0882ed2136c95a015735d3dcb44ff066f1016119 (diff) | |
download | ick-helpers-e37be55be6ea634bd34eab34d8344234da951434.tar.gz |
Add: some comments to explain
Diffstat (limited to 'ick_helpers.py')
-rw-r--r-- | ick_helpers.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ick_helpers.py b/ick_helpers.py index 731d4fd..dd62ccb 100644 --- a/ick_helpers.py +++ b/ick_helpers.py @@ -1,3 +1,10 @@ +# This module contains some helper functions and classes for ick +# pipelines, specifically for doing release builds. They're in a +# Python module, in a git repo, so they're easy to use. They started +# life as a normal ick pipeline, but grew up to be big enough that +# embedding the code in YAML was too tedious and hard to debug. + + import glob import os import re @@ -5,19 +12,26 @@ import sys import subprocess +# Set this to False to make debug() be silent. verbose = True + +# Write a debug log message. def debug(*args): if verbose: - print('DEBUG:', *args) + print(*args) class Exec: + # A class to execute external commands in a directory. + def __init__(self, dirname): self.dirname = dirname def run(self, *args, **kwargs): + # Run a command. + if 'cwd' not in kwargs: kwargs['cwd'] = self.dirname if 'check' not in kwargs: @@ -35,12 +49,16 @@ class Exec: return x def get_stdout(self, *args, **kwargs): + # Run a command, capture its stdout. Fail on non-zero exit. + kwargs['check'] = True kwargs['stdout'] = subprocess.PIPE x = self.run(*args, **kwargs) return x.stdout.decode('UTF-8') def run_silently(self, *args, **kwargs): + # Run a command, don't capture output. Return exit code. + kwargs['stdout'] = kwargs['stderr'] = subprocess.DEVNULL kwargs['check'] = False return self.run(*args, **kwargs) |