Discussion:
[Py2exe-users] py2exe with cmd module
honas grael
2016-03-17 20:46:31 UTC
Permalink
Hi I'm using python's cmd.cmd module(aka cmd module), essentially I have a
function like

do_simple_test(line)
*run the test file*

When I run it, I get a nice little console typing
simple_test(test_filename.txt), allows me to run the tests contained in the
text file that I typed in.

This works well, but I want to take the automation one step further. I
converted my *main.py* into an executable *main.exe* using py2exe. It still
works fine.

What I now want is to be able to launch main.exe with the test_filename.txt
as a parameter so

main.exe test_filename.txt

so that it will execute

simple_test(test_filename.txt)

That would give me the freedom to change the argument with which I call
main.exe, without having to type the appropriate command in the console
window.

I am running python 2.7.10 on Windows Is it possible to do this, and how?

Thank you
Toni Barth
2016-03-18 05:27:32 UTC
Permalink
Post by honas grael
Hi I'm using python's cmd.cmd module(aka cmd module), essentially I
have a function like
|do_simple_test(line)*run the test file*|
When I run it, I get a nice little console typing
|simple_test(test_filename.txt)|, allows me to run the tests contained
in the text file that I typed in.
This works well, but I want to take the automation one step further. I
converted my *main.py* into an executable *main.exe* using py2exe. It
still works fine.
What I now want is to be able to launch main.exe with the
test_filename.txt as a parameter so
|main.exe test_filename.txt|
so that it will execute
|simple_test(test_filename.txt)|
That would give me the freedom to change the argument with which I
call main.exe, without having to type the appropriate command in the
console window.
I am running python 2.7.10 on Windows Is it possible to do this, and how?
Thank you
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
Hi,
this isn't actually a py2exe question. What stops you from doing it
the old fashioned way?
import sys
do_simple_test(sys.argv[1])
or actually implement an argument parser for your program. That way
you could actually add some more arguments to your program. Use the
argparse module to do that (import argparse).
Both ways should be fully compatible to py2exe.
Best Regards.
Toni
_______________________________________________
Py2exe-users mailing list
https://lists.sourceforge.net/lists/listinfo/py2exe-users
Loading...