Groovy script to call Python and batch file - groovy

I wish to send email containing build status of all child job.
Therefore, I have used batch and python script to prepare the html file, which I will be importing in Editable Email Notification plugin.
However, in Pre Send script tab, we can only write groovy script.
So I would like to call my python file, that contains my logic from groovy

You would have to call your python script as part of the job (possibly via a shell action) and save the HTML in the workspace and the add that file to the email. Alternatively you could create a custom email template that does the same

Related

Pass value from operator to dag

I have a BashOperator in my dag which runs a python script. At the end of its run, the python script creates a json as a report. In case of failure, I want to report this json to Slack. I have an on_failure_callback function which can push a message to Slack. However, I have no elegant way to pass the json value to the dag. Currently, I am saving the json to a file and then reading it from the file in the dag and reporting it. I also tried storing it in an environment variable and getting it in the dag. But is there a more direct way to pass this value to the dag? Preferably, without saving it to a file or an environment variable.
Rather than using on_failure_callback you should use another task to send your slack message.
And for that you should simply use XComs to push/pull the file. https://airflow.apache.org/docs/apache-airflow/stable/concepts/xcoms.html#
Then you can pull the xcom in the task that sends it further to slack.

Convert response PDF to text and execute test script. (eg., check for specific string)

I have a Postman collection with multiple POST requests which returns PDF as response(content type "application/pdf").
I use node js to run this collection via newman. The script converts the pdf response to txt using "pdf-parse" and store it in file system.
I would like to run test scripts from postman collection request on this text file so that I can do string compare.
Approached it differently. Update the code to enhance the test script during runtime by replacing a standard string with converted pdf text which will be used for test evaluation.
More info on https://stackoverflow.com/a/66631208/5038526

Sending Information from one Python file to another

I would like to know how to perform the below mentioned task
I want to upload a CSV file to a python script 1, then send file's path to another python script in file same folder which will perform the task and send the results to python script 1.
A working code will be very helpful or any suggestion is also helpful.
You can import the script editing the CSV to the python file and then do some sort of loop that edits the CSV file with your script 1 then does whatever else you want to do with script 2.
This is an advantage of OOP, makes these sorts of tasks very easy as you have functions set in a module python file and can create a main python file and run a bunch of functions editing CSV files this way.

Execute stand alone python script inside another script

I have made a .py file (i call it acomp.py) that reads from and SQL database and after a series of calculations and exports its output to an excel file.Later I sends this .xlsx file by e-mail to various persons.
I wish to put it inside another python script so I can use the schedule module to call acomp.py aromatically at selected times, run it and send the output by email:
def exec_scrpit():
exec(open("acomp.py", encoding='utf-8').read())
send_email()
schedule.every().day.at("07:20").do(exec_scrpit)
When the second script calls the fist it messes with the acom.py internal functions returning the error:
" File "<string>", line 125, in <lambda>
NameError: name 'modalidade_contrato' is not defined"
This 'modalidade_contrato' is defined inside acomp.py and it runs perfectly when I execute acom.py directly.
Any ideia how should I proceed? I think my whole strategy is not usual, but I have to do it this way because I do not have admin privileges on my computer.
I learned that you can simply run it as you would in cmd:
os.system(r'"C:\Users\user.name\Miniconda3\python.exe acomp.py"')

kofax import connector does not collect system copied files

I have 2 KTA process, the first collects email attachments and then uses a .net activity to flatten with a cmd utility.
It is called as a .vbs script from the KTA .net activity.
The file is output to new directory. The second process is supposed to pick up again via file import connector but wont detect the file.
If I copy it there manually it collects.
Any other method like windows scheduler copy or VB copy or KTA process copy causes the import connector not to pick up the file.
I tried trigger and time based modified file.
Any suggestions what could be the problem?
Thanks
Shane

Resources