Best methods for checking script scope

Try this:

	def getScope():
		"""
		Returns:
			scope (int): 0=Gateway, 1=Client, 2=Designer
		"""
		try:
			if system.util.getSystemFlags() & system.util.CLIENT_FLAG:
				location = 1
			elif system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
				location = 2
		except AttributeError:
			# system.util.getSystemFlags() does not exist in gateway scope
			location = 0
		return location

(Source: Which scope is my code running in?)

4 Likes