0
我正在编写一个有时使用HTTP下载文件的GTK应用程序。由于我不想阻止正常执行,因此我显然不能使用urllib或Requests,所以我试图使用GIO。但是,通过HTTP下载文件时,我得到GLib.Error: g-io-error-quark: Operation not supported (15)
(file://
正常工作)。使用GLib的GIO API时不支持HTTP
from gi.repository import Gio
print(Gio.File.new_for_uri("file:///etc/profile").load_contents(None))
print(Gio.File.new_for_uri("http://example.org").load_contents(None))
第一条语句(该file://
)按预期工作,但第二个(http://
)给出了上述错误(低于满输出)。在我的真实程序中,我使用异步版本,但同步版本较短并且出现相同的错误。
(True, contents=b'# /etc/profile\n\n [-snip-]')
Traceback (most recent call last):
File "/tmp/gio.py", line 3, in <module>
print(Gio.File.new_for_uri("http://example.org").load_contents(None))
GLib.Error: g-io-error-quark: Operation not supported (15)
似乎它是Arch上的'gvfs'。 – Caagr98