Re: putting text through pager

2008-03-20 Thread Michael Goerz
Michael Goerz wrote, on 03/20/2008 04:43 PM: > Hi, > > I'm trying to print some variable through a pager (i.e. 'less') on a > linux system. My attempt was this: > > > == snip here == > import subprocess > > def put_through_pager(displ

putting text through pager

2008-03-20 Thread Michael Goerz
Hi, I'm trying to print some variable through a pager (i.e. 'less') on a linux system. My attempt was this: == snip here == import subprocess def put_through_pager(displaystring): less_pipe = subprocess.Popen(\ 'less', shell=True, \ stdin

Re: 'normal' shell with curses

2008-03-04 Thread Michael Goerz
Michael Goerz wrote, on 03/04/2008 12:05 PM: > 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

Re: 'normal' shell with curses

2008-03-04 Thread Michael Goerz
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 th

Re: 'normal' shell with curses

2008-03-03 Thread Michael Goerz
Miki wrote, on 03/03/2008 11:14 PM: > Hello Michael, > >> I'm trying to print out text in color. As far as I know, curses is the >> only way to do that (or not?). > On unix, every XTerm compatible terminal will be able to display color > using escape sequence. > (Like the one you see in the output

'normal' shell with curses

2008-03-03 Thread Michael Goerz
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

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Grant Edwards wrote, on 02/27/2008 04:34 PM: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> >> latexprocess = subprocess.Popen( \ >&g

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Gabriel Genellina wrote, on 02/27/2008 03:26 PM: > En Wed, 27 Feb 2008 15:06:36 -0200, Ian Clark <[EMAIL PROTECTED]> > escribi�: > >> On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >>> Hi, >>> >>> I would like to raise an except

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Ian Clark wrote, on 02/27/2008 12:06 PM: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> latexprocess = subprocess.Popen( \ >> 'pdflatex&#

Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Hi, I would like to raise an exception any time a subprocess tries to read from STDIN: latexprocess = subprocess.Popen( \ 'pdflatex' + " " \ + 'test' + " 2>&1", \ shell=True, \ cwd=os.getcwd(), \ env=os.environ, \ stdin=StdinCatcher() # any

KeyboardInterrupt should not kill subprocess

2008-02-21 Thread Michael Goerz
Hi, I'm using subprocess.Popen() to run some background processes. However, the program is also supposed to catch CTRL+C keyboard interrupts for refreshs (i.e. a keyboard interrupt doesn't shut down the program). But as it seems, a keyboard interrupt will automatically pass down to the subproc

Exception on keypress

2008-02-14 Thread Michael Goerz
Hi, I'm writing a command line program that watches a file, and recompiles it when it changes. However, there should also be a possibility of doing a complete clean restart (cleaning up temp files, compiling some dependencies, etc.). Since the program is in an infinite loop, there are limited

Re: Unicode char replace

2008-02-12 Thread Michael Goerz
DiMar wrote, on 02/12/2008 09:54 PM: > Hi all, > > I have this unicode string: > > string = u'Macworld » Jobs 1 - Twitter 0' > > and I want to replace the '»' (aka \xbb) char to '»'. > I've tried 2 ways: > > 1. string2 = string.replace('\\xbb','»') > u'Macworld \xbb Jobs 1 - Twitter 0' How

Catching a non-Exception object (KeyboardInterrupt)

2008-02-04 Thread Michael Goerz
Hi, when I try to catch ctrl+c with except KeyboardInterrupt: pychecker tells me Catching a non-Exception object (KeyboardInterrupt) It works fine, but the message indicates that it's not completely clean. How should I write the exception correctly? Thanks, Michael -- http://mail.python.o

Re: converting to and from octal escaped UTF--8

2007-12-03 Thread Michael Goerz
MonkeeSage wrote: > On Dec 3, 1:31 am, MonkeeSage <[EMAIL PROTECTED]> wrote: >> On Dec 2, 11:46 pm, Michael Spencer <[EMAIL PROTECTED]> wrote: >> >> >> >>> Michael Goerz wrote: >>>> Hi, >>>> I am writing unicode stings into a

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Goerz
MonkeeSage wrote: > Looks like escape() can be a bit simpler... > > def escape(s): > result = [] > for char in s: > result.append("\%o" % ord(char)) > return ''.join(result) > > Regards, > Jordan Very neat! Thanks a lot... Michael -- http://mail.python.org/mailman/listinfo/python-list

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Goerz
Michael Goerz wrote: > Hi, > > I am writing unicode stings into a special text file that requires to > have non-ascii characters as as octal-escaped UTF-8 codes. > > For example, the letter "Í" (latin capital I with acute, code point 205) > would come out as "

converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Goerz
Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as octal-escaped UTF-8 codes. For example, the letter "Í" (latin capital I with acute, code point 205) would come out as "\303\215". I will also have to read back from the file later on and con

calling locale.setlocale repeatedly

2007-09-15 Thread Michael Goerz
Hi, From http://www.pyzine.com/Issue008/Section_Articles/article_Encodings.html#guessing-the-encoding: > The way to access the information about the "normal" encoding used on the > current computer is through the locale module. Before using locale to > retrieve the information you want, you need