This is more of a lesson share than a question, but I thought someone might find this helpful. I am trying to manage projects for a number of Gateways from a single “parent” Gateway. I would like all of these projects disabled at the parent so they aren’t running erroneous scripts, but I need them re-enabled when I push them to the daughter Gateways. Unfortunately, EAM respects the project enabled attribute, so I have resorted to doing this with scripting through a message handler (this would be a nice addition when pushing projects using EAM).
from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
projectManager = context.getProjectManager()
project = projectManager.getProject(projectName).get() # Need to get() from the java "Optional" object
resources = list(project.getAllResources().values())
manifest = project.getManifest()
# Need to make sure project is enabled
jsonManifest = system.util.jsonDecode(manifest.toJson(manifest))
jsonManifest['enabled'] = True
manifest = manifest.fromJson(system.util.jsonEncode(jsonManifest))
Now you would just need to package these up into an object and send it to the remoteGateway where you could use something like ProjectManager.createOrReplaceProject(projectName, manifest, resources).
The same thing could be accomplished using the file system and editing the project.json file, but this seemed a bit more straightforward.
@williamsr.andrew Thanks for sharing this, I was working on a method to compare project details between an “alpha” and “prod” gateway, and was trying to figure out the best way to get the project manifest data. Your code snippet helped me get that working.
I was hoping that the project manifest would contain some of the “project edit” information that can be seen in the designer launcher and gateway config pages (author, last edited by, last edit time, etc). Do you know if there is any way to access this info via scripting in the gateway context? I’ve dug around in the docs for RuntimeProject object but I haven’t had any luck so far.
I haven’t really looked into the project change tracking that you are talking about, but it does look like RuntimeProject should be able to do something like this. The diff function looks like it should do what you want, you would just need to compare the prod version of the project to the updated dev version.
Right now I am just tracking changes manually. Each of my projects has a version Project Script where I keep a handful of variables like author, last modified date, and a changelog dictionary. Obviously it becomes an issue if you forget to update this, but I figure its better than nothing. You could then either import the file to access those variables, or read in the file and search for those variables.
This discussion has sparked me to look into using git for project change/version control, and it looks like there has been quite a bit of discussion around it already. If you really want to be more rigorous in change management, this would definitely be something to look into further: