Add system repository for command line handling
This commit is contained in:
parent
94b993ccf5
commit
72e9add5af
1 changed files with 22 additions and 0 deletions
22
system_repository.py
Normal file
22
system_repository.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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}")
|
Loading…
Reference in a new issue