UC4 ONE Atutomation Job with Python Script

1.2k Views Asked by At

I have a little problem with UC4. There is a job, which only starts a batch file. Inside this job on the process sheet there are three variables as plain text.

Filename country department

file.bat sweden sales

The filename is used for in the job itself to execute the batch file. The other two are used inside the batch file and are called like:

set country = %1
set dep = %2

In order to rebuild it in python, I would like to know how to assign/call the variables in python.

1

There are 1 best solutions below

1
On BEST ANSWER

You can pass the variables as arguments while triggering Python job. It can be done using argparse library. See the below example where the argument named "country" and "dep" are accessed.

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("country")
parser.add_argument("dep")
args = parser.parse_args()
print(args.country, args.dep)

Your job will look like,

python file_python_job.py --country "Country Name" --dep "Dept Name"

More info can be found here