You mentioned that the solution doesn't have to be in Python, so you can just use a Bash script for this (given that you can ping the server):
#!/usr/bin/env bash
COUNTER=$1
SERVER=$2
COMMAND="sudo reboot"
SLEEP_DURATION=60
echo "Working on $SERVER $COUNTER times"
while (( $COUNTER > 0 )); do
ping -c 1 -t 5 $SERVER;
_ping_r=$?
if (( $_ping_r < 1 )); then
echo "Rebooting $SERVER"
ssh $SERVER $COMMAND;
let COUNTER=COUNTER-1
else
echo "Couldn't ping $SERVER. Taking a quick nap and trying again."
sleep 5
fi
sleep $SLEEP_DURATION;
done
echo "Done working on $SERVER"
Save it in something like command_runner.sh
and simply call it via ./command_runner.sh 2 server.example.org
on a workstation that can SSH and run reboot on the server.