Reset board after doing "pio run --target upload" using extra scripts

Hello Folks,

I need to reset nano BLE sense board after running “pio run --target upload”

I am following the thread -

Tried to do something like below in (kept in same folder as platform.ini) -

import os
from import AutodetectUploadPort
from import TouchSerialPort

platform = env.PioPlatform()
print(“Doing AutodetectUploadPort”)
upload_port = env.subst(‘$UPLOAD_PORT’)
TouchSerialPort(env, upload_port, 1200)
print(“Doing TouchSerialPort”)

My platform.ini has “extra_scripts =”

But above code doesn’t seem to cause the reset. Am I missing something? I am monitoring the reset on a separate terminal running “pio device monitor”. This is Ubuntu 18.

I am newbie in pio and python so please bear with me. Please guide to some document or example code.