Re: stdin, stdout, redmon

2008-01-22 Thread Thynnus
On 1/21/2008 9:02 AM, Bernard Desnoues wrote:
> Hi,
> 
> I've got a problem with the use of Redmon (redirection port monitor). I 
> intend to develop a virtual printer so that I can modify data sent to 
> the printer.

FWIW: there is a nice update the RedMon (v1.7) called RedMon EE (v1.81) 
available at http://www.is-foehr.com/ that I have used and like a lot.

 From the developers website:
Fixed issues and features [with respect to the orininal RedMon]
 *  On Windows Terminal Server or Windows XP with fast user switching, the
   "Prompt for filename" dialog will appear on the current session.
 * "SaveAs" now shows XP style dialogs if running under XP
 * Support for PDF Security added - experimental -.
 * Support for setting the task priority - experimental -
 * Use of file-shares as output
 * Environment variables are passed to the AfterWorks Process now.
 * Environment variables are replaced in the program arguments. No 
workaround is needed.
 * RedMon EE comes with an RPC communication feature which could transfer
   output-files back to the client starting the print job on a print server.
   Error messages will be send to the client.
 * Redmon EE may start a process after the print job has finished (After 
works process).
   e.g. starting a presentation program to show the pdf generated by 
GhostScript.
 * additional debug messages may be written for error analysis.
   No special debug version is needed.
 * user interface has been rewritten. May be it's more friendly.
   Added some basic system information which may help if running in 
failures.
 * new feature: running on a print server.
 * cleanup of documentnames "Microsoft -"
 * define templates for output-file names with full environment variable 
substitution
   e.g. %homedrive%\%homedir%\%redmon-user%-%date%-%time%-%n.pdf
 * RedMon EE does not support for NT 3.5 and Windows 95/98 !

-Thynnus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin, stdout, redmon

2008-01-22 Thread Thynnus
On 1/22/2008 8:54 AM, Konstantin Shaposhnikov wrote:
> Hi,
> 
> This is Windows bug that is described here: 
> http://support.microsoft.com/default.aspx?kbid=321788
> 
> This article also contains solution: you need to add registry value:
> 
> HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies
> \Explorer
> InheritConsoleHandles = 1 (REG_DWORD type)
> 
> Do not forget to launch new console (cmd.exe) after editing registry.
> 
> Alternatively you can use following command
> 
>   cat file | python script.py
> 
> instead of
> 
>   cat file | python script.py
> 
> Regards,
> Konstantin

Nice one, Konstantin!

I can confirm that adding the registry key solves the problem on XPsp2:

-After adding InheritConsoleHandles DWORD 1 key-
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\temp>type test3.py | test3.py
['import sys\n', '\n', 'print sys.stdin.readlines ()\n']

D:\temp>

The KB article is quite poorly written. Even though it seems to state that 
issue was 'solved for win2k with sp4, for XP with sp1', and gives no indication 
that the key is needed after the sp's are applied *even though* it is in fact 
necessary to the solution.

Questions:
 -Any side effects to look out for?
 -If the change is relatively benign, should it be part of the install?
 -Is this worth a documentation patch? If yes to where, and I'll give it a 
shot.

-Thynnus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'normal' shell with curses

2008-03-04 Thread Thynnus
On 3/3/2008 9:57 PM, Michael Goerz wrote:
> Hi,
> 
> I'm trying to print out text in color. As far as I know, curses is the 
> only way to do that (or not?). So, what I ultimately want is a curses 
> terminal that behaves as closely as possible as a normal terminal, i.e. 
> it breaks lines and scrolls automatically, so that I can implement a 
> function myprint(color, text) that does what print() does, only in color.

You might find the below helpful. Let us know how you make out?



Python Cookbook
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116

Title:
  Using terminfo for portable color output & cursor control

Description:
The curses module defines several functions (based on terminfo) that can be 
used to perform lightweight cursor control & output formatting (color, bold, 
etc). These can be used without invoking curses mode (curses.initwin) or using 
any of the more heavy-weight curses functionality. This recipe defines a 
TerminalController class, which can make portable output formatting very 
simple. Formatting modes that are not supported by the terminal are simply 
omitted.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'normal' shell with curses

2008-03-04 Thread Thynnus
On 3/4/2008 12:05 PM, Michael Goerz wrote:
> Thynnus wrote, on 03/04/2008 08:48 AM:
>> On 3/3/2008 9:57 PM, Michael Goerz wrote:
>>> Hi,
>>>
>>> I'm trying to print out text in color. As far as I know, curses is the 
>>> only way to do that (or not?). So, what I ultimately want is a curses 
>>> terminal that behaves as closely as possible as a normal terminal, 
>>> i.e. it breaks lines and scrolls automatically, so that I can 
>>> implement a function myprint(color, text) that does what print() does, 
>>> only in color.
>> 
>> You might find the below helpful. Let us know how you make out?
>> 
>> 
>> 
>> Python Cookbook
>>  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116
>> 
>> Title:
>>  Using terminfo for portable color output & cursor control
>> 
>> Description:
>> The curses module defines several functions (based on terminfo) that can 
>> be used to perform lightweight cursor control & output formatting 
>> (color, bold, etc). These can be used without invoking curses mode 
>> (curses.initwin) or using any of the more heavy-weight curses 
>> functionality. This recipe defines a TerminalController class, which can 
>> make portable output formatting very simple. Formatting modes that are 
>> not supported by the terminal are simply omitted.
>> 
>> 
>> 
> 
> That looks *extremely* interesting. From a very brief test, it seems to 
> do exactly what I want!
> 
> Now, Windows seems very problematic for color output. I was using the 
> following as a test, based on the above recipe:
> 
> term = TerminalController()
> while True:
>  print term.render('${YELLOW}Warning:${NORMAL}'), 'paper is crinkled'
>  print term.render('${RED}Error:${NORMAL}'), 'paper is ripped'
> 
> On Linux, it works fine, on Windows, it just prints white on black 
> (which is of course what it should do if the terminal doesn't support 
> color). Can anyone get the Windows cmd.exe terminal to do color? I 
> already tried to add device=%SystemRoot%\system32\ansi.sys to config.nt, 
> but that doesn't seem to do anything (neither in what I tried yesterday 
> with the ANSI escape codes, nor with the recipe code now). I also very 
> briefly tried running it on the winbash shell 
> (http://win-bash.sourceforge.net/), it didn't have any color either... 
> So, any way to get color in Windows?
> 
> Michael

ipython - http://ipython.scipy.org/ - does a colored Windows interpreter, clue 
there.
-- 
http://mail.python.org/mailman/listinfo/python-list