{"action":"created","issue":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/331","repository_url":"https://api.github.com/repos/pexpect/pexpect","labels_url":"https://api.github.com/repos/pexpect/pexpect/issues/331/labels{/name}","comments_url":"https://api.github.com/repos/pexpect/pexpect/issues/331/comments","events_url":"https://api.github.com/repos/pexpect/pexpect/issues/331/events","html_url":"https://github.com/pexpect/pexpect/issues/331","id":137880921,"number":331,"title":"replwrap.run_command stdout & stderr hook","user":{"login":"jkgeyti","id":617033,"avatar_url":"https://avatars.githubusercontent.com/u/617033?v=3","gravatar_id":"","url":"https://api.github.com/users/jkgeyti","html_url":"https://github.com/jkgeyti","followers_url":"https://api.github.com/users/jkgeyti/followers","following_url":"https://api.github.com/users/jkgeyti/following{/other_user}","gists_url":"https://api.github.com/users/jkgeyti/gists{/gist_id}","starred_url":"https://api.github.com/users/jkgeyti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkgeyti/subscriptions","organizations_url":"https://api.github.com/users/jkgeyti/orgs","repos_url":"https://api.github.com/users/jkgeyti/repos","events_url":"https://api.github.com/users/jkgeyti/events{/privacy}","received_events_url":"https://api.github.com/users/jkgeyti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-02T14:00:32Z","updated_at":"2016-03-02T15:18:36Z","closed_at":null,"body":"When running slow commands with occasional output in replwrap, it would be good to be able to receive output as it's written to stdout/stderr.\r\n\r\nFor my own purpose, I've just added an optional lambda argument to `replwrap.run_command`, that is called with `self.child.before` in the inner loop, whenever it's appended to `res` (see below), but it would be good to have this implemented in a more rigorous manner, separating stdout from stderr output.\r\n\r\n    def run_command(self, command, timeout=-1, progress_fn=None): # added progress_fn\r\n        ...\r\n        for line in cmdlines[1:]:\r\n            ...\r\n            res.append(self.child.before)\r\n            progress_fn(self.child.before) # added line\r\n        ...\r\n        return u''.join(res + [self.child.before])\r\n\r\nI'd be happy to take a stab at it, but I haven't looked further into the source, and wanted to get some feedback on the idea first."},"comment":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/comments/191283674","html_url":"https://github.com/pexpect/pexpect/issues/331#issuecomment-191283674","issue_url":"https://api.github.com/repos/pexpect/pexpect/issues/331","id":191283674,"user":{"login":"jkgeyti","id":617033,"avatar_url":"https://avatars.githubusercontent.com/u/617033?v=3","gravatar_id":"","url":"https://api.github.com/users/jkgeyti","html_url":"https://github.com/jkgeyti","followers_url":"https://api.github.com/users/jkgeyti/followers","following_url":"https://api.github.com/users/jkgeyti/following{/other_user}","gists_url":"https://api.github.com/users/jkgeyti/gists{/gist_id}","starred_url":"https://api.github.com/users/jkgeyti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkgeyti/subscriptions","organizations_url":"https://api.github.com/users/jkgeyti/orgs","repos_url":"https://api.github.com/users/jkgeyti/repos","events_url":"https://api.github.com/users/jkgeyti/events{/privacy}","received_events_url":"https://api.github.com/users/jkgeyti/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T15:18:36Z","updated_at":"2016-03-02T15:18:36Z","body":"Perfect - that'll works for my purposes. I still think it would be a worthwhile addition to have a less \"hacky\" way of getting output callbacks line by line, but this will make do for now.\r\n\r\nThanks a lot!"}}