1

...在 Ubuntu 10.04 上使用 AutoKey 0.81.4

  1. 相对较新的 Linux(<1 年)
  2. 这是我写的第一个python

AutoKey 的以下脚本一直失败并出现以下错误。我没有得到什么?

Script name: 'find files script'
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/autokey/service.py", line 442, in execute
    exec script.code in self.scope
  File "<string>", line 13, in <module>
AttributeError: 'CalledProcessError' object has no attribute 'output'

剧本

import time

time.sleep(0.10)
retCode, args =  dialog.input_dialog("Files to Find","enter a file name")
fmt = "find / -name \"{0}\" -type f -print 2>/dev/null "
if retCode == 0:
    if len(args) > 0:
        cmd = fmt.format(args)
        #dialog.info_dialog(title="the command",message=cmd)
        try:
            rc = system.exec_command(cmd, getOutput=True)
        except subprocess.CalledProcessError, e:
            dialog.info_dialog(title="the return",message=str(e.output))
4

2 回答 2

0

输出属性直到 Python 2.6 才存在。您可以使用 subprocess.Popen 和communicate()。或者您可以在this之后反向移植 subprocess.check_output(也不是 2.6)。

于 2015-07-16T14:12:39.790 回答
-1

将 e.output 更改为仅 e。使用 str(e) 将为您提供错误字符串。您可能需要查找异常以找出它们支持的属性。我不认为输出是其中之一。

于 2012-01-08T22:17:45.463 回答