How to run appium from my python code?

Hi,

I am using python 3.7 for my test on android real devices.

I’d like to detect from my python code the connected real devices, and then detect the desired capabilities In order to run appium from my code… and then run the code on several real devices.

The idea is to handle everything from python code:

detect devices,
detect platform, name, serial, etc (the desired caps)
start appium
and then start the test code on 2 connected real devices.
Anyone has already done that in the past? Do you know any tuto?