473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ANNOUNCE; Try python beta

Ok, I've given it the interface I want, and made it less of an
attractive nuisance.

http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #1
20 1602
Pretty neat =)

But aren't you concerned about security? Letting anybody execute
arbitrary Python expressions (and therefore also arbitrary system
commands?!) on your box --- even from within a FreeBSD jail --- seems a
bit dangerous.

Dec 20 '05 #2
Mike Meyer wrote:
Ok, I've given it the interface I want, and made it less of an
attractive nuisance.

http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.

<mike


I suggest it should work like IDLE do and not remain limited to
evaluating of expressions. One can easily get the impression Python is
very limited and this is not what can help Python to show its strengths.

By the way:

The page doesn't work for me in MSIE (I am on a Windows system)
1+1 SyntaxError: unexpected EOF while parsing (line 1)

It does work for me in FireFox and Netscape: 1+1 2

but in Opera I get: 1+1

祓瑮硡牅潲㩲*敮灸捥整⁤佅⁆桷汩 慰獲湩⁧氨湩⁥⤱>>>
I am most curious about the last one with no idea how it comes?

Maybe the subject of your posting should be changed to:

Try my skills in processing form requests from different Internet browser?

Claudio

Dec 20 '05 #3
Lonnie Princehouse wrote:
Pretty neat =)

But aren't you concerned about security? Letting anybody execute
arbitrary Python expressions (and therefore also arbitrary system
commands?!) on your box --- even from within a FreeBSD jail --- seems a
bit dangerous.


I found out about the FreeBSD jail myself, too ;-)

Removing __import__ from the builtins would make such detective work
much harder, though ;-)

-- Gerhard
Dec 20 '05 #4
Mike Meyer wrote:
Ok, I've given it the interface I want, and made it less of an
attractive nuisance.

http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.

I was bored so I wrote some code that takes input one line at a time
and spits out the a tuple representing the state and a message to be
echoed. It handles statements on multiple lines, too. So it might be
helpful, since your tutorial doesn't seem to handle multiple lines or
statements.

You can see it at <http://www.datamech.com/devan/bastille.txt>

Dec 20 '05 #5
"Lonnie Princehouse" <fi**************@gmail.com> writes:
Pretty neat =)
But aren't you concerned about security? Letting anybody execute
arbitrary Python expressions (and therefore also arbitrary system
commands?!) on your box --- even from within a FreeBSD jail --- seems a
bit dangerous.


What's there is actually more restricted than a FreeBSD jail. This one
has been tightened down to a statically linked Python interpreter, the
statically linked cgi program which does nothing but launch the Python
interpreter with the right arguments, and python library files. I've
even removed most of the latter that aren't used by the python
script. So yeah - you can run arbitrary system commands, except there
shouldn't be any.

The previous version was in a jail, which is why I didn't want it
generally announced. The logs made amusing reading. I like Gerhard's
idea of removing __import__, and have done that.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #6
Claudio Grondi <cl************@freenet.de> writes:
Mike Meyer wrote:
Ok, I've given it the interface I want, and made it less of an
attractive nuisance.
http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.
<mike I suggest it should work like IDLE do and not remain limited to
evaluating of expressions. One can easily get the impression Python is
very limited and this is not what can help Python to show its
strengths.


I thought about that. It's not clear that it's fixable at this
level. If not, it'll be documented.
By the way:
The page doesn't work for me in MSIE (I am on a Windows system)
>>> 1+1 SyntaxError: unexpected EOF while parsing (line 1)
Yeah, I know. I poked at it briefly, but couldn't figure out what was
goiing on. MSIE on the Mac doesn't work at all (no AJAT), and I don't
have regular access to a Windows box to try it on.
It does work for me in FireFox and Netscape: >>> 1+1 2
Also Safari, Mozilla and Netscape. If you try it with a browser
without XMLHttpRequest, it'll suggest them.
but in Opera I get: >>> 1+1
祓瑮硡牅潲㩲*敮灸捥整⁤佅⁆桷汩 慰獲湩⁧氨湩⁥⤱>>>


Yup, I've seen that one as well. I have *no* idea what Opera thinks
it's doing. Adding a charset to the content-type didn't solve the
problem. I checked opera's web site, and couldn't find a page for web
developers.

I've added a note about these problems.
Maybe the subject of your posting should be changed to:
Try my skills in processing form requests from different Internet browser?


Actually, it's doing form processing. It's doing XMLHttpRequests.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #7
It does work for me in FireFox and Netscape:
>>> 1+1

2


Mike> Also Safari, Mozilla and Netscape.

I tried 4+3 in Safari and got

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
we*******@mired.org and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>Apache/1.3.26 Server at www.mired.org Port 80</ADDRESS>
</BODY></HTML>

in the terminal just now (9:05 or so CST).

Skip
Dec 20 '05 #8
Mike Meyer wrote:
The previous version was in a jail, which is why I didn't want it
generally announced. The logs made amusing reading. I like Gerhard's
idea of removing __import__, and have done that.


Oh, you have, eh? Are you absolutely sure? Try running "grep 'all your
base' log".

