How can I uniformly modify a pipe with coding?
It may be that you need nothing more than a proportional edit, set to 'Linear' profile, and in 'Connected' mode. 

With Median Point as your pivot, select an edge loop at one end of your pipe. The extent of the scaling along normals (AltS) will depend not on the geometric distance from your selection, but on the topological distance (the total edge-length from your selection).. so it works round corners, linearly tapering as you go. 

The circle in the 3D view may no longer be a visual indicator of extent - just keep growing it until you begin to see the influence at the other end of your pipe.