Python script to manage the quorum with 2 servers HA cluster

no, it is not safe as it throws out all the safeguards and violates basic assumptions of a PVE cluster.
 
use a quorum device, if the quorum device goes down your remaining two nodes are still quorate.. of course if the quorum device and a node goes down your back to square one but at least still in safe territory..
 
it mainly has the advantage of not having a chance of starting any guests on two nodes at the same time, which is a huge mess in almost every regard..