-- David

Dec 20 '05 #9
"David Wahler" <dw*****@gmail.com> writes:
Mike Meyer wrote:
The previous version was in a jail, which is why I didn't want it
generally announced. The logs made amusing reading. I like Gerhard's
idea of removing __import__, and have done that.

Oh, you have, eh? Are you absolutely sure? Try running "grep 'all your
base' log".


Yup, removing it securely is more trouble than it's worth. Which is
why this is running in a sandbox inside a jail - I knew that securing
Python was a probably impossible.

I put __import__ back, and even imported os just to save you some
time. I also put the expression that will get do the equivalent of "ls
-R /" up for anyone to read.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #10
sk**@pobox.com writes:
>> It does work for me in FireFox and Netscape:
>> >>> 1+1
>> 2

Mike> Also Safari, Mozilla and Netscape.
I tried 4+3 in Safari and got


I've been futzing with it all evening. Various things I've done have
broken it in strange ways. It's working now (or was - someone may have
found a way to break it).

I'm tempted to put in a hook to log expressions and let people play
them back - it's kind of amusing.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #11
Mike Meyer wrote:
Ok, I've given it the interface I want, and made it less of an
attractive nuisance.

http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.


Very nice though a little tedious to use ;)

Working on Windows XP behind a proxy ( trying both Mozilla + Internet
Explorer ) and typing
1+2


results in a HTML request in the output field of the console:

<html>
<head>
<title> Data Transfer Status Report </title>
<META http-equiv="Refresh" content="1;
URL=http://www.mired.org/home/mwm/try_python/GGTSPU-fw1.gdm.de-1305-446462-DAT/python.sbox?%3E%3E%3E%201+2">
</head>
<body bgcolor="#ffffff">
<h2> Data Transfer Status Report</h2>
<hr>
<table>
<tr><td align=right>URL:</td><td align=left><b><a
href="http://www.mired.org/home/mwm/try_python/python.sbox?%201+2">http://www.mired.org/home/mwm/try_python/python.sbox?%201+2</a></b></td></tr>

etc.

The interesting issue is the provided link. Copying the HTML output
into a file and executing it opens a file transfer connection. The
result is as expected:

python.sbox

It contains the correct result: it is 3 :)

Kay

Dec 20 '05 #12

[Claudio]
The page doesn't work for me in MSIE (I am on a Windows system)
[Mike] Yeah, I know. I poked at it briefly, but couldn't figure out what was
goiing on. MSIE on the Mac doesn't work at all (no AJAT), and I don't
have regular access to a Windows box to try it on.


I think it's your JavaScript '\r' processing that's broken. Certainly the
error ("unexpected EOF while parsing") is consistent with having a \r on the
end of the expression. Won't this:

if (input.length == 1)

always fail in the case where the user has typed a newline? I'd ditch that
code and do it at the server end:

expr = expr[4:].strip()

--
Richie Hindle
ri****@entrian.com
Dec 20 '05 #13
Mike Meyer wrote:

[Browser behaviour]
Actually, it's doing form processing. It's doing XMLHttpRequests.


You might want to add some workarounds for Konqueror. What I found was
that Konqueror (on KDE 3.4.0) has a tendency to add null bytes to the
end of some form field values. Consequently, I get mostly "SyntaxError:
unexpected EOF while parsing (line 1)" in that browser. It could well
be that other browsers also have their quirks with XMLHttpRequest.

Paul

Dec 20 '05 #14
Richie Hindle <ri****@entrian.com> writes:
Yeah, I know. I poked at it briefly, but couldn't figure out what was
goiing on. MSIE on the Mac doesn't work at all (no AJAT), and I don't
have regular access to a Windows box to try it on.
I think it's your JavaScript '\r' processing that's broken. Certainly the
error ("unexpected EOF while parsing") is consistent with having a \r on the
end of the expression.


Python doesn't care about the trailing newline.
Won't this:

if (input.length == 1)

always fail in the case where the user has typed a newline? I'd ditch that
code and do it at the server end:


The point of the '\r' processing is to make sure we don't send the
entire text area string to the server. That breaks things pretty
badly. My assumption is that if splitting on '\n' leaves us with one
thing, we may have gotten a string that used \r for newlines, so we
split on that. Hmm. If the results of the first split left us with
"'\r'expr", then the second split will send an empty string, which
would result in what we're seeing.

I'll investigate that.

thanks,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #15

[Richie]
I think it's your JavaScript '\r' processing that's broken. Certainly the
error ("unexpected EOF while parsing") is consistent with having a \r on the
end of the expression.
[Mike] Python doesn't care about the trailing newline.
That's a carriage return, not a newline:
eval("1+2\r") Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 1
1+2
^
SyntaxError: unexpected EOF while parsing
My assumption is that if splitting on '\n' leaves us with one
thing, we may have gotten a string that used \r for newlines


Ah, OK. Your comment talks about DOS - that won't happen on DOS (or
Windows) which uses \r\n. I don't know about the Mac. But the \r\n pair
isn't handled by your code - strip() on the server side will make it work if
that's the problem:
eval("1+2\r".strip())

