[ipython] Do some sanity checks before starting the console

* Even if IPython is not installed, restore sys.stdout (Python 3 only)
* Prevent starting the console without a tty (ie. prevent starting the
console when the shell is detached)
* Prevent starting the console when running as a deamon