Aug 11, 2009

cnetworkmanager 0.21

As I advertised in a previous post, cnetworkmanager got a complete rewrite, and here is a summary of the changes:

v0.21, User visible changes
  • Added screenshots.html.
  • Output in a tabular form (like Tambet's nmcli); --terse/-t to disable.
  • Added --wireless-enabled/--we.
  • Added --con-info.
  • For unimplemented device types, return "unknown", crash not (Kevin Fenzi).
  • Ignore AlreadyAsleepOrAwake error (-o).
  • Flags with zero value now output its name (NONE) instead of nothing.
  • Major rewrite:
  • Created a library wrapping the NM DBus API.
  • Created a generic library wrapping python-dbus.
    (both libraries are still quite messy)
  • Dropped support for NM 0.6.
    (the last trace is in the 'breakup' branch)
  • Connection setting:
    --activate-connection for system settings or another applet
    --connect for exporting a transient connection
  • knetworkmanager (KDE3) config reading dropped
  • Added a (basic) testsuite.
  • Switched to distutils.
BTW, I also pushed the git repo to Github so that you can enjoy the fork graphs. ( stays)


gbin said...

Trying to use the 0.21 in gentoo I have this error trying to connect to a wpa AP :

Traceback (most recent call last):
File "/usr/bin/cnetworkmanager", line 294, in module
c = settings.WpaPsk(ssid, "", options.wpa_psk_hex)
File "/usr/lib64/python2.6/site-packages/networkmanager/applet/", line 130, in __init__
self["802-11-wireless"]["security"] = "802-11-wireless-security"
File "/usr/lib64/python2.6/site-packages/networkmanager/applet/", line 15, in __getitem__
return self.conmap.__getitem__(key)
TypeError: string indices must be integers, not str

I tried guessing the error and made the modification below, it corrects it but it doesn't connect.


--- /root/cnetworkmanager/networkmanager/applet/ 2009-08-12 22:10:45.000000000 +0200
+++ /usr/lib64/python2.6/site-packages/networkmanager/applet/ 2009-08-12 21:23:09.000000000 +0200
@@ -126,7 +127,7 @@
def __init__(self, ssid, key, hashed_key=""):
"One of key, hashed_key must be present"

- super(WiFi, self).__init__(ssid)
+ super(WpaPsk, self).__init__(ssid)
self["802-11-wireless"]["security"] = "802-11-wireless-security"
self["802-11-wireless-security"] = {}
self["802-11-wireless-security"]["group"] = ["tkip", "cselfp"]

Teslas_codpiece said...

Hi there. Great software. Was wondering if you could advise me how I would use cnetworkmanager to restart a 3G/HSDPA adapter.

The adapter is assigned ppp0
It has a profile already created to do the dialling and such. It's also set to automatically dial up.

I just wondered if there is an easy to way to achieve this?

muimota said...
This comment has been removed by the author.
muimota said...

To setup a 3G connection (it works great for me)
cnetwrokmanager --activate-connection user,Simyo,ttyACM0,

1st param=user
2nd param=name of the connection in NetworkManager
3rd param=device

Mokawi said...

I have a small bug report. When I do a "cnetworkmanager -u", get this:

Traceback (most recent call last):
File "/usr/bin/cnetworkmanager", line 240, in <module>
File "/usr/bin/cnetworkmanager", line 236, in list_connections
t.row(active, cs["connection"]["id"], cs["connection"]["type"])
File "/usr/lib/python2.5/site-packages/networkmanager/", line 125, in row
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 8: ordinal not in range(128)

I suspected it was a SSID named "Café du monde En vrac" (note the accent on Café), and I was right. I deleted it with nm-connection-editor, and the output was alright.

Mokawi said...

btw, "module" is between "<" and ">". Blogger thinks it's a html tag, so I tried the &lt/gt + semicolon tag, but apparently it won't work either.

Martin Vidner said...

Mokawi, thanks for the report, I have fixed it in a67ed11b (a release should follow soon).

gbin's issue is already fixed in 0.21.1 (and tracked as Gentoo bug 281099.

Quentin said...

"cnetworkmanager -C" won't find my knetworkmanagerrc.
I could correct the path in the code to ./kde4/config/share/networkmanagementrc but this did not help:

"quentin@linux-d6um:~> cnetworkmanager -C
cnetworkmanager 0.8 - Command Line Interface for NetworkManager
Usage: cnetworkmanager [options]

cnetworkmanager: error: -C option requires an argument"

You should implement the recognition of the new knetworkmanagementrc path.

XG-網頁設計 said...

Great software. thanks

forum-b1online said...

Hi there

Man, this is really a great piece of software. The only thing I am missing is an easy way to change the default route from one interface to another. For example from the eth0 to the wlan0 interface. This is the only thing I am missing and unfortunately I am not skilled enough to write a patch of my own. Therefore I wanted to know whether an implementation might be possible



Peter J said...

Just started using it but very new to linux and python so please excuse what might be a dumb question. There was a query earlier about starting a 3G/HSDPA adapter and a follow-up comment giving a solution of cnetworkmanager --activate-connection user,Simyo,ttyACM0,

A couple of questions.
1) I couldn't find any documentation where the --activate-connection featured. Is there a doc that contains all the commands
2) What is user in this command. My device is wlan0 in network manager and is device ttyhs0 but I receive an error of "Invalid bus name"
3) Is there a deactivate command

