app.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:PyDbusNetworkManager 作者: stoic1979 项目源码 文件源码
def get_active_connection_info(self, ac_path):
        bus = dbus.SystemBus()
        wifi = bus.get_object('org.freedesktop.NetworkManager', ac_path)

        iface = dbus.Interface(wifi, dbus_interface='org.freedesktop.DBus.Properties')

        # creating proxy 'Get' method
        m = iface.get_dbus_method("Get", dbus_interface=None)

        # getting Id of active connection
        Id = m("org.freedesktop.NetworkManager.Connection.Active", "Id")

        # getting Type of active connection
        Type = m("org.freedesktop.NetworkManager.Connection.Active", "Type")

        # getting Uuid of active connection
        Uuid = m("org.freedesktop.NetworkManager.Connection.Active", "Uuid")

        # getting State of active connection
        State = m("org.freedesktop.NetworkManager.Connection.Active", "State")

        # NOTE:
        # this function only returns properties like Id, Type, Uuid, State of an active connection
        # However, other properties like Dhcp4Config, Dhcp6Config, Ip4Config, Ip6Config etc. can also be obtained
        return (str(Id), str(Type), str(Uuid), int(State))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号