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

output 属性は 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 に答える