Closed Bug 964506 Opened 11 years ago Closed 11 years ago

[mozprocess] ProcessHandlerMixin's processOutputLine parameter may accept a function according to the docstring, while in fact it only accepts arrays

Categories

(Testing :: Mozbase, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: dadeldev, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release) Build ID: 20131206151436 Steps to reproduce: The mozprocess module provides ProcessHandler to launch commands. As the documentation says (https://mozbase.readthedocs.org/en/latest/mozprocess.html), the parameter processOutputLine allow to provide a function to be called for each line of output. According to this, the following code should work: from mozprocess import processhandler def output(l): print ("#> "+str(l)) p = processhandler.ProcessHandler(COMMAND_TO_LAUNCH, cwd='./',processOutputLine=output) p.run() print p.wait() Actual results: An AttributeError exception is raised showing that in fact an array is expected as following: File "/.../src/mozbase/mozprocess/mozprocess/processhandler.py", line 911, in __init__ kwargs['processOutputLine'].append(storeoutput) AttributeError: 'function' object has no attribute 'append' Expected results: According to the documentation, a single function should be accepted instead of an array and the previous code exemple shouldn't fail.
Note that ProcessHandler is a wrapper for ProcessHandlerMixin. And using directly ProcessHandlerMixin, will also lead to an exception due to the same problem: File "/.../src/mozbase/mozprocess/mozprocess/processhandler.py", line 595, in __init__ self.processOutputLineHandlers = list(processOutputLine) TypeError: 'function' object is not iterable
The patch fix the docstrings and code of both ProcessHandlerMixin and ProcessHandler to accept single function as well as array of functions in processOutputLine
Comment on attachment 8366291 [details] [diff] [review] Fix both the docstrings and the code to accept single function or array of functions Review of attachment 8366291 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me!
Attachment #8366291 - Flags: review+
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: