How can I use a Python script to control the velocity and direction of motion of a conveyor belt while it is running?

I want to set up a simulation environment to move boxes from a single source to multiple destinations. To achieve this, I need to change the movement of the conveyor belt while it is running to divert boxes from one conveyor to another based on certain decisions. How can I use a Python script to control the velocity and direction of motion of the conveyor belt in this scenario?