Skip to content

Commit

Permalink
Back to stdout.readlines() for cmd_stdout.sort
Browse files Browse the repository at this point in the history
run_command accepts a sort argument which causes the line output from
the command to be sorted. Can only do this with a list hence we're
moving back to stdout.readlines() which creates a list of lines.

Also clean up the subprocess.Popen call.
  • Loading branch information
rhodesn committed Jun 16, 2019
1 parent 2b98e41 commit 3c785d5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions configsnap
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ class dataGather:
(command[0], e.strerror))
return False

cmd_stdout, cmd_stderr = cmd_proc.communicate(input=False)
# Can't change this to Popen.communicate() as it needs to be a list for the sort below
cmd_stdout = cmd_proc.stdout.readlines()

returncode = cmd_proc.wait()
if not fail_ok and returncode != 0:
Expand Down Expand Up @@ -326,16 +327,21 @@ class dataGather:
report_error("Unable to open %s: %s" % (filename, e.strerror))
return False


def get_diff_files(self, filename):
global diffs_found_msg
filename = os.path.join(self.workdir, filename)
pre_filename = "%s.%s" % (filename, options.pre_suffix)
post_filename = "%s.%s" % (filename, self.phase)

try:
diff_proc = subprocess.Popen(['diff', '--unified=0', '--ignore-blank-lines', '--ignore-space-change', pre_filename, post_filename],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
diff_proc = subprocess.Popen(['diff', '--unified=0',
'--ignore-blank-lines',
'--ignore-space-change',
pre_filename,
post_filename],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False)
except OSError, e:
report_error("Error running diff: %s" %
(e.strerror))
Expand Down

0 comments on commit 3c785d5

Please sign in to comment.