"window.project()" will tell you if a project is open
"window.project().fileName()" will tell you its path
I don't think it's documented, so it's possible it changes in the future.
Anyways, you can get more hidden info like that by introspecting variables. Try "dir(window)" and "dir(window.project())"