My device is ttyhs0 and wlan0 in network manager said...

hey martin, thanks for a great piece of software!

i have to +1 peter's request for more info about --activate-connection. it's the main reason i looked for something like cnetworkmanager in the first place, but i haven't gotten it to work yet.

if i try to use it with a user connection, i get:

purgatory:~> cnetworkmanager --activate-connection=user,0,wlan0,01:23:45:67:89:AB
Traceback (most recent call last):
File "/usr/local/bin/cnetworkmanager", line 319, in
conn = get_connection(svc, conpath)
File "/usr/local/bin/cnetworkmanager", line 211, in get_connection
applet = NetworkManagerSettings(get_service_name(svc))
File "/usr/local/lib/python2.6/dist-packages/networkmanager/applet/", line 37, in __init__
super(NetworkManagerSettings, self).__init__(dbus.SystemBus(), service, self.OPATH, default_interface = self.IFACE)
File "/usr/local/lib/python2.6/dist-packages/dbusclient/", line 40, in __init__
super(DBusMio, self).__init__(conn, bus_name, object_path, introspect, follow_name_owner_changes, **kwargs)
File "/usr/lib/pymodules/python2.6/dbus/", line 241, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/pymodules/python2.6/dbus/", line 183, in activate_name_owner
File "/usr/lib/pymodules/python2.6/dbus/", line 281, in start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/pymodules/python2.6/dbus/", line 620, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManagerUserSettings was not provided by any .service files

if i try with system, i get:

purgatory:~> cnetworkmanager --activate-connection=system,0,wlan0,01:23:45:67:89:AB
Connection '0' not found
Traceback (most recent call last):
File "/usr/local/bin/cnetworkmanager", line 320, in
hint = get_connection_devtype(conn)
File "/usr/local/bin/cnetworkmanager", line 220, in get_connection_devtype
cs = conn.GetSettings()
AttributeError: 'NoneType' object has no attribute 'GetSettings'

i get the same errors regardless of the values i pass for ID, DEV, and APMAC, in all three versions: 0.21.1, head, and github head.

it looks like the last cnetworkmanager change was over 8 months ago. is it still under development?

Konain said...

Can cnetworkmanager be used to disconnect a connection.
I plan to disconnect my internet connection at a particular time. Then connect it after half an hour. Check every half an hour if the connection is up upto say 8 in the morning. If it is down reconnect it. Then finally disconnect it at 8.

Ryan said...

for the record, martin announced last year that he's stopped development on cnetworkmanager in favor of Jirka Klimes's nmcli.