Hmm. Something like this (untested):
from com.inductiveautomation.ignition.common.model import ApplicationScope
scope = ApplicationScope.getGlobalScope()
if (ApplicationScope.isClient(scope)):
...
if (ApplicationScope.isDesigner(scope)):
...
if (ApplicationScope.isGateway(scope)):
...