[PATCH 1/3] Define a DEFAULT_DBUS_TIMEOUT constant and use it
Vratislav Podzimek
vpodzime at redhat.com
Mon Apr 1 14:22:02 UTC 2013
-1 is a weird magic value
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/constants.py | 3 +++
pyanaconda/nm.py | 16 +++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index bb59afc..4310bf1 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -101,6 +101,9 @@ RUNLEVELS = {3: 'multi-user.target', 5: 'graphical.target'}
# Network
NETWORK_CONNECTION_TIMEOUT = 45 # in seconds
+# DBus
+DEFAULT_DBUS_TIMEOUT = -1 # use default
+
# Thread names
THREAD_EXECUTE_STORAGE = "AnaExecuteStorageThread"
THREAD_STORAGE = "AnaStorageThread"
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index 8efe388..fa06dbe 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -24,6 +24,8 @@ from gi.repository import NetworkManager
import struct
import socket
+from pyanaconda.constants import DEFAULT_DBUS_TIMEOUT
+
device_type_interfaces = {
NetworkManager.DeviceType.ETHERNET: "org.freedesktop.NetworkManager.Device.Wired",
NetworkManager.DeviceType.WIFI: "org.freedesktop.NetworkManager.Device.Wireless",
@@ -103,7 +105,7 @@ def nm_devices():
devices = proxy.call_sync("GetDevices",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
devices = devices.unpack()[0]
@@ -145,7 +147,7 @@ def nm_device_property(name, property):
device = proxy.call_sync("GetDeviceByIpIface",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
except Exception as e:
if "org.freedesktop.NetworkManager.UnknownDevice" in e.message:
@@ -304,7 +306,7 @@ def _find_settings(value, key1, key2, format_value=lambda x:x):
connections = proxy.call_sync("ListConnections",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
for con in connections.unpack()[0]:
@@ -313,7 +315,7 @@ def _find_settings(value, key1, key2, format_value=lambda x:x):
settings = proxy.call_sync("GetSettings",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
settings = settings.unpack()[0]
try:
@@ -348,7 +350,7 @@ def nm_device_setting_value(name, key1, key2):
settings = proxy.call_sync("GetSettings",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
settings = settings.unpack()[0]
try:
@@ -386,14 +388,14 @@ def _update_settings(settings_path, key1, key2, value, default_type_str=None):
settings = proxy.call_sync("GetSettings",
args,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
new_settings = _gvariant_settings(settings, key1, key2, value, default_type_str)
proxy.call_sync("Update",
new_settings,
Gio.DBusCallFlags.NONE,
- -1,
+ DEFAULT_DBUS_TIMEOUT,
None)
def _gvariant_settings(settings, updated_key1, updated_key2, value, default_type_str=None):
--
1.7.11.7
More information about the anaconda-patches
mailing list