class
ScriptProjects.
ScriptProjects
Bases: object
The ScriptDriverProjects uses this interface to provide project handling functionality for the python scripts.
create
path
primary=True
Creates a new project.
path (str) -- The location where the project content is to be stored.
primary (bool) -- if set to True the project will be the new primary project. See ScriptProject.primary for more information.
The created ScriptProject instance.
open
path
password=None
primary=True
encryption_password=None
session_user=None
session_password=None
update_flags='VersionUpdateFlags.NoUpdates'
allow_readonly=False
Opens the specified project.
WARNING | |
---|---|
If the password is omitted, None or empty string, opening a password protected archive will prompt the user for a password.
For the update_flags parameter, the VersionUpdateFlags.SilentMode is usually combined with one or more of the Update... flags defined in the VersionUpdateFlags enum. If you only pass some Update... flags without the VersionUpdateFlags.SilentMode flag, they will be used as initial values when the update dialog pops up. To silently update everything, you can pass the combination VersionUpdateFlags.SilentMode|VersionUpdateFlags.UpdateAll.
path (str) -- The path of the project file to open.
password (str) -- The password for the project encryption.
primary (bool) -- if set to True, open as primary project. See ScriptProject.primary for more information.
encryption_password (str) -- Version added: 3.5.5.0 The project encryption password.
session_user (str) -- Version added: 3.5.5.0 The project session user (project usermanagement).
session_password (bool) -- Version added: 3.5.5.0 The project session password (project usermanagement).
update_flags (VersionUpdateFlags) -- Version added: 3.5.8.0 The flags telling whether some aspects (libraries, compiler version) ought to be updated when the project is loaded. The default is to silently update nothing.
session_password -- Version added: 3.5.8.0 If set to True, allow the project to be opened as read-only.
The opened project.
open_archive
archivefile
projectpath
overwrite=False
password=None
encryption_password=None
session_user=None
session_password=None
update_flags='VersionUpdateFlags.NoUpdates'
prompt_absolute_path=None
Opens a project archive.
The parameter projectpath will be evaluated using the following algorithm:
If it's the path of an existing file, and overwrite is true, it will be overwritten.
If it's the path to an existing file, and overwrite is false, an IOException will be thrown.
If this points to an existing directory, the project will be extracted with its original name into that directory.
If the path does not exist, but ends with a "/" or "", the directory (and all non-existing parent directories) will be created, then the project will be extracted with its original name into that directory.
If the path does not exist, but the parent directory exists, the given path (directory and file name) will be used.
Otherwise, if the path ends with ".project" or ".library", the project will be extracted using the given path, creating all necessary parent directories.
In all other cases, a DirectoryNotFoundException will be thrown.
This method will return None when the archive extraction was cancelled due to an error, overwriting of files or cancel request for absolute path handling. If a password is given, SystemInstances.ObjectManager must implement IObjectManager9, or a MissingMethodException will be thrown (even if the project is not actually password protected). If the password is omitted, None or empty string, opening a password protected archive will prompt the user for a password.
For the update_flags parameter, the VersionUpdateFlags.SilentMode is usually combined with one or more of the Update... flags defined in the VersionUpdateFlags enum. If you only pass some Update... flags without the VersionUpdateFlags.SilentMode flag, they will be used as initial values when the update dialog pops up. To silently update everything, you can pass the combination VersionUpdateFlags.SilentMode|VersionUpdateFlags.UpdateAll.
archivefile (str) -- The path of the project archive.
projectpath (str) -- The path for the extracted project.
overwrite (bool) -- if set to true, overwrite existing objects and project files
password (str) -- The password.
encryption_password (str) -- Version added: 3.5.5.0 The project encryption password.
session_user (str) -- Version added: 3.5.5.0 The project session user (project usermanagement).
session_password (str) -- Version added: 3.5.5.0 The project session password (project usermanagement).
update_flags (VersionUpdateFlags) -- Version added: 3.5.8.0 The flags telling whether some aspects (libraries, compiler version) ought to be updated when the project is loaded. The default is to silently update nothing.
prompt_absolute_path (PromptAbsolutePath) -- Version added: 3.5.16.0 The callback which allows to decide if an project archive item with an absolute path should be extracted relatively to the project file or not at all. Or if the operation should be canceled. The default is to cancel the operation.
The opened project or null if it was canceled.
get_by_path
path
Gets a Project by the absolute path where the project is physically stored.
path (str) -- The path to the project.
The project instance
primary
Gets the primary project, or None if no primary project currently exists.
The primary project is the one the user usually works with. See ScriptProject.primary for more information.
all
Gets a (possibly empty) List of all currently opened projects.
list
convert
path
output_path=None
converter=None
primary=True
Converts the specified project.
Currently, password and device conversion prompts cannot be caught by the script.
3.5.0.0
path (str) -- The path of the project to convert.
output_path (str) -- The output path. This parameter is optional, if it is omitted, the output path will be auto-generated from the project path by changing the file extension.
converter (str) -- The GUID of the CoDeSys converter factory as string object. This parameter is optional, if omitted, the script engine will try to guess using the extension of the file name.
primary (bool) -- If set to True, open as primary project. See ScriptProject.primary for more information.
The converted project.
class
ScriptProjects.
ScriptProjectArchiveCategories
Bases: list
The list of available archive categories.
Enumerating this object will give all categories available in the current installation. Some often used categories are defined here, but may be unavailable (throw exceptions) in customized environments. An instance of this object is injected into the scriptengine module with the name "ArchiveCategories".
default
The default selection of archive categories.
See also: ScriptProjectArchiveCategory.selected_by_default
return_type
none
No categories (empty set).
This is a special sentinel value, different from passing an arbitrary empty list.
all
A collection of all categories (returns self).
compileinfo
Gets the category for the compileinfo.
This is needed for logins and online changes into an existing application without download.
libraries
Gets the category for the libraries referenced by the project.
devices
Gets the category for the device descriptions of the devices used in the project.
options
Gets the category for the project, user, and machine specific preferences.
ftd
Gets the category for the FDT Bulk Data.
images
Gets the category for the imagepool images of the project.
bootproject
Gets the category for the files containing offline boot applications, that were generated for the current project.
libraryprofile
Gets the category for the library profile that is currently in use with this project.
visualstyles
Gets the category for the visualization styles which are currently referenced by this project.
visualprofile
Gets the category for the active visualization profile.
visuextensions
Gets the category for the active visualization extensions.
class
ScriptProjects.
ScriptProjectArchiveCategory
Bases: object
Represents a category of items which can be included into a project archive.
guid
Gets the Guid for this category.
Guid
name
Gets a display name for this project category, e.g. "Referenced libraries".
This string should be localized.
str
descrption
Gets a description for this project category.
This string should be localized.
str
selected_by_default
Gets a boolean value indicating whether this category should be selected for project archive inclusion per default.
This is a hint for the presentation layer.
bool
class
ScriptProjects.
PromptOverwriteResult
Bases: enum.Enum
Enum that enumerates the possible results for the overwrite handling.
Yes
= 0
The user selected "Yes", which means that the file or item should be overwritten.
No
= 1
The user selected "No", which means that the file or item should not be overwritten.
Cancel
= 2
The user selected "Cancel", which means that the project archive extraction should be terminated.
ScriptProjects.
PromptAbsolutePath
path
[Delegate]. This method can be used to decide if a project archive item with absolute path should be extracted relatively to the project file or not at all. Or if the whole operation should be canceled.
path (str) -- Path to the location where the item wants to be extracted to
Yes if the item should be extracted relatively to the project file. No if the item should not be extracted at all. Cancel if the operation should be canceled.