python - 如何使用 Automator 运行 python 脚本以查看调试/错误消息?

标签 python shell terminal automator

目前,如果我使用 Run shell script 并在那里启动 python 脚本:

/usr/bin/python /Users/myuser/script.py "$1"

如果由于发生异常而导致脚本执行失败,Automator 将返回错误,但什么也没说:

Run Shell Script failed - 1 error
Traceback (most recent call last):

有什么方法可以运行 shell 脚本来查看所有调试消息(或者,运行终端并在那里运行 python 脚本)?

最佳答案

我相信您最好的前进方式是使用 Python 调试器:

import pdb

pdb.set_trace()

在你的 py 脚本中。

更多信息在这里:

https://docs.python.org/2/library/pdb.html

关于python - 如何使用 Automator 运行 python 脚本以查看调试/错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23359901/

相关文章:

linux - ssh 远程命令源交互式启动脚本

bash - fish shell : Weird exit command behaviour from terminal

python - 使用 minidom 解析 Bash 导出变量,Python 出错

python - 如何使用python限制同一字母的最长序列

Python - 如何跳过特定的 JSON 元素?

linux - 压缩目录的 Shell 脚本

linux - 从 shell 启动程序时是否可以分配窗口 ID?

Ruby命令行脚本不连续执行代码

terminal - 尝试将 echo 的输出传递到 mkdir 命令

Python LDAP 将 objectGUID 转换为十六进制字符串并返回