Export project scripts in text mode

Is there a way to export the project scripts in a readable text format instead of the binary 64 bits encryption?

Thanks.

Hi,

Yes, that is what the pa.project.getProjectScriptModules function is for. It gets you the text of all the Python project scripting library modules. Once you get the text you can write it to files or do whatever you want with it.

Examples:#Getting all the project script modules modules = pa.project.getProjectScriptModules() #Getting a couple project script modules modules = pa.project.getProjectScriptModules(["util","perfectchat.nav"])This function is part of the PA Power Scripting module.
Links:
marketplace.inductiveautomation. … oduleId=87
nickmudge.info/post/pa-power-scripting-module
doc.perfectabstractions.com/modu … index.html

Best,

There isn’t a way to easily do this now, but it’s something that can be looked at in the future. Out of curiosity, what is the use case? Just to be able to read the scripts outside of ignition, or do you have some specific need?

Using the “pa.project.getProjectScriptModules()” function is pretty easy.

First of all, Thanks Nick for the PA module. I tested it and it works. My only concern is that it can be interesting if the addProjectScriptModule may have an option to overwrite an existing module. Currently if I add a module script with an existing name, the name is duplicated.

Hi Perry,

The use case is that we need a source control management tool for scripts. Currently develop many projects with a huge number of scripts and with many developers on the same project. It is not easy if not impossible to track historic of changes inside the designer. So, we want to extract the scripts code from Ignition project to link them with our sources control software. With that,we are able to see the historic of each scripts and compare versions. It will be great if we can extract all scripts from components also.

Sincerely,

Pierre

Hi Pierre,

Great to hear it is working for you. Yes, I agree, I should add an option to the addProjectScriptModule function for overwriting existing modules that have the same path/name. Thanks for pointing that out. I’m not sure when but I will make that change.

Here is another possible approach to doing what you want to do with source control for scripts:
Write all your Python scripts outside Ignition in your favorite text editor and store them in files in your source control system. Use those Python modules in Ignition.

Your various event scripts could just make a single function call to functions in your Python modules that are written and stored outside of Ignition.

Check out this blog post that tells how to do this:
perfectabstractions.com/blog … on-modules

Here is a quote from it:

[quote] Ignition 7.7 provides a way to write Python modules outside Ignition in your favorite text editor or IDE and immediately use those modules in Ignition. Your Python scripts can even access and manipulate windows and components in the designer and in clients.

On Linux, Python module files are put in this directory: /var/lib/ignition/user-lib/pylib/. On windows, Python module files are put under the C:\Program Files\Inductive Automation\Ignition\user-lib\ directory.

When changes are made to a Python module file the changes are picked up right away by Ignition and the code is reloaded in the Gateway and the designer and a project update is sent to any open clients.

This is an awesome new way to write Python module libraries for Ignition. It also opens the door to using version control systems with Python libraries used in Ignition.

Of course third-party Python libraries written by others can also be added to the pylib directory.
Python module files that are added to the pylib directory are included in Gateway backups. [/quote]Best,

[quote]Using the “pa.project.getProjectScriptModules()” function is pretty easy.
[/quote]

Nick,

Got me there, should have said “…no easy built-in way”.

Pierre,

Nick’s solution of having an external python lib is one I have seen used before and is a pretty good workaround, though something more native could streamline editing and testing.

Versioning/source control is on our radar. System-wide version control in the form of git or mercurial probably isn’t something we’ll be able to support due to how projects are encoded and stored, but adding tools to support scripts is something we can take a look at.

This idea in our ideas forum seems pretty close to what you are looking for: ideas.inductiveautomation.com/fo … with-the-a

Scripting is an area we will continue to improve, feedback/ideas are always welcome and appreciated.

Hi,

Is it possible to make the same (Export) with all component script in Ignition project ?

Do you have a sample project with getProjectScriptModules in it?
Thank you
Danny

Oki it’s just for the client script