Skip to content

Conversation

@andrey-pr
Copy link
Contributor

No description provided.

@igo95862
Copy link
Collaborator

Thank you for submitting pull request. Allow me to review it.

@andrey-pr
Copy link
Contributor Author

How to allow?

@andrey-pr
Copy link
Contributor Author

Resolved issues

@andrey-pr
Copy link
Contributor Author

Pls review again

@igo95862
Copy link
Collaborator

Pls review again

Could you do the args unpacking?

It would be asyncio.run(add_vpn_connection_async(**vars(args))). This allows for better typing as there will be explicit keywords instead of opaque args.

@andrey-pr
Copy link
Contributor Author

It would be asyncio.run(add_vpn_connection_async(**vars(args))). This allows for better typing as there will be explicit keywords instead of opaque args.

Ok, but how to accept this kind of arguments in function?

@igo95862
Copy link
Collaborator

igo95862 commented Jul 21, 2023

Ok, but how to accept this kind of arguments in function?

Add the keyword arguments matching the args attributes.

For example, there is args.conn_id so the keyword argument would be conn_id: str.

The function would look like this:

async def add_vpn_connection_async(
   conn_id: str,
   dev: str,
   ...............
) -> str:

Instead of ............... are all the keywords that args has.

Probably better to use default=str(uuid4()) straight away so it the type can simple be str.

@andrey-pr
Copy link
Contributor Author

Fixed

@andrey-pr
Copy link
Contributor Author

I have one question about further library usage. How to connect existing connection?

@igo95862
Copy link
Collaborator

igo95862 commented Jul 21, 2023

I have one question about further library usage. How to connect existing connection?

Probably using NetworkManager.activate_connection.

@igo95862 igo95862 merged commit 76a3c2c into python-sdbus:master Jul 21, 2023
@andrey-pr
Copy link
Contributor Author

Probably using NetworkManager.activate_connection.

I can not understand how to create object of NetworkManagerInterfaceAsync. Can you show me some example how to do it?

@igo95862
Copy link
Collaborator

igo95862 commented Jul 21, 2023

Probably using NetworkManager.activate_connection.

I can not understand how to create object of NetworkManagerInterfaceAsync. Can you show me some example how to do it?

Just use the NetworkManager class. It inherits from NetworkManagerInterfaceAsync.

The difference is NetworkManager is an object that automatically proxies to /org/freedesktop/NetworkManager and NetworkManagerInterfaceAsync is an interface class that has all the methods and properties definitions.

So it would look something like this:

nm = NetworkManager()
nm.activate_connection(vpn_connection_path, "/", "/")

@andrey-pr
Copy link
Contributor Author

It works. Thank you.

await nm.activate_connection(vpn_connection_path, "/", "/")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants