From 120830f2766e9e4f02fd9d6c80eb7263c4e17189 Mon Sep 17 00:00:00 2001 From: Sankar Ramalingam Date: Fri, 22 Sep 2017 15:46:48 +0530 Subject: [PATCH] Ticket #98 - Fix dbscan output Description: Dbscan output is printing new line characters and tab characters. So, I changed the subprocess.Popen to subprocess.check_ output to return the exact the same output as command line. https://pagure.io/lib389/issue/98 --- lib389/__init__.py | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib389/__init__.py b/lib389/__init__.py index abd60d4..6ee56bf 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -2832,40 +2832,35 @@ class DirSrv(SimpleLDAPObject, object): else: indexfile = os.path.join(self.dbdir, bename, index + '.db') - option = '' + cmd = [ + prog, + '-f', indexfile + ] + if 'id2entry' in index: if key and key.isdigit(): - option = ' -K %s' % key + cmd.append('-K') + cmd.append(key) else: if key: - option = ' -k %s' % key + cmd.append('-k') + cmd.append(key) if width: - option = option + ' -t %d' % width + cmd.append('-t') + cmd.append(width) if isRaw: - option = option + ' -R' - - cmd = '%s -f %s' % (prog, indexfile) - - if len(option) > 0: - cmd = cmd + option + cmd.append('-R') self.stop(timeout=10) + log.info('Running script: %s' % cmd) - proc = Popen(cmd.split(), stdout=PIPE) - outs = '' - try: - outs = proc.communicate() - except OSError as e: - log.exception('dbscan: error executing (%s): error %d - %s' % - (cmd, e.errno, e.strerror)) - raise e + output = subprocess.check_output(cmd) + self.start(timeout=10) - log.info('Output from ' + cmd) - log.info(outs) - return outs + return output def searchAccessLog(self, pattern): """ -- 2.13.5