Mark Saunders, I'm trying to use your pre and post build feature.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoWi_3984961
Level 4
Level 4
First like received First like given

First I see it does not accept Python..the most popular language by most measures.

Visual Basic is not.

So I made the .py into a .EXE.

It runs, outputs, which is captured and displayed in your "output" window.

So far, so good.

But now the script needs an input, a COM port.

How can I get my reply through your output window into my EXE?

Why not just allow .py?

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

You can run python scripts directly from Creator. You just need to add the following in the post-build option:

"C:\Python27\python.exe" "C:\<project_dir>.cydsn\python_file.py"

If the python script needs a COM Port input, you will need to import the win32com.client as follows:

import win32com.client

pp = win32com.client.Dispatch("<Pass ProgID here>")  

#example usage: pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")

In case you have many scripts to run, you can create a batch file with sequence of commands. Just ensure your python script terminates uses sys.exit() to ensure control is passed back. In the post build command, just specify the command as <filename>.bat.

Regards,

Dheeraj

View solution in original post

0 Likes
2 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

You can run python scripts directly from Creator. You just need to add the following in the post-build option:

"C:\Python27\python.exe" "C:\<project_dir>.cydsn\python_file.py"

If the python script needs a COM Port input, you will need to import the win32com.client as follows:

import win32com.client

pp = win32com.client.Dispatch("<Pass ProgID here>")  

#example usage: pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")

In case you have many scripts to run, you can create a batch file with sequence of commands. Just ensure your python script terminates uses sys.exit() to ensure control is passed back. In the post build command, just specify the command as <filename>.bat.

Regards,

Dheeraj

0 Likes

I got it working an easier way, but thanks!

0 Likes