From: Marko L. <mar...@gm...> - 2013-03-27 08:00:28
|
Hello, Is there a way to tweak a py2exe executable *made with windows option* so that I can get stdout and stdin working as if it were a console executable? I would like to be able to launch the script in a DOS window and read from stdin and write to stdout. I wonder if there is a way to set sys.stdin and sys.stdout to recover the DOS streams. The py2exe executable made with the windows option is already installed on my clients' machines. This file is difficult to update (I depend on the IT department for changing any .exe file and it is a complicated procedure). For updates of the application what I do is to change the non-exe files such as library.zip. I can change these files easily. For the moment the application is a qt GUI that works well as a py2exe windows executable. But I would like to add new functionality that would work in a console environment. Thanks a lot for any hint, Marko |
From: Werner F. B. <wer...@fr...> - 2013-03-27 09:35:54
|
Hi Marko, On 27/03/2013 08:59, Marko Loparic wrote: > Hello, > > Is there a way to tweak a py2exe executable *made with windows option* > so that I can get stdout and stdin working as if it were a console > executable? > > I would like to be able to launch the script in a DOS window and read > from stdin and write to stdout. > > I wonder if there is a way to set sys.stdin and sys.stdout to recover > the DOS streams. > > The py2exe executable made with the windows option is already installed > on my clients' machines. This file is difficult to update (I depend on > the IT department for changing any .exe file and it is a complicated > procedure). For updates of the application what I do is to change the > non-exe files such as library.zip. I can change these files easily. > > For the moment the application is a qt GUI that works well as a py2exe > windows executable. But I would like to add new functionality that would > work in a console environment. > I am not sure I get what you want to do, but are you aware of "console" py2exe keyword? http://www.py2exe.org/index.cgi/ListOfOptions I generate my stuff like this: console = [GUI2Exe_Target_1c, GUI2Exe_Target_2c], windows = [GUI2Exe_Target_1, GUI2Exe_Target_2] In the above Target_1c and Target_1 are the same script, one will generate "target1.exe" the other "target1_con.exe", I use the console one mainly for debugging. The above format is from GUI2Exe which I use to to generate the skeleton of my setup.py. http://wiki.wxpython.org/py2exe-python26 http://code.google.com/p/gui2exe/downloads/list Werner |
From: Marko L. <mar...@gm...> - 2013-03-27 11:02:51
|
Hi Werner, On Wed, Mar 27, 2013 at 10:37 AM, Werner F. Bruhin wrote: > > Hi Marko, > > On 27/03/2013 08:59, Marko Loparic wrote: > > Hello, > > > > Is there a way to tweak a py2exe executable *made with windows option* > > so that I can get stdout and stdin working as if it were a console > > executable? > > > > > I would like to be able to launch the script in a DOS window and read > > from stdin and write to stdout. > > > > I wonder if there is a way to set sys.stdin and sys.stdout to recover > > the DOS streams. > > > > The py2exe executable made with the windows option is already installed > > on my clients' machines. This file is difficult to update (I depend on > > the IT department for changing any .exe file and it is a complicated > > procedure). For updates of the application what I do is to change the > > non-exe files such as library.zip. I can change these files easily. > > > > For the moment the application is a qt GUI that works well as a py2exe > > windows executable. But I would like to add new functionality that would > > work in a console environment. > > > I am not sure I get what you want to do, but are you aware of "console" > py2exe keyword? Yes. The perfect solution would be to make a new executable using the "console" option as you say. But my problem is that I would like to avoid deploying a new executable, because in this case I would need to go through a complicated procedure involving the IT department. I work for a large company and they impose a strict policy on the installation of exe files. The system I use to make upgrades of my application is to upgrade only non-exe files generated by py2exe. I wrote the code in a way that the exe file is only a small bootstrap code, the rest stays outside. This has worked well for some time, but now I would like to have the "console" functionality and the exe file was written with the "windows" option. Thanks! Marko |
From: Mark H. <ski...@gm...> - 2013-03-27 10:30:17
|
There is no way to do this directly with py2exe, and I only recently discovered it was even possible. The C++ code Firefox uses to do this is at http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsNativeAppSupportWin.cpp#400, and it might be possible to re-implement this directly in your app using pywin32/ctypes/something :) HTH, Mark On 27/03/2013 6:59 PM, Marko Loparic wrote: > Hello, > > Is there a way to tweak a py2exe executable *made with windows option* > so that I can get stdout and stdin working as if it were a console > executable? > > I would like to be able to launch the script in a DOS window and read > from stdin and write to stdout. > > I wonder if there is a way to set sys.stdin and sys.stdout to recover > the DOS streams. > > The py2exe executable made with the windows option is already installed > on my clients' machines. This file is difficult to update (I depend on > the IT department for changing any .exe file and it is a complicated > procedure). For updates of the application what I do is to change the > non-exe files such as library.zip. I can change these files easily. > > For the moment the application is a qt GUI that works well as a py2exe > windows executable. But I would like to add new functionality that would > work in a console environment. > > Thanks a lot for any hint, > Marko > > > > ------------------------------------------------------------------------------ > Own the Future-Intel® Level Up Game Demo Contest 2013 > Rise to greatness in Intel's independent game demo contest. > Compete for recognition, cash, and the chance to get your game > on Steam. $5K grand prize plus 10 genre and skill prizes. > Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d > > > > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > |
From: Marko L. <mar...@gm...> - 2013-03-27 13:42:40
|
Hello Mark, On Wed, Mar 27, 2013 at 11:30 AM, Mark Hammond wrote: > There is no way to do this directly with py2exe, and I only recently > discovered it was even possible. The C++ code Firefox uses to do this is at > http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsNativeAppSupportWin.cpp#400, > and it might be possible to re-implement this directly in your app using > pywin32/ctypes/something :) I have tried directly in Python (using a windows py2exe) to see if I was lucky enough to get it working: with open('CONOUT$', 'wb') as fobj: fobj.write("yes!\n") but I get Traceback (most recent call last): File "console.py", line 1, in <module> with open('CONOUT$', 'wb') as fobj: IOError: [Errno 13] Permission denied: 'CONOUT$' Apparently I need to write a C code as you say and use freopen. If it works I will write a new message showing the solution. Thanks a lot! Marko > > HTH, > > Mark > > > > On 27/03/2013 6:59 PM, Marko Loparic wrote: >> >> Hello, >> >> Is there a way to tweak a py2exe executable *made with windows option* >> so that I can get stdout and stdin working as if it were a console >> executable? >> >> I would like to be able to launch the script in a DOS window and read >> from stdin and write to stdout. >> >> I wonder if there is a way to set sys.stdin and sys.stdout to recover >> the DOS streams. >> >> The py2exe executable made with the windows option is already installed >> on my clients' machines. This file is difficult to update (I depend on >> the IT department for changing any .exe file and it is a complicated >> procedure). For updates of the application what I do is to change the >> non-exe files such as library.zip. I can change these files easily. >> >> For the moment the application is a qt GUI that works well as a py2exe >> windows executable. But I would like to add new functionality that would >> work in a console environment. >> >> Thanks a lot for any hint, >> Marko >> >> >> >> >> ------------------------------------------------------------------------------ >> Own the Future-Intel® Level Up Game Demo Contest 2013 >> Rise to greatness in Intel's independent game demo contest. >> Compete for recognition, cash, and the chance to get your game >> on Steam. $5K grand prize plus 10 genre and skill prizes. >> Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d >> >> >> >> _______________________________________________ >> Py2exe-users mailing list >> Py2...@li... >> https://lists.sourceforge.net/lists/listinfo/py2exe-users >> > |