From 47337d570666d309ed5f8cea85ea83db8008daf2 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Sun, 27 Oct 2019 11:27:21 +0100 Subject: [PATCH] wip --- zfs_autobackup | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/zfs_autobackup b/zfs_autobackup index aa91d7f..cfab82a 100755 --- a/zfs_autobackup +++ b/zfs_autobackup @@ -326,6 +326,27 @@ class ExecuteNode: else: return(self.ssh_to) + def parse_stdout(self, line): + """parse stdout. can be overridden in subclass""" + if self.debug_output: + self.debug("STDOUT > "+line.rstrip()) + + + def parse_stderr(self, line, hide_errors): + """parse stderr. can be overridden in subclass""" + if hide_errors: + self.debug("STDERR > "+line.rstrip()) + else: + self.error("STDERR > "+line.rstrip()) + + def parse_stderr_pipe(self, line, hide_errors): + """parse stderr from pipe input process. can be overridden in subclass""" + if hide_errors: + self.debug("STDERR|> "+line.rstrip()) + else: + self.error("STDERR|> "+line.rstrip()) + + def run(self, cmd, input=None, tab_split=False, valid_exitcodes=[ 0 ], readonly=False, hide_errors=False, pipe=False): """run a command on the node @@ -404,26 +425,19 @@ class ExecuteNode: line=p.stdout.readline() if line!="": output_lines.append(line.rstrip()) - if self.debug_output: - self.debug("STDOUT > "+line.rstrip()) + self.parse_stdout(line) else: eof_count=eof_count+1 if p.stderr in read_ready: line=p.stderr.readline() if line!="": - if hide_errors: - self.debug("STDERR > "+line.rstrip()) - else: - self.error("STDERR > "+line.rstrip()) + self.parse_stderr(line, hide_errors) else: eof_count=eof_count+1 if isinstance(input, subprocess.Popen) and (input.stderr in read_ready): line=input.stderr.readline() if line!="": - if hide_errors: - self.debug("STDERR|> "+line.rstrip()) - else: - self.error("STDERR|> "+line.rstrip()) + self.parse_stderr_pipe(line, hide_errors) else: eof_count=eof_count+1