Ignition Install Path from G Script?

Is there a way to determine the Ignition installation path from a gateway script?

I guess this is a good start context.getServletContext().getRealPath('/')

Try:

import os
print os.getcwd()

Thanks again… that was easy.

Here is a class that I use to download activemq-all-xxx.jar from maven if not in lib/core/gateway.

AMQLibDownloader().Download('activemq-all')
from java.lang import Exception
from java.io import IOException
from java.nio.file import Paths
from java.net import URL
from org.apache.commons.io import FileUtils
import sys
import os

class AMQLibDownloader():
	def __init__(self):
		self._logger = system.util.getLogger('activemq.AMQLibDownloader')
		self._localGatwayCoreRelativePathString = "//lib//core//gateway"
		
	def _buildLatestMavenUrl(self,artifactId):
		try:
			searchUrl = "http://search.maven.org/solrsearch/select?q=%s&rows=1&wt=json" % artifactId
			json = system.net.httpGet(searchUrl)
			dict = system.util.jsonDecode(json)
			artifact = dict['response']['docs'][0]
			url = "http://%s.maven.org/maven2/%s/%s/%s/%s-%s.%s" \
				% (artifact['repositoryId'],artifact['g'].replace('.','/'),artifact['a'],artifact['latestVersion'],artifact['a'],artifact['latestVersion'],artifact['p'])
			return url, artifact
		except Exception, ex:
			self._logger.error("unable to build maven url for artifactId: '%s'" % artifactId)
			self._logger.info(str(ex))
			return None, None
		
	def Download(self,artifactId,force=False):
		mavenUrl, mavenArtifact = self._buildLatestMavenUrl(artifactId)
		
		if mavenUrl is not None:
			gatewayCorePath = Paths.get(os.getcwd() + self._localGatwayCoreRelativePathString)
			libraryLocalPath = Paths.get(gatewayCorePath.toString() + "//%s-latest.%s" % (mavenArtifact['a'],mavenArtifact['p'])).toFile()
			libraryRemotePath = URL(mavenUrl)
			
			if not force:
				if not system.file.fileExists(libraryLocalPath.toString()):
					force = True
					self._logger.warn("'%s' was not found" % libraryLocalPath.toString())
				else:
					pass
					# get local SHA
					# search maven by SHA
					# compare local version against latest version
					# update if mavent has newer version => set force=True
					
			else:
				self._logger.info("'%s' download forced" % libraryRemotePath.toString())
				
			if force:
				try:
					self._logger.info("downloading '%s' => '%s'" % (libraryRemotePath.toString(), libraryLocalPath.toString()))
					FileUtils.copyURLToFile(libraryRemotePath, libraryLocalPath)
					sys.path.append(libraryLocalPath.toString()) #manual append until gateway is rebooted
					self._logger.info('done')
				except IOException, iex:
					self._logger.error(iex)
				except Exception, ex:
					self._logger.error(ex)