Closed dmd closed 7 years ago
What information can I provide to help debug this?
Can you provide more definition around what you mean by "call fails" and "call succeed"?
When I use this code in Python:
if not call(['/u/ddrucker/node-v4.5.0/bin/particle', 'call', button, 'fraccon', rgb], stdout=FNULL, stderr=STDOUT):
print(button + ' succeeded')
else:
print(button + ' failed')
I get 'succeeded' if particle is 1.14.2, but 'failed' if I update to 1.15. I can upgrade and downgrade at will to switch between success and failure.
My function fraccon
's last line is just return 0;
.
Narrowing it down, 1.14.2 succeeds, 1.15 fails.
I suspect this change: https://github.com/spark/particle-cli/compare/v1.14.2...v1.15.0#diff-ae38a11a829764f7ca0d93c0e9318f7dR75
Updated original text for clarity.
It's still not clear what kind of failure you are getting. The change you link to makes console.log
synchronous to prevent long output like particle list
from being truncated if the program completes before all output is written.
It looks like there's something going on with respect to how it interacts with python's subprocess.call:
✔ ~/clack [master L|…2]
15:59 $ cat test.py
#!/usr/bin/env python2.7
from __future__ import print_function
from subprocess import call, STDOUT
import os
FNULL = open(os.devnull, 'w')
if not call(['/u/ddrucker/node-v4.5.0/bin/particle', 'call', 'dmd', 'fraccon', '0,4.5,4.5,0'], stdout=FNULL, stderr=STDOUT):
print('succeeded')
else:
print('failed')
✔ ~/clack [master L|…2]
15:59 $ particle
Welcome to the Particle Command line utility!
Version 1.14.2
https://github.com/spark/particle-cli
Usage: particle <command_name> <arguments>
Common Commands:
setup, list, call, get, device, identify, flash, subscribe
compile, monitor, login, logout, help
Less Common Commands:
token, binary, cloud, config, function, keys, serial, udp
update, variable, webhook, wireless
For more information Run: particle help <command_name>
✘-1 ~/clack [master L|…2]
16:00 $ ./test.py
succeeded
✔ ~/clack [master L|…2]
16:00 $ npm install particle-cli@1.15 -g --unsafe-perm
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
-
> serialport@3.1.2 install /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build
[serialport] Success: "/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node" is installed via remote
/u/ddrucker/node-v4.5.0/bin/particle -> /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/bin/particle.js
particle-cli@1.15.0 /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli
├── cli-spinner@0.2.5
├── semver@5.3.0
├── xtend@4.0.1
├── temp@0.8.3 (os-tmpdir@1.0.1, rimraf@2.2.8)
├── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, strip-ansi@3.0.1, has-ansi@2.0.0)
├── cli-table@0.3.1 (colors@1.0.3)
├── glob@4.5.3 (inherits@2.0.1, inflight@1.0.5, once@1.3.3, minimatch@2.0.10)
├── node-wifiscanner2@1.2.0 (os-locale@1.4.0)
├── inquirer@0.11.4 (ansi-regex@2.0.0, strip-ansi@3.0.1, ansi-escapes@1.4.0, rx-lite@3.1.2, through@2.3.8, cli-width@1.1.1, figures@1.7.0, string-width@1.0.2, readline2@1.0.1, cli-cursor@1.0.2, run-async@0.1.0)
├── when@3.7.7
├── form-data@1.0.0-rc4 (async@1.5.2, combined-stream@1.0.5, mime-types@2.1.11)
├── binary-version-reader@0.4.0 (buffer-crc32@0.2.5, h5.buffers@0.1.1)
├── latest-version@2.0.0 (package-json@2.4.0)
├── hogan.js@2.0.0
├── request@2.74.0 (tunnel-agent@0.4.3, aws-sign2@0.6.0, oauth-sign@0.8.2, forever-agent@0.6.1, is-typedarray@1.0.0, caseless@0.11.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.1, qs@6.2.1, node-uuid@1.4.7, combined-stream@1.0.5, mime-types@2.1.11, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validator@2.0.6)
├── moment@2.14.1
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.30)
├── lodash@3.10.1
└── serialport@3.1.2 (bindings@1.2.1, es6-promise@3.2.1, commander@2.9.0, debug@2.2.0, nan@2.4.0, object.assign@4.0.4)
✔ ~/clack [master L|…2]
16:00 $ ./test.py
failed
✔ ~/clack [master L|…2]
16:00 $ npm install particle-cli@1.14 -g --unsafe-perm
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
\
> serialport@3.1.2 install /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build
[serialport] Success: "/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node" is installed via remote
/u/ddrucker/node-v4.5.0/bin/particle -> /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/bin/particle.js
particle-cli@1.14.2 /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli
├── cli-spinner@0.2.5
├── semver@5.3.0
├── xtend@4.0.1
├── chalk@1.1.3 (ansi-styles@2.2.1, escape-string-regexp@1.0.5, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.1)
├── temp@0.8.3 (os-tmpdir@1.0.1, rimraf@2.2.8)
├── cli-table@0.3.1 (colors@1.0.3)
├── glob@4.5.3 (inherits@2.0.1, inflight@1.0.5, once@1.3.3, minimatch@2.0.10)
├── node-wifiscanner2@1.2.0 (os-locale@1.4.0)
├── inquirer@0.11.4 (ansi-regex@2.0.0, ansi-escapes@1.4.0, strip-ansi@3.0.1, rx-lite@3.1.2, through@2.3.8, cli-width@1.1.1, figures@1.7.0, string-width@1.0.2, readline2@1.0.1, cli-cursor@1.0.2, run-async@0.1.0)
├── when@3.7.7
├── form-data@1.0.0-rc4 (async@1.5.2, combined-stream@1.0.5, mime-types@2.1.11)
├── binary-version-reader@0.4.0 (buffer-crc32@0.2.5, h5.buffers@0.1.1)
├── latest-version@2.0.0 (package-json@2.4.0)
├── hogan.js@2.0.0
├── request@2.74.0 (tunnel-agent@0.4.3, aws-sign2@0.6.0, oauth-sign@0.8.2, forever-agent@0.6.1, is-typedarray@1.0.0, caseless@0.11.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.1, qs@6.2.1, node-uuid@1.4.7, combined-stream@1.0.5, mime-types@2.1.11, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validator@2.0.6)
├── moment@2.14.1
├── lodash@3.10.1
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.30)
└── serialport@3.1.2 (bindings@1.2.1, es6-promise@3.2.1, commander@2.9.0, debug@2.2.0, nan@2.4.0, object.assign@4.0.4)
✔ ~/clack [master L|…2]
16:01 $ ./test.py
succeeded
✔ ~/clack [master L|…2]
16:01 $ /u/ddrucker/node-v4.5.0/bin/particle call dmd fraccon 0,4.5,4.5,0
0
✔ ~/clack [master L|…2]
16:01 $ npm install particle-cli@1.15 -g --unsafe-perm
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
-
> serialport@3.1.2 install /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build
[serialport] Success: "/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node" is installed via remote
/u/ddrucker/node-v4.5.0/bin/particle -> /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/bin/particle.js
particle-cli@1.15.0 /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli
├── cli-spinner@0.2.5
├── semver@5.3.0
├── xtend@4.0.1
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, strip-ansi@3.0.1, has-ansi@2.0.0)
├── temp@0.8.3 (os-tmpdir@1.0.1, rimraf@2.2.8)
├── cli-table@0.3.1 (colors@1.0.3)
├── glob@4.5.3 (inherits@2.0.1, inflight@1.0.5, once@1.3.3, minimatch@2.0.10)
├── node-wifiscanner2@1.2.0 (os-locale@1.4.0)
├── inquirer@0.11.4 (ansi-regex@2.0.0, strip-ansi@3.0.1, ansi-escapes@1.4.0, rx-lite@3.1.2, through@2.3.8, cli-width@1.1.1, figures@1.7.0, readline2@1.0.1, string-width@1.0.2, cli-cursor@1.0.2, run-async@0.1.0)
├── when@3.7.7
├── form-data@1.0.0-rc4 (async@1.5.2, combined-stream@1.0.5, mime-types@2.1.11)
├── binary-version-reader@0.4.0 (buffer-crc32@0.2.5, h5.buffers@0.1.1)
├── latest-version@2.0.0 (package-json@2.4.0)
├── hogan.js@2.0.0
├── request@2.74.0 (aws-sign2@0.6.0, tunnel-agent@0.4.3, oauth-sign@0.8.2, forever-agent@0.6.1, caseless@0.11.0, is-typedarray@1.0.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.1, qs@6.2.1, node-uuid@1.4.7, combined-stream@1.0.5, mime-types@2.1.11, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validator@2.0.6)
├── moment@2.14.1
├── lodash@3.10.1
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.30)
└── serialport@3.1.2 (bindings@1.2.1, es6-promise@3.2.1, commander@2.9.0, debug@2.2.0, nan@2.4.0, object.assign@4.0.4)
✔ ~/clack [master L|…2]
16:02 $ /u/ddrucker/node-v4.5.0/bin/particle call dmd fraccon 0,4.5,4.5,0
0
✔ ~/clack [master L|…2]
16:02 $ echo $?
0
✔ ~/clack [master L|…2]
16:02 $ npm install particle-cli@1.14.2 -g --unsafe-perm
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
-
> serialport@3.1.2 install /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build
[serialport] Success: "/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node" is installed via remote
/u/ddrucker/node-v4.5.0/bin/particle -> /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/bin/particle.js
particle-cli@1.14.2 /u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli
├── cli-spinner@0.2.5
├── semver@5.3.0
├── xtend@4.0.1
├── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, strip-ansi@3.0.1, has-ansi@2.0.0)
├── temp@0.8.3 (os-tmpdir@1.0.1, rimraf@2.2.8)
├── cli-table@0.3.1 (colors@1.0.3)
├── glob@4.5.3 (inherits@2.0.1, once@1.3.3, inflight@1.0.5, minimatch@2.0.10)
├── node-wifiscanner2@1.2.0 (os-locale@1.4.0)
├── inquirer@0.11.4 (ansi-regex@2.0.0, strip-ansi@3.0.1, ansi-escapes@1.4.0, rx-lite@3.1.2, through@2.3.8, cli-width@1.1.1, figures@1.7.0, readline2@1.0.1, string-width@1.0.2, cli-cursor@1.0.2, run-async@0.1.0)
├── when@3.7.7
├── form-data@1.0.0-rc4 (async@1.5.2, combined-stream@1.0.5, mime-types@2.1.11)
├── binary-version-reader@0.4.0 (buffer-crc32@0.2.5, h5.buffers@0.1.1)
├── latest-version@2.0.0 (package-json@2.4.0)
├── hogan.js@2.0.0
├── request@2.74.0 (oauth-sign@0.8.2, tunnel-agent@0.4.3, aws-sign2@0.6.0, forever-agent@0.6.1, caseless@0.11.0, is-typedarray@1.0.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.1, qs@6.2.1, node-uuid@1.4.7, combined-stream@1.0.5, mime-types@2.1.11, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validator@2.0.6)
├── moment@2.14.1
├── lodash@3.10.1
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.30)
└── serialport@3.1.2 (bindings@1.2.1, es6-promise@3.2.1, commander@2.9.0, debug@2.2.0, nan@2.4.0, object.assign@4.0.4)
✔ ~/clack [master L|…2]
16:03 $ /u/ddrucker/node-v4.5.0/bin/particle call dmd fraccon 0,4.5,4.5,0
0
✔ ~/clack [master L|…2]
16:03 $ echo $?
0
I don't see the difference between the 2 calls to particle call
. What do you think is going on?
Yeah, see, that's what's weird - from the command line, they both print 0 and have exit status 0 - yet subprocess.call
fails when particle is 1.15.
Note that the subprocess.call
is returning 1 even though particle call
returns 0 when run from the command line, under 1.15.
Hum, mysterious. Let me know if you figure out what is going on.
Here's the error:
/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/lib/interpreter.js:75
if(process.stdout._handle.setBlocking) {
^
TypeError: Cannot read property 'setBlocking' of undefined
at Object.Interpreter.setupTerminal (/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/lib/interpreter.js:75:28)
at Object.Interpreter.startup (/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/lib/interpreter.js:43:8)
at Object.<anonymous> (/u/ddrucker/node-v4.5.0/lib/node_modules/particle-cli/bin/particle.js:19:5)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3
Can you try redirecting stdout to /dev/null instead of passing no handle? It's is a rather strange corner case to run a console program with no stdout.
I get the same error with:
STDOUTFILE = open('/tmp/csastdout', 'w')
[...]
if not call(['/u/ddrucker/node-v4.5.0/bin/particle', 'call', button, 'fraccon', rgb], stdout=STDOUTFILE, stderr=STDOUTFILE):
(in fact, that's how I captured the error in the first place)
The solution is quite clear not to call setBlocking
when process.stdout
has no _handle
. I'm just mystified why your method of calling the process leads to no handle for stdout...
In the meantime, I've changed my code to use check_output
instead of call
, and now it works, so clearly those two methods are handing subtly different things to Popen
.
This issue should be fixed in the newly released 1.17.0.
Thanks. Looks like 9acd33dd128eb486c3d0378ee64492ce4e536785 fixed it.
Particle call fails in 1.15 for me.
Downgrading to 1.14.2 with sudo npm install particle-cli@1.14.2 -g --unsafe-perm
causes the same request to succeed.