收录日期:2021/01/28 16:52:34 时间:2010-03-31 04:37:41 标签:python,linux,dbus

Is there a way using Python to simulate the presence of an active network connection using dbus? If I call getstate() on the dbus, I'm able to get the current network state. I want to set the current state to 4 (Connection Present). This is because Network Manager is not able to connect using my modem and I use other tools to connect. Pidgin, Empathy and other software are not able to detect the network.

I'm pretty sure that both Pidgin and Empathy assume you're online if you disable NM by right-clicking the Network Manager tray icon and untick Enable Networking. So you can do this when you're connecting via a non-NM mechanism. No code necessary!

(You could write an application which implements the same D-Bus interface as NetworkManager, sits on the system bus, and pretends to be online, and then when you want to use your network kill the real NetworkManager program and start your fake one, but that smells like overkill to me...)

Your options are to write something that mocks NetworkManager's D-Bus interface, or to write a module for NetworkManager that supports the tools you use.