3

--
Richie Hindle
ri****@entrian.com
Dec 20 '05 #16
Richie Hindle <ri****@entrian.com> writes:
My assumption is that if splitting on '\n' leaves us with one
thing, we may have gotten a string that used \r for newlines

Ah, OK. Your comment talks about DOS - that won't happen on DOS (or
Windows) which uses \r\n. I don't know about the Mac. But the \r\n pair
isn't handled by your code - strip() on the server side will make it work if
that's the problem:


You mean there's a difference between DOS and Windows?

The Mac stuff I can test, so that's easier to get right.
eval("1+2\r".strip())

3


I actually did wind up doing it this way. MSIE works now, but still
doesn't seem very reliable.

Thanks,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 20 '05 #17
On 20 December 2005, Mike Meyer wrote:
Ok, I've given it the interface I want, and made it less of an
attractive nuisance.

http://www.mired.org/home/mwm/try_python/ is now ready for people to
play with. There's no tutorial information on it yet, that's the next
thing to do. However, I won't be able to work on it for a while, so if
you want to make suggestions about what that should look like, all
such suggestions will be given proper consideration.


I'm not sure about everyone else, but I find the big warnings about
CSS and JavaScript almost as annoying as the fact that it doesn't do
anything. At all, even with JavaScript enabled. Then again, my main
browser is elinks, so my opinion is somewhat biased.

If you get it working in Lynx, supporting other browsers should be
easier than the other posts make this solution sound.

- Eric
Dec 21 '05 #18
I'm afraid that I've spoiled the "try_python" working by means of
executing the sentence:

open("try.py").write("\n")

Sorry. I hope it don't be difficult for you to restore the module again
to the default folder.

In any case, I think it should include some control for malicious code
like that one.

Dec 21 '05 #19
"Maravilloso" <ma*********@gmail.com> writes:
I'm afraid that I've spoiled the "try_python" working by means of
executing the sentence:

open("try.py").write("\n")

Sorry. I hope it don't be difficult for you to restore the module again
to the default folder.
No problem - I'm not crazy enough to leave unreplaceable data on a
machine with open incoming ports.
In any case, I think it should include some control for malicious code
like that one.


Normally, it is. I must have left the module writeable after updating
it :-(. It's been replaced, and if you try that now you'll get an
IOError.

Thanks for reporting it.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 21 '05 #20
Eric <gr****@brainshell.org> writes:
I'm not sure about everyone else, but I find the big warnings about
CSS and JavaScript almost as annoying as the fact that it doesn't do
anything. At all, even with JavaScript enabled. Then again, my main
browser is elinks, so my opinion is somewhat biased.
Well, if you have CSS working properly and JavaScript enabled, you
won't get the warnings. Would you honestly prefer that it just quietly
not work at all, rather than tell you why it doesn't work? At least it
doesn't insult your intelligence by telling you how to enable them for
browsers you aren't using.
If you get it working in Lynx, supporting other browsers should be
easier than the other posts make this solution sound.


True. On the other hand, it was designed from the ground up to use
AJAT, to keep the traffic required to update the page at a sane
level. Future plans also depend on JavaScript, since it's required for
the basic functionality in any case.

A version could be designed that didn't keep the history around that
would work in lynx (though I'd test it in my preference: w3m) and used
the same evaluation back end. That would look a lot less like the
python interpreter, though. If you want to do that, I'd be more than
happy to provide a link to it, or even host it. Otherwise, I'll think
about it after I finish the currently planned version.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 21 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg | last post by:
The following article from microsoft describes a workaroind for a bug in hte beta version of VISUAL PYTHON DOT NET ...
15
by: John Machin | last post by:
I am pleased to announce a new general release (0.5.2) of xlrd, a Python package for extracting data from Microsoft Excel spreadsheets. CHANGES: * Book and sheet objects can now be pickled and...
2
by: Gregory (Grisha) Trubetskoy | last post by:
The Apache Software Foundation and The Apache HTTP Server Project are pleased to announce the 3.3.0b (Beta) release of mod_python. Version 3.3.0b of mod_python features several new functions and...
0
by: Steven Knight | last post by:
SCons is a software construction tool (build tool, or make tool) written in Python. It is based on the design which won the Software Carpentry build tool competition in August 2000. Version...
0
by: Wingware | last post by:
Hi, We're happy to announce the release of Wing IDE 3.0, an advanced development environment for the Python programming language. It is available from: http://wingware.com/ Wing IDE...
0
by: giles.thomas | last post by:
We're proud to announce that today Resolver One, our flagship application, entered its public Beta phase. It can be downloaded from <http://www.resolversystems.com/download/(free registration...
1
by: Steven Knight | last post by:
SCons is a software construction tool (build tool, or make tool) written in Python. It is based on the design which won the Software Carpentry build tool competition in August 2000. Version...
0
by: mh | last post by:
I'm pleased to announce the initial release of OraPIG, the Oracle Python Interface Generator. OraPIG generates Python wrapper classes for Oracle packages. If you use Oracle and Python, this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.