【问题标题】:How to unmount based on volume type using Python GIO library如何使用 Python GIO 库根据卷类型卸载
【发布时间】:2020-02-14 23:13:51
【问题描述】:

我正在尝试模仿 shell 命令 gio mount 的行为,该命令会卸载所有 gphoto2 相机

gio mount -s gphoto2

如何检测音量是否为gphoto2?我尝试获取音量类型,但似乎没有保持它的变量,

from gi.repository import Gio, GObject

def main():
    mo = Gio.MountOperation()
    mo.set_anonymous(True)

    vl = Gio.VolumeMonitor.get()

    loop = GObject.MainLoop()

    for v in vl.get_mounts():
        print(dir(v))
        print(v.get_name(), v.get_uuid(), v.g_type_instance, v.get_drive(),
              v.get_volume(),
              v.get_root(),
              v.get_drive(),
              v.get_sort_key(),
              v.get_uuid())

【问题讨论】:

    标签: python gio


    【解决方案1】:

    【讨论】:

    • 谢谢,我知道了if v.get_root().has_uri_scheme("gphoto2"): print("yes")
    猜你喜欢
    • 1970-01-01
    • 2015-06-27
    • 2021-12-25
    • 2016-10-18
    • 1970-01-01
    • 2023-03-15
    • 2011-11-25
    • 1970-01-01
    • 2016-08-28
    相关资源
    最近更新 更多