cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

How to run Python-scripts on the ctrlX CORE

How to run Python-scripts on the ctrlX CORE

CodeWasi
Occasional Contributor

By installing the Python app, the interpreter stays present on the ctrlX-CORE.
Since the functionality had been upgraded and its interfaces changed incompatible - latest created script files (maybe Tiger-generated form promoter-package) are not executable anymore. The attached Interpreter description will offer the info needed to update the former script coding.

The upcoming script-manager-functionality/app is supposed to provide an easy and intuitive way to place and execute scripts on the ctrlX-CORE. Meanwhile we need to get familiar with interims solution.
Goal of the paper is to get familiar with the script-handling-workaround, which will be dispensable soon.   

How to place the script file(s) on the ctrlX?

Transfer the script files using the Configuration interface.

grafik.png

a) Use the Configuration-Website to download the config to the PC.
b) Unzip and add the python script file(s) and zip again.
grafik.png

c) Create a new/empty configuration by clicking + and upload the modified zip file.
d) The prepared configuration gets active by clicking the Hook-button – which registers the *py file(s) at the Ubuntu OS
(do not care about the storage location – you may not find easily viewing with SSH/MobaXterm).

How to execute the scripts using Rest-clients e.g. Yarc

e) Get the authentification token first

grafik.png

f) Create a new script instance by sending a similar Rest-payload.

grafik.png

g) Finally the script can be started by sending the payload containing path and filename of the related script.


with the payload:
{"name":"/var/snap/rexroth-automationcore/common/solutions/activeConfiguration/PythonBsp2.py"}

 
6 REPLIES 6

lizette_lamers
New Poster

I tried to do this and sucessfully created an instance under script but when I send the post request to cmd/file of the instance with the file path I got the error "DL_CREATION_FAILED" with code 404. I am trying this on a virtual CORE and I saw with ssh that in the directory "/var/snap/rexroth-automationcore/common/solutions" I do not have a directory of "activeConfiguration", in my case this directory is completely empty even though I did active my configuration. I saw that my added script file was stored in the "/var/snap/rexroth-solutions/common/solutions/activeConfiguration" directory. But even when I try this path as the pay load I still get the same error.

CodeWasi
Occasional Contributor

Hello,

the Failure 404 assume that the 'URL-Path' is not correct.
Assuming you added as well the Authorization Token in the https Rrequest do run the script (that mistake is related to Failure 401),
I want you to check the typing please.

 

CodeWasi_2-1603094879671.png

 

I just tried it with the ctrlX CORE virtual and it worked fine. I guess you included the 'AuthentifcationToken' as well in the 2nd https request to run the script file.

CodeWasi_0-1603094418903.png

CodeWasi_1-1603094820681.png

Please return if the info did not help to solve the topic.

Bye Jens

Usalas
Long-established Member

Thanks for the information. The scripts runs fine when the file is located in the root. 

I was trying to run files located in the tiger folder and me a 500 error.

{"name":"/var/snap/rexroth-automationcore/common/solutions/activeConfiguration/scripts/bosch/tiger/ReadWritePLC.py"}

Usalas_0-1618429848797.png

 

Is there any update to this process? I am not seeing the Configurations menu on RM22.07. 

CodeShepherd
Community Moderator
Community Moderator

The button to view the configuration (app data) moved in the top bar and is a folder with a gear in it:ctrlX CORE WebUI manage app datactrlX CORE WebUI manage app data

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist