The
joystick.py example script exits if a DirectInput device is not connected:
If both the display and sensor cables of the Oculus are not connected
getSensor will return None:
Code:
import oculus
hmd = oculus.Rift()
if hmd.getSensor() is None:
print 'Rift not connected'