terraformDummyRepo/system_repository.py
erik fa73c52fe2 Remove asterisk on destructured args
Otherwise we would create a tuple containing
a tuple of arguments and an empty tuple.
2023-02-22 16:23:03 +01:00

22 lines
616 B
Python

import subprocess as sub
class SystemRepository():
def __init__(self):
self.stdout = [""]
self.stderr = [""]
def run(self, args):
stream = sub.Popen(args,
stdout=sub.PIPE,
stderr=sub.PIPE,
text=True,
encoding="UTF-8")
self.stdout = stream.stdout.readlines()
self.stderr = stream.stderr.readlines()
def run_checked(self, *args):
self.run(args)
if len(self.stderr) > 0:
raise Exception(f"Command failed with: {self.stderr}")