1

我有一个 Twilio CLI 命令,我希望在 Raspberry Pi 上使用 Python os.system() 运行它,但是它不能正常运行......说它遇到错误。

我也不明白调试消息...

当前代码如下所示:

command_string = '/home/pi/.config/nvm/versions/node/v16.13.1/bin/twilio phone-numbers:update ' +my_number+ ' --sms-url=http://localhost:5000 -l debug'

os.system(command_string)

Python 脚本运行良好,但我不断收到上述命令的以下结果:

[DEBUG] Config File: /root/.twilio-cli/config.json
[DEBUG] Using profile: ${TWILIO_ACCOUNT_SID}/${TWILIO_AUTH_TOKEN}
[DEBUG] -- BEGIN Twilio API Request --
[DEBUG] GET https://api.twilio.com/2010-04-01/Accounts/TWILIO_ACCOUNT_SID/IncomingPhoneNumbers.json
[DEBUG] Querystring:
[DEBUG] {"PhoneNumber":"NUMBER"}
[DEBUG] Custom HTTP Headers:
[DEBUG] User-Agent: twilio-cli/2.35.0 @twilio/cli-core/5.32.2 (linux arm) twilio-node/3.71.3 node/v16.13.0 phone-numbers:update
[DEBUG] -- END Twilio API Request --
[DEBUG] response.statusCode: 200
[DEBUG] response.headers: {"date":"Sun, 12 Dec 2021 19:03:24 GMT","content-type":"application/json; charset=utf-8","content-length":"1585","connection":"close","twilio-concurrent-requests":"1","twilio-request-id":"RQ1c8c8551e33b2b8efaf2a3e93ce84050","twilio-request-duration":"1.085","access-control-allow-origin":"*","access-control-allow-headers":"Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since","access-control-allow-methods":"GET, POST, DELETE, OPTIONS","access-control-expose-headers":"ETag","access-control-allow-credentials":"true","x-powered-by":"AT-5000","x-shenanigans":"none","x-home-region":"us1","x-api-domain":"api.twilio.com","strict-transport-security":"max-age=31536000"}
[DEBUG] Found command "phone-numbers:update" plugin: twilio-cli
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg="no configuration paths supplied"
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg="ignoring default config path, could not stat it" path=/root/.ngrok2/ngrok.yml err="stat /root/.ngrok2/ngrok.yml: no such file or directory"
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg="starting web service" obj=web addr=127.0.0.1:4040
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg=start pg=/api/tunnels id=9ba04b3a3b59fd8f
t=2021-12-13T03:03:25+0800 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=9ba04b3a3b59fd8f err="a successful ngrok tunnel session has not yet been established"
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg=end pg=/api/tunnels id=9ba04b3a3b59fd8f status=503 dur=1.646498ms
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg=start pg=/api/tunnels id=38085fdc657c6c64
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=38085fdc657c6c64 err="a successful ngrok tunnel session has not yet been established"
t=2021-12-13T03:03:25+0800 lvl=info msg=end pg=/api/tunnels id=38085fdc657c6c64 status=503 dur=829.471µs
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg=start pg=/api/tunnels id=1d29d31d96b0c316
t=2021-12-13T03:03:25+0800 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=1d29d31d96b0c316 err="a successful ngrok tunnel session has not yet been established"
t=2021-12-13T03:03:25+0800 lvl=info msg=end pg=/api/tunnels id=1d29d31d96b0c316 status=503 dur=494.549µs
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=info msg=start pg=/api/tunnels id=541085ca341447c1
[DEBUG] ngrok: t=2021-12-13T03:03:25+0800 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=541085ca341447c1 err="a successful ngrok tunnel session has not yet been established"
t=2021-12-13T03:03:25+0800 lvl=info msg=end pg=/api/tunnels id=541085ca341447c1 status=503 dur=900.748µs
[DEBUG] ngrok: t=2021-12-13T03:03:26+0800 lvl=info msg=start pg=/api/tunnels id=894e9ee1a0583b59
[DEBUG] ngrok: t=2021-12-13T03:03:26+0800 lvl=info msg="tunnel session started" obj=tunnels.session
t=2021-12-13T03:03:26+0800 lvl=info msg="client session established" obj=csess id=fe7aff6afc5d
[DEBUG] ngrok: t=2021-12-13T03:03:26+0800 lvl=warn msg="failed to start tunnel" pg=/api/tunnels id=894e9ee1a0583b59 err="You must signup for ngrok and add your authtoken to perform this operation.\n\nSign up for an account: https://dashboard.ngrok.com/signup\nInstall your authoken: https://dashboard.ngrok.com/get-started/your-authtoken\r\n\r\nERR_NGROK_4018\r\n"
[DEBUG] ngrok: t=2021-12-13T03:03:26+0800 lvl=info msg=end pg=/api/tunnels id=894e9ee1a0583b59 status=502 dur=391.989355ms
[DEBUG] Found command "phone-numbers:update" plugin: twilio-cli
 » twilio-cli encountered an unexpected error. To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: "https://github.com/twilio/twilio-cli/issues"
[DEBUG] Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
[DEBUG] TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
    at JSON.stringify (<anonymous>)
    at NumberUpdate.createTunnel (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/src/commands/phone-numbers/update.js:94:51)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NumberUpdate.run (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/src/commands/phone-numbers/update.js:48:9)
    at async NumberUpdate._run (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/node_modules/@oclif/config/lib/config.js:173:24)
    at async Main.run (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/main.js:27:9)
    at async Main._run (/home/pi/.config/nvm/versions/node/v16.13.1/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)

结果,我无法接收来自 Twilio 的短信...

关于如何使这项工作的任何想法?

4

2 回答 2

1

ngrok 的产品经理在这里。为了遏制对平台的滥用,我们现在要求所有提供 HTML 内容的用户都必须拥有一个免费帐户。您将需要在 ngrok.com 上注册一个免费帐户,并将您的 authtoken 添加到您的 ngrok 配置文件或 Phil 所描述的命令行标志中,即使您使用其中一个 ngrok 库也是如此。如果您有任何问题或疑虑,请联系 ngrok 支持!谢谢!

于 2021-12-13T16:39:09.083 回答
1

Twilio 开发人员布道者在这里。

这里的输出中有来自 ngrok 的错误,上面写着:

You must signup for ngrok and add your authtoken to perform this operation.

Sign up for an account: https://dashboard.ngrok.com/signup
Install your authoken: https://dashboard.ngrok.com/get-started/your-authtoken

ERR_NGROK_4018

因此,您似乎需要注册一个免费的 ngrok 帐户提供您的 authtoken


您似乎在围绕 Python 和 Twilio CLI 编排此应用程序时遇到了一些麻烦。您可能会发现这完全在 python 中更容易处理。有一个Twilio Python 库和一个ngrok Python 库,您可以将它们组合起来以启动隧道并在应用程序中更新电话号码的 URL。

于 2021-12-13T00:06:57.213 回答