Alon Bar-Lev has posted comments on this change. Change subject: core: Add _executePipe ......................................................................
Patch Set 1: (10 comments) http://gerrit.ovirt.org/#/c/26213/1/src/otopi/plugin.py File src/otopi/plugin.py: Line 327: Line 328: def resolveFile(self, file): Line 329: return self.context.resolveFile(file) Line 330: Line 331: def _executePipe( why private? we probably also need this to be Raw and have the non raw with unicode conversion wrapper. Line 332: self, Line 333: popenKwargsList, Line 334: ): Line 335: """Execute a list of processes in a pipeline. Line 329: return self.context.resolveFile(file) Line 330: Line 331: def _executePipe( Line 332: self, Line 333: popenKwargsList, add stdin of the entire chain? add stdout of the entire chain? Line 334: ): Line 335: """Execute a list of processes in a pipeline. Line 336: Line 337: popenKwargsList is a list of dictionaries, each a **kwarg for Popen Line 343: stderrlist - list of binary blobs, stderrs of the commands Line 344: stdout - binary blob output of the last command Line 345: Line 346: stdin of the first process will be passed as is. The others will Line 347: be set to PIPE from their previous. please get it as explicit parameter. Line 348: Line 349: stdout of all will be set to PIPE - the last will be returned, the Line 350: others will be passed to the following ones. Line 351: """ Line 346: stdin of the first process will be passed as is. The others will Line 347: be set to PIPE from their previous. Line 348: Line 349: stdout of all will be set to PIPE - the last will be returned, the Line 350: others will be passed to the following ones. there is a value to allow redirect to file if required, default should be returned, this is ok. Line 351: """ Line 352: try: Line 353: kwl = [] Line 354: popens = [] Line 349: stdout of all will be set to PIPE - the last will be returned, the Line 350: others will be passed to the following ones. Line 351: """ Line 352: try: Line 353: kwl = [] is this only for debug? Line 354: popens = [] Line 355: rcs = [] Line 356: stderrs = [] Line 357: num = len(popenKwargsList) Line 351: """ Line 352: try: Line 353: kwl = [] Line 354: popens = [] Line 355: rcs = [] not used? Line 356: stderrs = [] Line 357: num = len(popenKwargsList) Line 358: for i, kworig in enumerate(popenKwargsList): Line 359: kw = kworig.copy() Line 352: try: Line 353: kwl = [] Line 354: popens = [] Line 355: rcs = [] Line 356: stderrs = [] not used Line 357: num = len(popenKwargsList) Line 358: for i, kworig in enumerate(popenKwargsList): Line 359: kw = kworig.copy() Line 360: kwl.append(kw) Line 353: kwl = [] Line 354: popens = [] Line 355: rcs = [] Line 356: stderrs = [] Line 357: num = len(popenKwargsList) single used variable? Line 358: for i, kworig in enumerate(popenKwargsList): Line 359: kw = kworig.copy() Line 360: kwl.append(kw) Line 361: kw['stdout'] = subprocess.PIPE Line 364: if i>0: Line 365: kw['stdin'] = popens[i-1].stdout Line 366: if i<num-1: Line 367: popens[i-1].stdout.close() Line 368: p = subprocess.Popen(**kw) no need for temporary variable Line 369: popens.append(p) Line 370: finished = False Line 371: while not finished: Line 372: # TODO add some (optional) limit? Line 373: finished = None not in [ Line 374: p.poll() for p in popens Line 375: ] Line 376: if not finished: Line 377: time.sleep(1) # TODO configurable delay? add as parameter with default=1 Line 378: except: Line 379: self.logger.debug( Line 380: '_executePipe failed: %s, exception', Line 381: popenKwargsList, -- To view, visit http://gerrit.ovirt.org/26213 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4a434fbe1308ac2f603b8ae09756354c11138912 Gerrit-PatchSet: 1 Gerrit-Project: otopi Gerrit-Branch: master Gerrit-Owner: Yedidyah Bar David <d...@redhat.com> Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com> Gerrit-Reviewer: Sandro Bonazzola <sbona...@redhat.com> Gerrit-Reviewer: Simone Tiraboschi <stira...@redhat.com> Gerrit-Reviewer: Yedidyah Bar David <d...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches