Create an Access Token and Upload a Snapshot with Python Script

Overview

You can upload a snapshot to the EcoStruxure Machine Advisor Code Analysis portal:

You can create a technical user (access token) that is allowed to upload a snapshot for one specific analysis project. For example, for CI-Systems (Continuous Integration Systems), it is possible to upload snapshots via Python scripts.

Click ADMINISTRATION > <PROJECT> > ACCESS TOKENS to open this window.

Create an Access Token

Step

Action

1

Enter a Name.

2

Select an Expiration Date. After this date, the access token cannot be used to upload a snapshot.

3

Click the CREATE button.

Result: A window is displayed which provides the access token as a character string.

4

Retain this string in a secure manner because the string is provided only once.

5

Close the window.

Result: A new row is displayed in the <Project> - Access Tokens table.

Python Script Example

You can use the token (saved character string) to log into the EcoStruxure Machine Advisor Code Analysis portal via a Python script.

NOTE: The Application node of the EcoStruxure Machine Expert Logic Builder project which snapshot should be uploaded to the EcoStruxure Machine Advisor Code Analysis portal must provide a Code Analysis Manager subnode.

Example of a Python script:

# application object searched

app = projects.primary.find("Application", True)[0]

# full analysis will be executed

app.code_analysis.perform_full_analysis()

#login

projects.primary.code_analysis.portal.login
('eyJVcmwiOiJodHRwczovL2Vjb3N0cnV4dXJlLW1hY2hpbmUtYWR2aXNvci1jb2RlYW5h'
+'bHlzaXMuc2UuYXBwIiwiQ2xpZW50SWQiOiJlNWM5aDI4ODdiZDV3YWZiajlpMWw5N2Zl'
+'NDMwZGNqOSIsIkNsaWVudFNlY3JldCI6Ijc2U1VBWkNVU0VEUDExMTExMTExIn0='
)
app.code_analysis.portal.snapshots.upload("mySnapshot")

# logout

app.code_analysis.portal.logout()

Result: After executing the Python script, the uploaded snapshot is displayed in the <Project> - Snapshots overview.