You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var co = require('co')
var spawn = require('co-child-process')
var fs = require('fs')
co(function* () {
var t = yield unzip()
})
function * unzip() {
var stream = fs.createReadStream("/home/sylvain/Documents/imgtmp/photos.zip")
var out = yield spawn('pv',['-','|','unzip-stream','/tmp']).pump(stream)
}
where unzip stream is an alias : alias unzip-stream="python -c \"import zipfile,sys,StringIO;zipfile.ZipFile(StringIO.StringIO(sys.stdin.read())).extractall(sys.argv[1] if len(sys.argv) == 2 else '.')\""
running this command from command line works very well :
/tmp/node_modules/co-child-process/lib/index.js:53
function onoutdata(chunk) {
^
RangeError: Invalid string length
at Socket.onoutdata (/tmp/node_modules/co-child-process/lib/index.js:53:23)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at Pipe.onread (net.js:529:20)
Activity
smolleyes commentedon Apr 27, 2016
i tried
where unzip stream is an alias :
alias unzip-stream="python -c \"import zipfile,sys,StringIO;zipfile.ZipFile(StringIO.StringIO(sys.stdin.read())).extractall(sys.argv[1] if len(sys.argv) == 2 else '.')\""running this command from command line works very well :
pv /home/sylvain/Documents/imgtmp/photos.zip | unzip-stream /tmp/testbut from the node code i have ...
NickHeiner commentedon Apr 27, 2016
I'm not sure what the problem is, and I don't have a whole lot of time to investigate. You may be better off just using
child_processdirectly.