Connectivity check script in python turning lights on in raspberry