Script Console Browse for Tag Providers

HI,

I use the following code to browse for a list of tag providers:

def getProviders():
	providers = system.tag.browse('')
	targetProviders = []
	for provider in providers.getResults():
		targetProviders.append(provider['name'])
	
	return targetProviders

This works when tag change script or a Perspective session calls this, but doesn’t when called from the script console.

I need to use this for some tag maintenance where I browse the gateway and search for some issues.

Any reason why it doesn’t work from the designer script console context and is there an alternative way of getting a list of all providers?

Regards,
Deon

1 Like

Hi,
i use this code inside a button… i don’t know if useful for you

context = event.source.getAppContext()

provs = []
tm = context.getTagManager()
provprops = tm.getProviderProperties()
for p in provprops:
	provs.append(p.getName())
 
print provs
1 Like

Hi

Do you know how to get provs list in perspective session?
There is no event.source.getAppContext in perspective

It was quicker to make a list by hand.

My automated tag maintenance scripts run on tag change events, so there the blank browse technique still works.

I’m interested in the solution, though.

Perspective scripts run in the gateway, so you’d need the GatewayContext (aka IgnitionGateway) instead of the VisionClientContext you get from a component. The rest would be the same.

1 Like

Thanks Phil

What about from the Designer's Script Console? How would I get a DesignerContext object reference?

Using the GatewayContext as an example, this doesn't work for the DesignerContext:

from com.inductiveautomation.ignition.designer.model import DesignerContext
context = DesignerContext.get()

I've also always been confused how I would know about the "get" method of the GatewayContext object, as this isn't in the javadocs?

The get method is on IgnitionGateway, a deliberately undocumented internal "implementation" class. The static getter on it is a big code-purity no-no, but mostly okay for our environment.

If you're using Ignition Extensions, there's a system.util.context getter already. The generic equivalent of IgnitionGateway in the designer is the IgnitionDesigner (or something like that) class, which has a static getFrame method that returns the instance.

Note that relying on any of these is at least a code smell to be aware, since theoretically any of these methods could go away on any Ignition upgrade.

1 Like

Cool, i forgot about the system.util.context function, cheers. This is purely for dev stuff, like summarising tags per provider, so if it breaks it only inconveniences me

I also added system.util.toolkitCtx() to my Integration Toolkit module to get the module context (which a wrapped gateway, designer, or vision client context).

1 Like

Hi, Are you able to fetch the tag provider details in perspective, I'm also having a similar kind of requirement, Does anyone find any scripts for the same?

What details are you looking for?

You should be able to use this (which is further up this topic) to see what other properties you can read

If you are searching for getting the tag providers list for perspective, to find the default tag provider for the project, then may be u can try this.

config =  system.tag.getConfiguration()
for row in config:
	prov = str(row['path'])
	print row