Bug fixes in Python
Product line
Standard
|Expert
Operating mode
CLOUD ABO
|ON-PREMISES
Modules
Services & CRM
Budget & Phases
Purchases
Resource Planning
Business Intelligence
If a script does not run and an error message is returned, you can analyze it in more detail as follows.
execute
, making sure that the argobject is of the correct type, e.g. a service or a project. The script will execute and the error message will appear in the output on the right:In the error message you will find the line number on which the problem occurs, for example:
Traceback (most recent call last): File “<string>,” line 146, in <module> File “<string>,” line 85, in main NameError: global name 'showPiority’ Inf not defined
It is always the lowest line number relevant to the current error, so here it occurs in row 85 of the script.
The script can now navigate to this row. The error is now clear: showPiority
is a typo and should be called showPriority
.
Correct errors, save, and execute the script again.
When using variables, you must be case sensitive. Python is case sensitive. When using variables, you must always keep in mind that the variable matches 1:1.
var1
is not equal to var1
In such cases, it is rather difficult to find the error because in certain cases, Python does not output an error, but instead creates a new variable 'Var1'. Therefore, always make sure that the variable used is named exactly.
The Python interpreter handles an indent correctly if it contains 4 spaces. A tab is automatically replaced by 4 spaces in a Python editor.
If a piece of code is copied from a web page or other text file into the Python Editor, care must be taken that it does not have tab indents. If this is the case, the tabs must be replaced by 4 spaces. Several editors support the option Replace tab with x characters.
Collection types should be created before use as a precaution to avoid unexpected errors (accessing or returning non-existent lists, etc.)
list = []
dict = {}
This error occurs when you access the system context, but it is not allowed. For example, for security reasons, it is not allowed to execute Python scripts with vtcapp.Systemcontext()
directly in the Python Editor, as this operation grants accepted user rights, which requires a corresponding login. See also the description in the Vertec Python Functions
.