Re: python scripts with IIS

2008-01-19 Thread Rolf van de Krol
Adding the following lines before your print statement should do the 
trick. IIS complains about the headers, so adding headers should help.

print "Content-Type: text/html" # HTML is following
print   # blank line, end of headers



william paul wrote:
>  
> Hello:
>  
> I am trying to configure IIS to work with Python scripts:
>  
> I've added in the Home Directory/Configuration the .py extention and 
> the path to the python.exe as: c:\Python24\python.exe %S %S
> The python script has 1 line:
> print "This is a test for python scripts with IIS"
>  
> When I launch the file using IE I get the message:
>  
> *CGI Error*
> The specified CGI application misbehaved by not returning a complete 
> set of HTTP headers. The headers it did return are:
>  
> This is a test for python scripts with IIS
>  
> How can I remove the CGI error?
>  
> Thank you
>  
> William
>
> 
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try 
> it now. 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin, stdout, redmon

2008-01-21 Thread Rolf van de Krol
According to various tutorials this should work.


|import sys
data = sys.stdin.readlines()
print "Counted", len(data), "lines."|


Please use google before asking such questions. This was found with only 
one search for the terms 'python read stdin'

Rolf

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.
> Redmon send the data flow to the standard input and lauchs the Python 
> program which send modified data to the standard output (Windows XP and 
> Python 2.5 context).
> I can manipulate the standard output.
>
> "import sys
> sys.stdout.write(data)"
>
> it works.
> But how to manipulate standard input so that I can store data in a 
> string or in an object file ? There's no "read" method.
>
> "a = sys.stdin.read()" doesn't work.
> "f = open(sys.stdin)" doesn't work.
>
> I don't find anything in the documentation. How to do that ?
> Thanks in advance.
>
> Bernard Desnoues
> Librarian
> Bibliothèque de géographie - Sorbonne
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin, stdout, redmon

2008-01-21 Thread Rolf van de Krol
I don't know what you did with your Python installation, but for me this 
works perfectly.

test3.py contains:

import sys

print sys.stdin.readlines()


test.txt contains:

Testline1
Testline2


Output of 'python test3.py < test.txt' is:

['Testline1\n', 'Testline2']


Just plain simple and just works.

Rolf



Bernard Desnoues wrote:
> Rolf van de Krol a écrit :
>   
>> According to various tutorials this should work.
>>
>> 
>> |import sys
>> data = sys.stdin.readlines()
>> print "Counted", len(data), "lines."|
>> 
>>
>> Please use google before asking such questions. This was found with only 
>> one search for the terms 'python read stdin'
>>
>> Rolf
>>
>> 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.
>>> Redmon send the data flow to the standard input and lauchs the Python 
>>> program which send modified data to the standard output (Windows XP 
>>> and Python 2.5 context).
>>> I can manipulate the standard output.
>>>
>>> "import sys
>>> sys.stdout.write(data)"
>>>
>>> it works.
>>> But how to manipulate standard input so that I can store data in a 
>>> string or in an object file ? There's no "read" method.
>>>
>>> "a = sys.stdin.read()" doesn't work.
>>> "f = open(sys.stdin)" doesn't work.
>>>
>>> I don't find anything in the documentation. How to do that ?
>>> Thanks in advance.
>>>
>>> Bernard Desnoues
>>> Librarian
>>> Bibliothèque de géographie - Sorbonne
>>>   
>
> Hello Rolf,
>
> I know this code because I have search a solution !
> Your google code doesn't work ! No attribute "readlines".
>
>  >>> import sys
>  >>> data = sys.stdin.readlines()
>
> Traceback (most recent call last):
>File "", line 1, in 
>  data = sys.stdin.readlines()
> AttributeError: readlines
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stdin, stdout, redmon

2008-01-22 Thread Rolf van de Krol
Well, that's at least weird. I did test my code with Python 2.5 on Win 
XP, using the command prompt. But testing it with IDLE gives exactly the 
same error Bernard has. So apparently STDIN can't be accessed with IDLE.

Rolf

John Machin wrote:
>
> Excuse me, gentlemen, may I be your referee *before* you resort to
> pistols at dawn?
>
> = IDLE =
> IDLE 1.2.1
>   
 import sys
 sys.stdin.readlines
 
>
> Traceback (most recent call last):
>   File "", line 1, in 
> sys.stdin.readlines
> AttributeError: readlines
>   
>
> = Command Prompt =
> C:\junk>python
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>   
 import sys
 sys.stdin.readlines
 
> 
>   
>
> HTH,
> John
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing other python code

2008-01-28 Thread Rolf van de Krol
AFAIK this can't be done with just python. You can use the C API of 
Python to achieve this. I don't know the details of that, but I guess 
you will need this (http://docs.python.org/api/api.html).

Rolf

Tim Rau wrote:
> I'm working on a game, and I'd like players to be able to define thier
> ships with scripts. Naturally, I don't want to give them the entire
> program as thier romping ground. I would like to invoke a seperate
> interpreter for these files, and give it a limited subset of the
> functions in my game. What is the best way to achieve this effect?
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.2/Linux] Getting Python to fork?

2008-02-04 Thread Rolf van de Krol
To create a deamon, you indeed need to fork two times. For more 
information and a working example see: 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 . I'm 
quite sure this works, because I used it several times to create a deamon.


Jon Ribbens wrote:
> On 2008-02-04, Christian Heimes <[EMAIL PROTECTED]> wrote:
>   
>>> Although bear in mind it's pretty UNIX-y.
>>>   
>> IIRC you have to fork a second time after you have changed the working
>> dir and created a new session group.
>> 
>
> Why? I don't think you do.
> Neither does BSD daemon.c or glibc daemon.c
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Write ooxml .ods (spreadsheat) from python?

2008-02-13 Thread Rolf van de Krol
Neal Becker wrote:
> I'd like to output some data directly in .ods format.  This format appears
> to be quite complex.  Is there any python software available to do this?  I
> did look at pyuno briefly.  It looks pretty complicated also, and it looks
> like it uses it's own private version of python, which would not help me.
>   
Google is your friend. For example this: 
http://www.oooforum.org/forum/viewtopic.phtml?p=56037#56037
It seems like that guy found the way to go for your problem.

Rolf

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


Re: Reading a keypress

2008-02-25 Thread Rolf van de Krol
wyleu wrote:
> Aaah it doesn't work from idle but it does from the command line...
>
>   
You are right. You can't read STDIN from IDLE. There has been a topic 
about that before: 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/9f9c90cfe52378fe

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


Re: Is this valid ?

2008-03-20 Thread Rolf van de Krol
John Machin wrote:
> Of course. You can chain comparisons as much as you like and is
> (semi-)sensible, e.g.
>   
Hmm, 'of course' is not the correct word for it. Although the Stef 
Mientki would probably be able to find it in the documentation it is not 
as simple as you might think.
Most languages interpret a == b == 2 as (a == b) == 2, or throw an error 
because this syntax is not valid. The fact that python understand the 
obvious meaning of this code, is quite unique to Python, as far as I know.
-- 
http://mail.python.org/mailman/listinfo/python-list