We actually use this method. This is one example. Note: I'm still a rookie at python.
This actually makes a REST call against automic to get some agent host information.
set PATH=%PATH%;d:\python\python310;d:\python\python310\scripts
:BEGIN_EXT_INT Python
import requests
import json
import socket
url = "hostname:8088/ae/api/v1/0060/system/agents?active=True"
payload = {}
headers = {
'Authorization': 'redacted'
}
response = requests.request("GET", url, headers=headers, data=payload)
#print(response.text)
#print(response)
data = json.loads(response.text)
# Iterating through the json
# list
for i in data['data']:
hostname="notfound"
try:
hostname = socket.gethostbyaddr(i["ip_address"])[0]
except socket.error:
pass
print("OUTDATA;",i["name"],";",i["ip_address"],";",i["software"],";",hostname)
:END_EXT_INT Python
! insert these lines in your script to determine if an error occurred
!
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode
Original Message:
Sent: Apr 02, 2024 04:10 PM
From: Andrzej Golaszewski
Subject: Create a job which will execute python script.
Hello Rupesh Kadam,
a possible solution for your use case is to configure your automic, for usage with external interpreters. Try to follow the manual description :BEGIN_EXT_INTERPRETERS... :END_EXT_INTERPRETERS . If you have further questions feel free to ask.
Best regards
Andrzej Golaszewski
Original Message:
Sent: Apr 02, 2024 09:33 AM
From: Rupesh Kadam
Subject: Create a job which will execute python script.
I watched documentation on UC4 (automic automation) but couldn't find the help where I can create a job and execute my python script.
I have developed on python script for web scrapping. This script doesn't required any input parameters. I want to create on job on UC4 in which this job will execute this python script. also I have to execute this python script. where I have to save this file in order to execute this script. because we have 4 environments for UC4. I have questions like, where to keep the python script in order to point the location and which command to use and where.
PS - I am using UC4 web interface version is "Automic web interface 21.0.8". I am very much new to UC4 hence step by step approach would be highly appreciated. Thank you !