python: Connect to device iff needed