From 249ca38c6b39bd2a9721d4a88eab2cac476e8fea Mon Sep 17 00:00:00 2001 From: Sankar Ramalingam Date: Fri, 22 Sep 2017 20:02:06 +0530 Subject: [PATCH] Issue #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 | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/lib389/__init__.py b/lib389/__init__.py index abd60d4..d401ff2 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -2832,40 +2832,32 @@ 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