python-sdbus / python-sdbus-networkmanager

python-sdbus binds for NetworkManager
GNU Lesser General Public License v2.1
30 stars 6 forks source link

Add from_settings_dict() to read a dict without signatures #22

Closed bernhardkaindl closed 2 years ago

bernhardkaindl commented 2 years ago

A simple settings dict uses the same keys as from_dbus() and to_dbus() but without the dbus variable signatures used by NetworkManader.py

This means a simple settings dict does not use the underscore in keys like the attributes of this class have to use and use "id" and "type".

Also adds a simple test case which tests the conversion from the simple settings dict and can also test adding a wireless connection (unsaved, not with autoconnect) which is also deleted by the test.

bernhardkaindl commented 2 years ago

@igo95862 Method to create a settings profile from a simple dict without signatures - I need this for my RPC server to create (and modify) with input data being a simple JSON which I convert to this simple settings dict which this new method reads.

igo95862 commented 2 years ago

I need this for my RPC server to create (and modify) with input data being a simple JSON

I am curious what does your RPC server do.

igo95862 commented 2 years ago

Also I wonder if the JSONDecoder can be leveraged here.

bernhardkaindl commented 2 years ago

The RPC server gives info about NetworkManager's connections, configures them from remote and more. Of course a simple dict is easy to convert to/from JSON using json.loads() and json.dumps(). I'm using the xjsonrpc package for RPC which does this internally.