[issue39853] Segmentation fault with urllib.request.urlopen and threads

2021-02-18 Thread Gilles Duboscq


Gilles Duboscq  added the comment:

Thanks Victor we'll look into moving away from this pattern.

--

___
Python tracker 
<https://bugs.python.org/issue39853>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39853] Segmentation fault with urllib.request.urlopen and threads

2021-02-18 Thread Gilles Duboscq


Gilles Duboscq  added the comment:

I get '0' so it was not built with HAVE_GETHOSTBYNAME_R.

--

___
Python tracker 
<https://bugs.python.org/issue39853>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39853] Segmentation fault with urllib.request.urlopen and threads

2021-02-18 Thread Gilles Duboscq


Gilles Duboscq  added the comment:

I'm not sure it's the same but we have seen stack traces looking like the one 
there: https://github.com/astropy/astropy/issues/9699

Current thread 0x7fffa857e3c0 (most recent call first):
  File "/sw/lib/python3.7/socket.py", line 748 in getaddrinfo
  File "/sw/lib/python3.7/socket.py", line 707 in create_connection
  File "/sw/lib/python3.7/http/client.py", line 938 in connect
  File "/sw/lib/python3.7/http/client.py", line 966 in send
  File "/sw/lib/python3.7/http/client.py", line 1026 in _send_output
  File "/sw/lib/python3.7/http/client.py", line 1247 in endheaders
  File "/sw/lib/python3.7/http/client.py", line 1298 in _send_request
  File "/sw/lib/python3.7/http/client.py", line 1252 in request

For us it happens when using multiprocessing: the main process forks 2 
processes and both use urlopen at roughly the same time. We are seeing this on 
Python 3.7.2 on macOS 10.14.3.

--
nosy: +gilles-duboscq

___
Python tracker 
<https://bugs.python.org/issue39853>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18319] gettext() cannot find translations with plural forms

2020-05-07 Thread Gilles Bassière

Gilles Bassière  added the comment:

Hi there,

I worked on a patch for this issue (see attached pull request).

I would be happy to discuss it with people involved in gettext module 
maintenance but I'm not sure how to contact them. Is there a dedicated mailing 
list or an IRC channel or something? I've found i18n-sig but it has been 
inactive for 5 years...

Best regards
Gilles

--

___
Python tracker 
<https://bugs.python.org/issue18319>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18319] gettext() cannot find translations with plural forms

2020-05-01 Thread Gilles Bassière

Change by Gilles Bassière :


--
nosy: +Gilles Bassière
versions: +Python 3.7

___
Python tracker 
<https://bugs.python.org/issue18319>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39539] Improve Keccak support in hashlib including KangarooTwelve

2020-02-03 Thread Gilles Van Assche

New submission from Gilles Van Assche :

Dear all,

I think it would be nice if hashlib would include the support of Keccak with a 
chosen suffix, as well as the fast instance KangarooTwelve (K12).

1) Currently, hashlib's interface for Keccak only supports the 6 instances of 
FIPS 202 (SHA3-* and SHAKE*). However, the instances in NIST SP 800-185 
(cSHAKE, KMAC, …) use a different suffix and therefore cannot be instantiated 
on top of the aforementioned 6 instances. Instead, simply adding the suffix as 
an argument to the constructor would enable a user to instantiate plain Keccak 
(as in Ethereum) or the SP 800-185 instances.

2) K12 is an alternative hash function (and XOF) in the Keccak family. It is 
fast, parallelizable and it benefits directly from the cryptanalysis on the 
(unchanged) underlying permutation since 2008. This would be IMHO a valuable 
addition to hashlib. Among others, implementations of K12 can be found in the 
XKCP on GitHub.

Kind regards,
Gilles (co-designer of Keccak and K12)

--
components: Library (Lib)
messages: 361280
nosy: gvanas
priority: normal
severity: normal
status: open
title: Improve Keccak support in hashlib including KangarooTwelve
type: enhancement
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39539>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37930] make fails when compiling Python 2.6 from source (posixmodule.c)

2019-10-21 Thread Gilles Bardoux


Gilles Bardoux  added the comment:

Hi Oguz,
You just need to change one line in Include/objimpl.h: replace "long double 
dummy" by "double dummy". Enjoy!

--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -248,7 +248,7 @@ typedef union _gc_head {
 union _gc_head *gc_prev;
 Py_ssize_t gc_refs;
 } gc;
-long double dummy;  /* force worst-case alignment */
+double dummy;  /* force worst-case alignment */
 } PyGC_Head;
 
 extern PyGC_Head *_PyGC_generation0;

--
nosy: +gilles.bardoux

___
Python tracker 
<https://bugs.python.org/issue37930>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Parsing multipart HTTP response

2015-08-03 Thread Gilles Lenfant
Hi,

I searched without succeeding a Python resource that is capable of parsing an 
HTTP multipart/mixed response stream, preferably as a generator that yields 
headers + content for each part.

Google and friends didn't find or I didn't use the appropriate term.

Any hint will be appreciated.
--
Gilles Lenfant
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing multipart HTTP response

2015-08-03 Thread Gilles Lenfant
Le lundi 3 août 2015 17:01:40 UTC+2, Gilles Lenfant a écrit :
 Hi,
 
 I searched without succeeding a Python resource that is capable of parsing an 
 HTTP multipart/mixed response stream, preferably as a generator that yields 
 headers + content for each part.
 
 Google and friends didn't find or I didn't use the appropriate term.
 
 Any hint will be appreciated.
 --
 Gilles Lenfant

Ah, aiohttp does something similar to what I need but requires Python 3.3 + 
when I'm stuck with Pyton 2.7 on that project.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing multipart HTTP response

2015-08-03 Thread Gilles Lenfant
Le lundi 3 août 2015 17:39:57 UTC+2, Mark Lawrence a écrit :
 On 03/08/2015 16:01, Gilles Lenfant wrote:
  Hi,
 
  I searched without succeeding a Python resource that is capable of parsing 
  an HTTP multipart/mixed response stream, preferably as a generator that 
  yields headers + content for each part.
 
  Google and friends didn't find or I didn't use the appropriate term.
 
  Any hint will be appreciated.
  --
  Gilles Lenfant
 
 
 Hardly my field but how about:-
 
 https://pypi.python.org/pypi/requests-toolbelt/0.3.1
 https://pypi.python.org/pypi/multipart/
 
 -- 
 My fellow Pythonistas, ask not what our language can do for you, ask
 what you can do for our language.
 
 Mark Lawrence

Thanks Mark,

multipart is close to what I need and will give me some inpiration. 
Unfortunately, it works for multipart/form-data server-side handling, when I'm 
searching for a multipart/mixed client side handling of a response. In 
addition, it does not yield the headers specific to each data chunk from the 
response, and I need those headers.

To be more specific, I'm buiding with the excellent requests lib and Python 
2.7 (sorry, I can't go to Python 3.x at the moment) a client library for the 
documents database MarkLogic 8 that provides some APIs with multipart/mixed 
responses like this one:

http://docs.marklogic.com/REST/POST/v1/eval

In other words I need something that may be used like this :

response = requests.post(some_uri, params=some_params, stream=True)
if response.headers['content-type'].startswith('multipart/mixed'):
boundary = parse_boundary(response.headers['content-type'])

generator = iter_multipart_response(response, boundary)
for part_headers, part_body in generator:
# I'm consuming parsed headers and bodies from response
# In my application code

Cheers
-- 
Gilles Lenfant
-- 
https://mail.python.org/mailman/listinfo/python-list


Stopping a wsgiref server programmatically

2014-01-14 Thread Gilles Lenfant
Hi,

I made a small / minimal wsgiref HTTP server dedicated to unittest stubs 
(testing custom REST client and other likes) that works pretty good in a 
separate thread.

https://gist.github.com/glenfant/7369894

Feel free to reuse it in your own unittest stubs/mocks.

But it only works like a charm in an Unix box, due to the use of a control pipe 
( https://gist.github.com/glenfant/7369894#file-pipetestserver-py-L118 ) that's 
checked with select.select ( 
https://gist.github.com/glenfant/7369894#file-pipetestserver-py-L133 ) and can 
be stopped on request when writing in that pipe ( 
https://gist.github.com/glenfant/7369894#file-pipetestserver-py-L173 ).

Is there a volunteer with a Windows box for helping me to get it fixed. Note: I 
have no windows box to experiment alternate.

Many thanks by advance.
-- 
Gilles Lenfant
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Skipping decorators in unit tests

2013-10-11 Thread Gilles Lenfant
Cameron, Steven, Ben, Ned, Terry, Roy. Many thanks for this interesting 
discussion.

I ended up... mixing some solutions provided by your hints :

* Adding an __original__ attribute to the wrapper func in the decorators of 
my own
* Playing with func_closure to test functions/methods provided by 3rd party 
tools

Cheers and thanks again for taking time to help me.

-- 
Gilles Lenfant
-- 
https://mail.python.org/mailman/listinfo/python-list


Skipping decorators in unit tests

2013-10-10 Thread Gilles Lenfant
Hi,

(explaining the title) : my app has functions and methods (and maybe classes in 
the future) that are decorated by decorators provided by the standard library 
or 3rd party packages.

But I need to test undecorated functions and methods in my unit tests, 
preferably without adding special stuffs in my target tested modules.

Can someone point out good practices or dedicated tools that remove 
temporarily the decorations.

I pasted a small example of what I heed at http://pastebin.com/20CmHQ7Y

Many thanks in advance
-- 
Gilles Lenfant
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [GUI] Good frameworks for Windows/Mac?

2013-08-08 Thread Gilles
On Thu, 8 Aug 2013 01:47:21 -0700 (PDT), sagar varule
sagar.var...@gmail.com wrote:
Pyside is also Good. It has a Designer which can be helpful.

Thanks for the info.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ActivePython] Add Qt/PyQt and wxWidgets/wxPython?

2013-08-08 Thread Gilles
Hello

I upgraded to ActivePython 2.7.2.5, and would like to get started
learning about Qt and wxWidgets in Python.

I have a couple of question:

1. Are there obvious reasons to choose either QT/PyQt or
wxWidgets/wxPython? I have the impression that Qt is a richer GUI than
wxWidgets, but it could just be an impression.

2. Is there a no-brainer article that explains how to add Qt and
wxWidgets to ActivePython community edition, since they're only
included in the Business and Enterprise editions?

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


Re: Source code to identify user through browser?

2013-08-06 Thread Gilles
On Wed, 05 Jun 2013 15:08:54 +0200, Gilles nos...@nospam.com wrote:
I was wondering if some Python module were available to identify a
user through their browser, like it's done on the Panopticlick site:

http://panopticlick.eff.org/

It appears that flash cookies is a better solution to keep most trolls
away from a forum/blog:

www.stackoverflow.com/questions/216542/

Still, I wish there a browser that could run in real incognito mode,
ie. would only send the minimum amount of infos to the server.
-- 
http://mail.python.org/mailman/listinfo/python-list


[GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Gilles
Hello

I need to write a small GUI application that should run on Windows and
Mac.

What open-source framework would you recommend? I just need basic
widgets (button, listbox, etc.) and would rather a solution that can
get me up and running fast.

I know about wxWidgets and Qt: Are there other good options I should
know about?

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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-06 Thread Gilles
On Sat, 3 Aug 2013 06:47:07 -0500 (CDT), Wayne Werner
wa...@waynewerner.com wrote:
Have you checked Kenneth Rietz's inbox.py[1]? It's fairly simple to 
use/extend and might fit your modest needs.


-W

[1]:https://crate.io/packages/inbox/

Thanks. I'll check it out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-06 Thread Gilles
On Sat, 03 Aug 2013 21:41:16 -0400, Kevin Walzer k...@codebykevin.com
wrote:
For what it's worth, that hasn't been my experience.

Thanks for the feedback. I'll experiment and see how it goes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-06 Thread Gilles
On Sat, 3 Aug 2013 10:57:32 -0700 (PDT), Aseem Bansal
asmbans...@gmail.com wrote:
I found Python3's sqlite3 library. I found that I needed sql commands for 
using it.

I have tried sql.learncodethehardway but it isn't complete yet. I tired 
looking on stackoverflow's  sql tag also but nothing much there.

It'll be easier to read tutorials specifically meant to use Sqlite
with Python:

www.google.com/search?q=python+sqlite+examples
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Gilles
On Tue, 6 Aug 2013 13:22:01 +0200, Vlastimil Brom
vlastimil.b...@gmail.com wrote:
I mostly use wxPython myself, but if you just need some basic widgets
and not some very complex or non-standard layouts, the tkinter -
available in the standard library - might be perfectly viable.
http://docs.python.org/3.3/library/tk.html
The more recent versions of python also support ttk and Tix which has
further possibilities, styling etc.
There is further e.g. Python GUI
http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/

and several others
http://wiki.python.org/moin/GuiProgramming

Thanks for the links. I'll play with Tkinter, and if it's not good
enough, check the alternatives.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ActivePython] Upgrading fails

2013-08-06 Thread Gilles
Hello,

I already posted in their forum, but got no reply and figured some
people here might have experienced this too.

I'm currently running ActivePython 2.5.1.1 on my XP Pro host.

After downloading and running the installer to 2.7.2.5, I get the
following error message:

Windows Installer: The Windows Installer Service could not be
accessed. This can occur if the Windows Installer is not correctly
installed.

Has someone seen this, and knows what to do?

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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-01 Thread Gilles
On Wed, 24 Jul 2013 10:38:52 -0400, Kevin Walzer k...@codebykevin.com
wrote:
 Thanks. hMailServer was one of the apps I checked, and I was just
 making sure there weren't something simpler, considering my needs,
 ideally something like Mongoose MTA.

 Regardless, because of the SPAM anti-measures mentioned above, it
 seems like I was over-optimistic about running an MTA and sending
 e-mails from my home computer :-/


The reason I mentioned hMailServer is that I host my own mail server for 
my business--I have a static IP address, and correctly configured 
DNS--and so I'm able to send out large batches of e-mails to customers 
from my network without being blocked by my ISP. I'm running a Mac 
server so my mail system is the typical Unix setup (Postfix, etc.), but 
hMailServer was the closest thing I've found for Windows.

Configuring your own server isn't cheap in terms of time even if you use 
FOSS components, and your ISP may charge more for a static IP, so I 
completely understand if you don't want to go that route.

Thanks for the infos. Indeed, it seems like hMailServer is one of the
few good MTAs for Windows.

I already have a static IP, so the issue is more that remote MTAs
might not accept connections from MTAs running on users' PC instead of
ISP's.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-23 Thread Gilles
On Mon, 22 Jul 2013 08:54:11 -0400, Eric S. Johansson
e...@harvee.org wrote:
try http://emailrelay.sourceforge.net/

Thanks. I did find it, but it says it's not a full MTA:

E-MailRelay is not a routing MTA. It forwards e-mail to a
pre-configured SMTP server, regardless of any message addressing or
DNS redirects.
http://emailrelay.sourceforge.net/userguide.html#SH_1_2

IOW, it'll just send outbound e-mails to my ISP's MTA, so I'm back at
square one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-23 Thread Gilles
On Mon, 22 Jul 2013 08:10:10 -0600, Michael Torrie torr...@gmail.com
wrote:
Where did you look?  Here's one I found.  It's not the real sendmail
program, but it implements the interface which is all you need:

http://glob.com.au/sendmail/

I just googled for sendmail win32

Thanks, but I need an MTA, not just a command-line app, so I can send
e-mails from my e-mail client and just change the SMTP line in the
configuration.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-23 Thread Gilles
On Mon, 22 Jul 2013 10:14:15 -0400, Kevin Walzer k...@codebykevin.com
wrote:
http://www.hmailserver.com

Thanks. hMailServer was one of the apps I checked, and I was just
making sure there weren't something simpler, considering my needs,
ideally something like Mongoose MTA.

Regardless, because of the SPAM anti-measures mentioned above, it
seems like I was over-optimistic about running an MTA and sending
e-mails from my home computer :-/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Gilles
On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie torr...@gmail.com
wrote:
The Sendmail MTA has been ported to many platforms including windows.
But...

Thanks for the tip. Since I couldn't find a good, basic, native
Windows app, I was indeed about to look at eg. Exim + Cygwin, and
resort to a Linux appliance if none footed the bill.

 I'm not sure my ISP blocks outbound port 25 connections. I'll
 experiment with a small Linux box.

Having spent a long time managing e-mail servers, everything Ivan said
in his reply is true as well.  I had forgotten a lot of that since I
haven't been running my own mail server (MTA or server part) in a while.

Indeed, I had forgotten about some MTAs refusing incoming e-mails from
other ISP's customer hosts. I'll experiment.

But then how would it know that legit-looking e-mails aren't in fact
SPAM?

It generally does a good job, but every once in a while, some
perfectly good e-mail I'm sending is flagged as SPAM. To keep all my
e-mails in the same client, I'd rather use a local MTA than sending
the e-mail from Gmail.

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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Gilles
On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards
invalid@invalid.invalid wrote:

Unless you've got a static IP address, a domain name, and a valid MX
record that will match up when they do a reverse DNS lookup, it's
pretty unlikely that you're going to have much luck running an SMTP
server.  Most other SMTP servers are probably going to ignore or
reject your attempts to transfer mail from your own SMTP server.

I had forgotten about this. I'll give a try, and see how it goes.

I'd recommend postfix or exim if I was going to try to do it, but I
think they're Unix-only.

Thanks for the tip. Looks like Exim is available on Windows through
Cygwin
http://blogostuffivelearnt.blogspot.fr/2012/07/smtp-mail-server-with-windows.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Gilles
On Sun, 21 Jul 2013 21:01:09 + (UTC), Grant Edwards
invalid@invalid.invalid wrote:
Unless you've got a static IP address, a domain name, and a valid MX
record that will match up when they do a reverse DNS lookup, it's
pretty unlikely that you're going to have much luck running an SMTP
server.  Most other SMTP servers are probably going to ignore or
reject your attempts to transfer mail from your own SMTP server.

Incidently, how do ISP MTAs find whether the remote MTA is legit or
running on some regular user's computer?

1. Query Reverse DNS for IP
2. Find domain
3. Query DNS for MX
4. ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Gilles
On Mon, 22 Jul 2013 22:29:42 +1000, Chris Angelico ros...@gmail.com
wrote:
One thing to check when you change how you send mail is your SPF
record. I run the mail server for kepl.com.au and have set its SPF to:

v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all

If your SPF is as strict as mine (and if it's not, please make it so,
for the sake of the rest of the world!), you'll want to check it
before you start sending mail directly from your own computer.
Otherwise your mail _will_ be rejected as spam.

Thanks for the tip. I didn't know about SPF
http://en.wikipedia.org/wiki/Sender_Policy_Framework
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple Python script as SMTP server for outgoing e-mails?

2013-07-21 Thread Gilles
Hello

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-21 Thread Gilles
On Mon, 22 Jul 2013 00:48:29 +1000, Chris Angelico ros...@gmail.com
wrote:
Rather than write something from scratch, I'd look at deploying
something out-of-the-box - Postfix, for instance - which you will be
able to configure much faster than writing your own. And then you
could have it either send via your ISP or send directly to the
receiving MTA, without much extra effort.

Thank you but precisely, I was looking for a ready-to-use solution in
Python so that I wouldn't have to write it myself.

Also, I don't need a full-fledged SMTP server, just a tiny script that
will let me send the occasional e-mails from my e-mail client that my
ISP wrongly considers as SPAM.

So, does someone know of a good, SMTP server just to send e-mails?

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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-21 Thread Gilles
On Sun, 21 Jul 2013 11:46:52 -0600, Michael Torrie torr...@gmail.com
wrote:
What you're looking for is not an SMTP server but a Mail Transfer Agent,
called an MTA.

Pretty much all distros ship with an MTA by default, even if the SMTP
server part of it isn't installed or running. And often the MTA is, for
compatibility reasons, /usr/sbin/sendmail.

http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

I'm sure there are MTA's implemented in python. Now that you know what
they are called (not SMTP servers!) you can search for them.

Dennis is correct, though, that most ISPs do block outbound port 25
connections for security and spam reasons, and require you to use their
SMTP server, which precludes the use of the local MTA.

Thanks for the infos. Ideally, I was looking for a simple Windows app
as MTA, but a Python script is OK.

I'm not sure my ISP blocks outbound port 25 connections. I'll
experiment with a small Linux box.

I wist they would use a smarter SPAM filter that wouldn't flag
perfectly legit-looking outgoing e-mails.
-- 
http://mail.python.org/mailman/listinfo/python-list


Source code to identify user through browser?

2013-06-05 Thread Gilles
Hello

I was wondering if some Python module were available to identify a
user through their browser, like it's done on the Panopticlick site:

http://panopticlick.eff.org/

I'd like to ban abusive users, and it seems like a good solution,
since few users will think of installing a different browser, and
there are few mainstream browsers anyway.

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


Re: Cross-compiling Python for ARM?

2013-04-20 Thread Gilles
On Tue, 16 Apr 2013 17:22:55 +0300, Anssi Saari a...@sci.fi wrote:
In any case, cross compiling Python shouldn't be that hard. I
just recently built 2.7.3 for my OpenWRT router since the packaged
Python didn't have readline support (some long standing linking issue
with readline and ncurses and uClibc).

Thanks guys. Turns out the error was not due to Python, so the ARM
version available in the Debian depot is fine.
-- 
http://mail.python.org/mailman/listinfo/python-list


Cross-compiling Python for ARM?

2013-04-15 Thread Gilles
Hello

I tried running uWSGI on an ARM-based appliance, but it fails. 

Apparently, it could be due to the official Python 2.6.6 interpreter
in the depot not being compiled the way uWSGI expects it to be:

./configure --enable-shared; make; make install;
www.raspberrypi.org/phpBB3/viewtopic.php?f=32t=15370

I see Python mentioned in /usr/lib and /usr/share, and was wondering
if all it'd take to solve this issue, is just to cross-compile the
interpreter and the rest is just CPU-agnostic Python scripts.

Just in case, here's the output:
www.pastebin.com/wJHjBrfn

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


What web server for WSGI? Recommended book?

2013-03-27 Thread Gilles
Hello

After going through multiple articles about the advantage of using
WSGI instead of FastCGI + Flup to run Python web apps, I have a couple
of questions:

1. Which server + WSGI module would you recommend? I know about Apache
and Graham Dumpleton's mod_wsgi, but what about Lighttpd and Nginx? I
read that Nginx's mod_wsgi written by Manlio Perillo is not
recommended.

2. At this point, is there a recommended book to learn how to write
web applications in Python, preferably one that would first show the
underlying mechanics before showing the main frameworks (web.py,
Pylons, TurboGears, Django, etc.) so that I understand what's going on
under the hood.

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


[WSGI] Tell Python to listen to LAN interface?

2013-03-26 Thread Gilles
Hello

I'm following this tutorial to learn about writing Python apps in
WSGI:

http://webpython.codepoint.net/wsgi_tutorial

On a Linux host with Python 2.6.6 installed, I launched the
Environment dictionary sample, but can't connect to it from my
remote Windows host since the application only accepts local queries:

# netstat -tunlp
...
tcp0  0 127.0.0.1:8051  0.0.0.0:* LISTEN
13110/python

How can I tell the Python interpreter to listen on 0.0.0.0 or at least
192.168.0.0/24?

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


Re: [WSGI] Tell Python to listen to LAN interface?

2013-03-26 Thread Gilles
On Tue, 26 Mar 2013 23:50:36 +1100, Chris Angelico ros...@gmail.com
wrote:
According to the docstring, the first argument to make_server() is the
host name to bind to. Using localhost means you're bound to
127.0.0.1, as you see. Use your LAN IP address there, or  to bind to
all local addresses - or possibly :: to bind to all IPv6 addresses
(try it and see - some systems work with one or the other, others work
happily with both together).

Thanks Chris. I was thinking it was due to how Python was configured,
and didn't first check that it could be some instruction in the script
itself. It works fine now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Daemonizing an application.

2013-02-27 Thread Gilles Lenfant
Hello,

Sorry for the obscure title, but I can't make short to explain what I'm 
searching for. :)

I made an app (kind of proxy) that works without UI within it's process. So 
far, so good.

Now I need to change live some controls of this application, without stopping 
it.

So my app will be split in two :

* A control app (say appctl) for a console UI
* A daemon (or agent ?) that runs the core of the app (say appd), processing 
inputs and outputs

What are the best practices to do this ? Examples in a well known Pyhon app I 
could hack ? Is it possible with standard packages only ?

Thanks in advance fo any pointer.

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


Re: Daemonizing an application.

2013-02-27 Thread Gilles Lenfant
Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
 Hello,
 
Hello again,

And thanks to all for your pointers and ideas.

As the app is already tied to an Unix like OS, I'll go with signal handling 
first since I can do all I need through reconfiguration (SIGHUP).

If I need other controls, I shall use an XML-RPC, since it's an OTB feature.

Thanks again
-- 
Gilles Lenfant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Daemonizing an application.

2013-02-27 Thread Gilles Lenfant
Le mercredi 27 février 2013 14:55:42 UTC+1, Tarek Ziadé a écrit :
 On 2/27/13 11:52 AM, Gilles Lenfant wrote:
 
  Hello,

[...]

 
  Thanks in advance fo any pointer.
 
 
 
 You can have a look at Circus - https://circus.readthedocs.org which is 
 
 a process manager.
 
 
 
 circusctl is used to control circusd using ZeroMQ
 
 
 
 The nice thing about zmq as opposed to signals is that you can code your 
 
 thing independantly from the transport
 
 then choose which transport fits a situation: TPC (then the ctl can be 
 
 on another box), IPC or even ITC
 
 
 
 That also means your ctl part can be portable to any platform

Hi Tarek,

Great stuff. Exactly what I was looking for. The various processes of my app 
already chat with each other using the great ZeroMQ power sockets. And can 
potentially be powered in as many physical servers since the shared persistent 
data are provided through SQLAlchemy + eXist-db.

I can read that Circus can monitor sockets too. Should I understand that I can 
monitor the state of ZMQ listening sockets with Circus too ?

Cheers
-- 
Gilles

 
 
 
 Cheers
 
 Tarek
 
 
 
 -- 
 
 Tarek Ziadé · http://ziade.org · @tarek_ziade

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


Installing Apache 2 and mod_wsgi on CentOS?

2013-02-12 Thread Gilles
Hello

Before I go ahead, I'd like to make sure I'm doing it the right away:

1. yum install httpd mod_wsgi

2. Edit /etc/sysconfig/httpd to uncomment this line to get Apache to
run as worker MPM:
#HTTPD=/usr/sbin/httpd.worker

3. Edit mod_wsgi

4. Build a test WSGI Python script

5. Start Apache, and launch a browser

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


[2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
Hello

I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

1. The following script runs fine...
=
#!/usr/bin/env python2.6

def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Done!\n']

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
=

... while this triggers an error:
=
#!/usr/bin/env python2.6
# -*- coding: UTF-8 -*-

from cgi import escape
import sys, os

def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])

yield 'h1FastCGI Environment/h1'
yield 'table'
for k, v in sorted(environ.items()):
 yield 'trth%s/thtd%s/td/tr' % (escape(k),
escape(v))
yield '/table'

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(app).run()
=

Internal Server Error: The server encountered an internal error or
misconfiguration and was unable to complete your request. [...]
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.

2. Generally speaking, what is the right way to investigate an error
in a Python web script? FWIW I have access to the shared server
through SSH.

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


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 10:30:01 +0100, Gilles nos...@nospam.com wrote:
   I have a couple of newbie questions about using Python in a FastCGI
+ Flup context on a shared CentOS server:

Please ignore the thread. I found the error, and a way to catch
compile-time errors (log on through SSH, and run python
./myscript.py).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 21:30:12 +1100, Chris Angelico ros...@gmail.com
wrote:
That'll catch some forms of error, but not everything. You may also
want to consider looking for your server's error log - that may be
getting the actual traceback. I don't know what your server setup is,
but there's likely to be one somewhere.

Good to know.

A question though. You say 2.4.3 in your subject line, but your
shebang says python2.6 - which version are you actually running?

I didn't pay attention to this. Support says that I should use 2.6,
but running python -V through SSH says 2.4.3. I'll ask support which
to use.

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


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 22:30:45 +1100, Chris Angelico ros...@gmail.com
wrote:
Try running python2.6 -V

Your shebang line says that it's looking for a program named
python2.6, which is quite probably not the same as the one named
just python.

Indeed, they have two versions of Python installed:

# python2.6 -V
Python 2.6.4

# python -V
Python 2.4.3

I'll make sure to use 2.6.

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


Re: [2.4.3/Newbie] Web script doesn't run

2013-02-11 Thread Gilles
On Mon, 11 Feb 2013 22:42:50 +1100, Chris Angelico ros...@gmail.com
wrote:
It's entirely possible you have a third Python, a 3.x, as well.
Different Pythons coexist quite happily on a system.

Thank for the help. I'm on my way to figure out how mod_fcgid, Flup,
and Python scripts work together.
-- 
http://mail.python.org/mailman/listinfo/python-list


Iterating over files of a huge directory

2012-12-17 Thread Gilles Lenfant
Hi,

I have googled but did not find an efficient solution to my problem. My 
customer provides a directory with a hge list of files (flat, potentially 
10+) and I cannot reasonably use os.listdir(this_path) unless creating a 
big memory footprint.

So I'm looking for an iterator that yields the file names of a directory and 
does not make a giant list of what's in.

i.e :

for filename in enumerate_files(some_directory):
# My cooking...

Many thanks by advance.
-- 
Gilles Lenfant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iterating over files of a huge directory

2012-12-17 Thread Gilles Lenfant
Le lundi 17 décembre 2012 16:52:19 UTC+1, Oscar Benjamin a écrit :
 On 17 December 2012 15:28, Gilles Lenfant ... wrote:
 
 
 In the last couple of months there has been a lot of discussion (on
 
 python-list or python-dev - not sure) about creating a library to more
 
 efficiently iterate over the files in a directory. The result so far
 
 is this library on github:
 
 https://github.com/benhoyt/betterwalk
 
 
 
 It says there that
 
 
 
 Somewhat relatedly, many people have also asked for a version of
 
 os.listdir() that yields filenames as it iterates instead of returning
 
 them as one big list.
 
 
 
 So as well as a faster walk(), BetterWalk adds iterdir_stat() and
 
 iterdir(). They're pretty easy to use, but see below for the full API
 
 docs.
 
 
 
 
 
 Does that code work for you? If so, I imagine the author would be
 
 interested to get some feedback on how well it works.
 
 
 
 Alternatively, perhaps consider calling an external utility.
 

Many thanks for this pointer Oscar.

betterwalk is exactly what I was looking for. More particularly iterdir(...) 
and iterdir_stat(...)
I'll get a deeper look at betterwalk and provide (hopefully successful) 
feedback.

Cheers
-- 
Gilles Lenfant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about long-running web scripts

2012-10-26 Thread Gilles
On Thu, 25 Oct 2012 08:53:11 -0400, David Hutto
dwightdhu...@gmail.com wrote:
 OTOH, Python web scripts can be written as long-running scripts: In
 this case, what is the added-value of using FastCGI? Why can't the
 web server simply call the Python script directly, just like CGI?

The server should call a the script, or script.sleep()

There are also server options to setup when a script is run, other
than a cron jo for php.

Thanks. Does it mean that Python scripts that rely on either fcgi.py
or WSGI really have some endless loop somewhere and will keep running
once they're launched by FastCGI?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about long-running web scripts

2012-10-26 Thread Gilles
On Thu, 25 Oct 2012 14:24:16 +0100, Tim Golden m...@timgolden.me.uk
wrote:
 But actually, I didn't mean one-shot scripts, where the Python
 interpreter + script must be loaded each time, but rather: If I leave
 a Python running in an endless loop, why not just use either CGI or
 some other basic way to call the script instead of FastCGI?

In essence, you're describing FastCGI. A Python program (or, indeed, any
program) which uses FastCGI runs continuously and waits for the incoming
request on a TCP socket (instead of as a sys.stdin stream + env vars
immediately after process startup).

Thanks for the clarification.

Since, unlike PHP, the Python interpreter is not available in a
FastCGI-capable version, this explains why the www server must be told
which specific Python script to run through FastCGI.

The reason I ask for all this, is that I want to understand how things
work under the hood before relying on a Python framework to handle the
nitty-gritty.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about long-running web scripts

2012-10-26 Thread Gilles
On Fri, 26 Oct 2012 12:00:17 +0100, Tim Golden m...@timgolden.me.uk
wrote:
Certainly there are Python equivalents (mod_python, mod_wsgi, etc.)
which can run in effectively the same way as mod_php, and they could be
configured to run an fcgi frontend script, I presume. There's always a
certain confusion here because you can often one mechanisms (say,
mod_wsgi) to act as another (say legacy one-shot CGI) and because some
things are both mechanism and protocol and it's not always easy to tease
the two apart.

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


Question about long-running web scripts

2012-10-25 Thread Gilles
Hello

I'd like to check something about running Python web applications.

Generally speaking, the reason scripts run faster when called through
FastCGI or the mod_* modules, is because the interpreter is already up
and running.
But when running PHP scripts, this does nothing about fetching the
file from disk, recompiling, rerunning it, and usually reconnecting to
the database.

OTOH, Python web scripts can be written as long-running scripts: In
this case, what is the added-value of using FastCGI? Why can't the web
server simply call the Python script directly, just like CGI?

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


Re: Question about long-running web scripts

2012-10-25 Thread Gilles
On Thu, 25 Oct 2012 13:03:14 +0100, Tim Golden m...@timgolden.me.uk
wrote:
(Your question is a little confused at the end. I'm choosing to
understand: why can't we just run Python one-shot, like CGI? The likely
alternative meaning is: why can't the incoming request be routed to an
already-running Python program -- which is not, of course, what CGI
generally does. Hence my confusion).

Yes indeed. Sorry about the confusion.

But actually, I didn't mean one-shot scripts, where the Python
interpreter + script must be loaded each time, but rather: If I leave
a Python running in an endless loop, why not just use either CGI or
some other basic way to call the script instead of FastCGI?

In the case of PHP, FastCGI makes sense, but I don't see the benefit
for long-running Python scripts.
-- 
http://mail.python.org/mailman/listinfo/python-list


[2.5.1 + CGI] Which interpreter and files?

2012-10-19 Thread Gilles
Hello

I'd like to use the Mongoose basic web server with Python which can
call scripts through CGI.

I have a coupole of questions:

1. Mongoose must be told in the shebang file where to locate the
interpreter, but ActivePython 2.5.1 comes with fours files that look
like the interpreter (actually, two files, since the other two have
the same size so they are probably left overs):

01/05/2007  18:0124.064 python.exe
01/05/2007  18:0124.064 python25.exe
01/05/2007  18:0124.576 pythonw.exe
01/05/2007  18:0124.576 pythonw25.exe


2. Which files and directories do I really need and must provide, and
which can I do without?

Directory of C:\Python25

20/07/2007  02:38DIR  DLLs
20/07/2007  02:38DIR  include
02/09/2012  11:47DIR  Lib
20/07/2007  02:38DIR  libs
18/07/2007  15:33   348.160 msvcr71.dll
28/10/2009  12:31 2.017 psyco-wininst.log
05/04/2008  03:17 9.226 py2exe-wininst.log
20/11/2008  15:13 4.218 pysqlite-wininst.log
01/05/2007  18:0124.064 python.exe
01/05/2007  18:0124.064 python25.exe
01/05/2007  18:0124.576 pythonw.exe
01/05/2007  18:0124.576 pythonw25.exe
03/05/2010  12:0161.440 Removeapsw.exe
28/10/2009  12:3161.440 Removepsyco.exe
05/04/2008  03:1761.440 Removepy2exe.exe
20/11/2008  15:1361.440 Removepysqlite.exe
14/11/2008  18:2261.440 Removesetuptools.exe
07/07/2010  14:43DIR  Scripts
14/11/2008  18:24 9.859 setuptools-wininst.log
20/07/2007  02:39DIR  tcl
20/07/2007  02:39DIR  Tools
01/05/2007  18:01 4.608 w9xpopen.exe


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


Re: [2.5.1 + CGI] Which interpreter and files?

2012-10-19 Thread Gilles
On Fri, 19 Oct 2012 21:09:55 +1100, Chris Angelico ros...@gmail.com
wrote:
The ones with the -w tag are designed for Windows apps that are going
to bring up a GUI and don't want a console. The python[w]25.exe ones
will be in case you have multiple Pythons installed and want to
explicitly call for version 2.5. You probably want python.exe, but
python25.exe will work too.

Thanks for the info.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python scripts for web

2012-10-19 Thread Gilles
On Thu, 18 Oct 2012 23:05:48 -0700 (PDT), chip9m...@gmail.com wrote:
these scripts will do a lot of calculation on a big dataset, and it is 
possible that there will be many requests in a short period of time.

In that case, are you sure a web script is a good idea? If you're
thinking web to make it easy for people to upload data, click on a
button, and get the results back, you might want to write the UI in
Python but write the number crunching part in a compiled language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to investigate web script not running?

2012-09-30 Thread Gilles
On Sat, 29 Sep 2012 10:05:25 -0700 (PDT), Ramchandra Apte
maniandra...@gmail.com wrote:
 Definitely not plug 'n play :-/

Well the plug and play standard is superseded by USB practically.

Indeed ;-)

Anyway, Support finally got back to me, and it turns out that they
have Flup alreay installed on shared hosts, so I just have to provide
a WSGI script. OTOH, mod_fcgid is confured to wait 5mn or so before
checking if the script was edited, so I'll have to use a test host for
development and only use the shared host for deployment.

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


#!/usr/bin/env python vs. #!/usr/bin/python?

2012-09-28 Thread Gilles
Hello

I've seen both shebang lines to run a Python script on a *nix host:

#!/usr/bin/env python
#!/usr/bin/python

What's the difference?

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


Re: #!/usr/bin/env python vs. #!/usr/bin/python?

2012-09-28 Thread Gilles
On Fri, 28 Sep 2012 06:57:28 -0400, Roy Smith r...@panix.com wrote:
The first one looks through your PATH to find the right python 
interpreter to run.  The second one is hard-wired to run /usr/bin/python.

If you only have a single copy of python installed, it doesn't really 
matter which you use.  But, you might as well get into the habit of 
using the /usr/bin/env flavor because it's more flexible.

Thanks guys. I suspected that's what the difference was.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to investigate web script not running?

2012-09-28 Thread Gilles
Hello

I'm trying to run my very first FastCGI script on an Apache shared
host that relies on mod_fcgid:
==
#!/usr/bin/python
from fcgi import WSGIServer
import cgitb

# enable debugging
cgitb.enable()

def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']

WSGIServer(myapp).run()
==

After following a tutorial, Apache complains with the following when I
call my script:
==
Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.
==

Generally speaking, what tools are available to investigate issues
when running a Python web app?

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


Re: How to investigate web script not running?

2012-09-28 Thread Gilles
On Fri, 28 Sep 2012 13:37:36 +0200, Gilles nos...@nospam.com wrote:

==
Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.
==

Looks like fcgi.py doesn't support WSGI:

Traceback (most recent call last):
File hello.fcgi, line 2, in ?
from fcgi import WSGIServer
ImportError: cannot import name WSGIServer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to investigate web script not running?

2012-09-28 Thread Gilles
On Fri, 28 Sep 2012 14:16:22 +0200, Michael Ross g...@ross.cx
wrote:
Do it the other way around:

# cgitb before anything else
import cgitb
cgitb.enable()

# so this error will be caught
 from fcgi import WSGIServer

Thanks much for the tip. The error isn't displayed when calling the
script from a web browser but it is when running the script on a shell
account.

It looks like that newer version of fcgi.py doesn't include support
for WSGI, and I need some extra (Flup?) software to sit between
mod_fcgid and a WSGI Python application.

Definitely not plug 'n play :-/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: #!/usr/bin/env python vs. #!/usr/bin/python?

2012-09-28 Thread Gilles
On Fri, 28 Sep 2012 09:19:54 -0400, D'Arcy Cain da...@druid.net
wrote:
Not just flexible but portable.  On various systems I have Python
in /usr/bin, /usr/local/bin and /usr/pkg/bin.  #!/usr/bin/env python
finds it in each case so I only need one version of the script.

Good to know.
-- 
http://mail.python.org/mailman/listinfo/python-list


[fcgi.py] Force cache upgrade?

2012-09-28 Thread Gilles
Hello

Does someone know if something must be done after editing a FastCGI +
WSGI script so that the changes will show in the browser immediately
instead of having to wait X minutes?

===
#!/usr/bin/env python2.6

def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['I CHANGED THIS\n']

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
===

I guess the FastCGI server (Flup) only updates its cache every so
often. Do I need to type a command to force Flup to recompile the
Python script?

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


Re: [fcgi.py] Force cache upgrade?

2012-09-28 Thread Gilles
On Fri, 28 Sep 2012 23:57:14 +0200, Gilles nos...@nospam.com wrote:
I guess the FastCGI server (Flup) only updates its cache every so
often. Do I need to type a command to force Flup to recompile the
Python script?

Turns out that, yes, mod_fcgid is configured to reload a script only
after some time or some number of hits, and yes, mod_fcgid settings
are off-limit on a shared host.
-- 
http://mail.python.org/mailman/listinfo/python-list


[WSGI] FCGID + Flup vs. mod_wsgi?

2012-09-21 Thread Gilles
Hello

The shared host I intend to use to run a small Python web app only
supports mod_fcgid on its Apache server.

If I understood what I read on the Net, the ideal solution would be to
have mod_wsgi installed and have it run either as a module within
Apache or a stand-alone process to talk to the Python app, but it's
N.A. so that's out.

As for FCGID, am I correct in understanding that this is the way
things work:

Apache - mod_fcgid - Flup (or some other wrapper) - WSGI
application?

www.stackoverflow.com/questions/1747266/is-there-a-speed-difference-between-wsgi-and-fcgi

Would I miss a lot by using the mod_fcgid+Flup solution instead of
mod_wsgi?

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


[issue7358] cStringIO not 64-bit safe

2012-09-10 Thread Gilles Louppe

Gilles Louppe added the comment:

Hi,

Any solution regarding that issue? We are currently encountering the exact same 
bug when pickling too large objects. 

Best,

Gilles

--
nosy: +Gilles.Louppe

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7358
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[web] Long-running process: FCGI? SCGI? WSGI?

2012-09-05 Thread Gilles
Hello

To write a long-running web application, I'd like to some feedback
about which option to choose.

Apparently, the choice boilds down to this:
- FastCGI
- SCGI
- WSGI

It seems like FCGI and SCGI are language-neutral, while WSGI is
Python-specific.

Besides that, how to make an informed choice about which option to
choose?

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


Re: [2.5.1] Read each line from txt file, replace, and save?

2012-09-05 Thread Gilles
On Sun, 02 Sep 2012 14:04:29 -0400, Terry Reedy tjre...@udel.edu
wrote:
If you process each line separately, there is no reason to read them all 
at once. Use the file as an iterator directly. Since line is already a 
string, there is no reason to copy it into a new string. Combining these 
two changes with Mark's suggestion to use with and we have the following 
simple code:

Thanks guys for the suggestion.
-- 
http://mail.python.org/mailman/listinfo/python-list


[2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Gilles
Hello

This is a newbie question.

I need to read a text file into a variable, loop through each line and
use a regex to substitute some items within the line, and save the
whole variable into a new text file.

This triggers an error when I save the modified variable that contains
all the lines:
==
import re,sys

f = open(C:\\input.txt, r)
textlines = f.readlines()
f.close()

for line in textlines:
#edit each line
line = just a test

#rewrite data to new file
log = open('output.sub','w')
#ERROR: argument 1 must be string or read-only character buffer, not
list
log.write(textlines)
log.close()
==

Should I use another way to read the file, edit each line, and save
the data into a new file?

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


Re: [2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Gilles
On Sun, 02 Sep 2012 12:19:02 +0200, Gilles nos...@nospam.com wrote:
(snip)

Found it:

#rewrite lines to new file
output = open('output.txt','w')

for line in textlines:
#edit each line
line = just a test
output.write(%s % line)

output.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


[CGI] Basic newbie error or server configuration error?

2012-08-20 Thread Gilles
Hello

Apache fails running this basic CGI script that I found on the Net:

www.acme.com/cgi-bin/test.py?name=myname
===
#!/usr/bin/env python

# Import modules for CGI handling
import cgi, cgitb

cgitb.enable()

# Create instance of FieldStorage
form = cgi.FieldStorage()

# Get data from field 'name'
#name = form['name'].value
name = form.getvalue('name')
===

This is what I get:
===
Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
===

FWIW, the script lives in www/cgi-bin/ where it should, was chmoded to
755, and I put the following .htaccess file:
===
Options +ExecCGI
AddHandler cgi-script .py
===

I'm not sure where to look for an error. Could it be some non-printed,
bad characters that prevent Python from compiling the source code?

Thanks for any help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Basic newbie error or server configuration error?

2012-08-20 Thread Gilles
Found it: The script MUST return something to the browser. I was
missing this:


print Content-Type: text/html;charset=utf-8
print

# print a document
print Name is %s % ( cgi.escape(name), )


Sorry about that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Basic newbie error or server configuration error?

2012-08-20 Thread Gilles
On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
rodper...@rodperson.com wrote:
Check the Apache error log, there should be more information there.

It's a shared account, so I only have access to what's in cPanel,
which didn't display anything. Problem solved.

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


Re: [CGI] Basic newbie error or server configuration error?

2012-08-20 Thread Gilles
On Mon, 20 Aug 2012 16:56:14 +0200, Hans Mulder han...@xs4all.nl
wrote:
Most such panels have a button to show the error log for your own site.

If you can't find it, ask the help desk of the web hosting company.

If there really is no way for you to see the error log, ask the help
desk to mail you the error message.

Thanks. the cPanel at my provider only has a Logs  Error Log icon,
but the error I was having didn't result in anything in the log file.

I'll set up a Linux host at home and test Python scripts before
uploading them to my ISP.

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


[CGI] Why is HTML not rendered?

2012-08-17 Thread Gilles
Hello

I'm learning how to call Python scripts through the different
solutions available.

For some reason, this CGI script that I found on Google displays the
contents of the variable but the HTML surrounding it is displayed
as-is by the browser instead of being rendered:

--
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

import cgi
form = cgi.FieldStorage()

# get a value from the form
value = form.getvalue(dummy)

print Content-Type: text/plain;charset=utf-8
print

# print a document
print PYou typed: TT%s/TT/P % (
cgi.escape(value),
)
--

Here's the output:
--
PYou typed: TTtest/TT/P
--

Could this be due to the script itself, or some server configuration?

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


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Gilles
On Fri, 17 Aug 2012 14:44:37 +0100, Robert Kern
robert.k...@gmail.com wrote:
 For some reason, this CGI script that I found on Google displays the
 contents of the variable but the HTML surrounding it is displayed
 as-is by the browser instead of being rendered

Thanks all. I (obviously) combined two scripts but didn't notice that
I had to change the Content-Type line to output HTML.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running Python web apps on shared ASO servers?

2012-08-16 Thread Gilles
On Sun, 12 Aug 2012 02:03:33 +0200, Gilles nos...@nospam.com wrote:
Does it mean that ASO only supports writing Python web apps as
long-running processes (CGI, FCGI, WSGI, SCGI) instead of embedded
Python à la PHP?

I need to get the big picture about the different solutions to run a
Python web application.

From what I read, it seems like this is the way things involved over
the years:

CGI : original method. Slow because the server has to spawn a new
process to run the interpreter + script every time a script is run.

mod_python : Apache module alternative to CGI. The interpreter is
loaded once, and running a script means just handling the script

mod_wsgi : mod_python is no longer developped, and mod_wsgi is its new
reincarnation

FastCGI and SCGI: Faster alternativees to CGI; Run as independent
programs, and communicate with the web server through either a Unix
socket (located on the same host) or a TCP socket (remote  host)

Is this correct?

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


Re: Running Python web apps on shared ASO servers?

2012-08-13 Thread Gilles
On Sun, 12 Aug 2012 22:26:19 +0100, Tim Golden m...@timgolden.me.uk
wrote:
Just to make a point: one person's isn't a good solution is another 
person's works perfectly well for me. Modern servers are really quite 
quick: the cost of starting up a Python process and generating an HTML 
page can be really quite low. I've certainly had low-traffic production 
websites running for years on CGI without anyone complaining.

Thanks Tim for the input. I'll try the different solutions available
and see if CGI is good enough for my needs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running Python web apps on shared ASO servers?

2012-08-12 Thread Gilles
On Sun, 12 Aug 2012 07:56:26 +0200, Dieter Maurer
die...@handshake.de wrote:
You should probably read the mentioned forum resources to learn
details about the Python support provided by your web site hoster.

Yup, but so far, no answer, so I figured someone here might now.

Those articles seem to indicate that CGI isn't a good solution when
mod_python isn't available, so it looks like I'll have to investigate
FastCGI, WSGI, etc.

http://docs.python.org/howto/webservers.html
http://stackoverflow.com/questions/219110/how-python-web-frameworks-wsgi-and-cgi-fit-together

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


Running Python web apps on shared ASO servers?

2012-08-11 Thread Gilles
Hello

I use A Small Orange (ASO) as my web provider. Asking the question in
their forum so far didn't work, so I figured I might have a faster
answer by asking here.

Support replied this in an old thread: Just a CGI option. We don't
have enough users to justify adding mod_python support.
http://forums.asmallorange.com/topic/4672-python-support/page__hl__python
http://forums.asmallorange.com/topic/4918-python-fcgi-verses-mod-python/

Does it mean that ASO only supports writing Python web apps as
long-running processes (CGI, FCGI, WSGI, SCGI) instead of embedded
Python à la PHP?

If that's the case, which smallest tool would you recomment to write
basic apps, eg. handling forms, etc.?

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


Re: Using a CMS for small site?

2012-07-05 Thread Gilles
On Wed, 4 Jul 2012 17:09:40 -0700 (PDT), alex23 wuwe...@gmail.com
wrote:
Not necessarily! There are several static site generators written in
Python :)

One that I see being updating a lot is Nikola: http://nikola.ralsina.com.ar/

I'll check it out, thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using a CMS for small site?

2012-07-05 Thread Gilles
On Thu, 05 Jul 2012 10:27:40 +0200, Dieter Maurer
die...@handshake.de wrote:
There is also Plone (http://plone.org;) -- easy to set up.

You likely need third party extensions for the anti-SPAM support
and the onlie payment.

I'll see what extensions it offers. Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Using a CMS for small site?

2012-07-04 Thread Gilles
Hello

Someone I know with no computer knowledge has a studio appartment to
rent in Paris and spent four months building a small site in Joomla to
find short-time renters.

The site is just...
- a few web pages that include text (in four languages) and pictures
displayed in a Flash slide show
- a calendar to show availability
- a form to send e-mail with anti-SPAM support
- (ASAP) online payment

Out of curiosity, are there CMS/frameworks in Python that can do this?
Django? Other?

Is a full-fledged CMS even needed for something like that?

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


Re: Using a CMS for small site?

2012-07-04 Thread Gilles
On Wed, 04 Jul 2012 06:28:09 -0400, Roy Smith r...@panix.com wrote:
You probably want to look at https://www.django-cms.org/.  It's not 
something that a person with no computer knowledge could set up, but 
once it's set up, that person could use it to build pages.

But, to be honest, for somebody who really doesn't know anything, some 
much more pre-canned solution like WordPress might be what they're 
looking for.

Thanks for the input. Considering that contents won't change, I was
wondering if a full-fledged CMS was even necessary.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using a CMS for small site?

2012-07-04 Thread Gilles
On Wed, 04 Jul 2012 11:21:42 -0400, Roy Smith r...@panix.com wrote:
This is really getting quite far afield for a Python group.  There are 
better forums for these kinds of questions.

Probably. I'll keep that in mind while checking Python web frameworks.
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Gilles
On Tue, 12 Jun 2012 11:39:50 +0200, Gilles nos...@nospam.com wrote:
I'm an amateur programmer, and would like to know what the main
options are to build web applications in Python instead of PHP.

When I need to host my Python application (preferably in Europe since
my users will be located there), what are the options?

Do Python hosters provide a VM so that it's just like a remote Linux
server where I'm free to install whatever I want, or do they force
users to use specific versions of Python and specific frameworks eg.
Django?

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


Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Gilles
On Thu, 21 Jun 2012 10:44:08 -0700, Paul Rubin
no.email@nospam.invalid wrote:
There are both kinds.  The first kind is called a Virtual Private Server
(VPS).  The second kind is called shared hosting.

Thanks much for the infos.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-14 Thread Gilles
On Wed, 13 Jun 2012 19:03:29 -0500, Tim Chase
python.l...@tim.thechases.com wrote:
That's just my off-the-top-of-my-head list of things that you'd have
to come up with that Django happens to give you out-of-the-box.

Thanks much. So the next step will have to find a framework that's
right for a given application.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 10:19:29 +1000, Chris Angelico ros...@gmail.com
wrote:
It's far simpler to manage, it retains running state, and is easily
enough encapsulated. It's the non-magic way of doing things. Also, it
plays very nicely with the MUD style of process, which is something I
do a lot with Pike. Plus, if you manage it right, you have a guarantee
that you can never be in a half-updated state - that's somewhat tricky
when you have inter-dependencies in PHP code and the file system
itself manages things. What happens if a request comes in while you're
half-way through uploading new code to the server? By default, you
could use half old code and half new code. Keeping everything in
memory makes it easier to prevent that.

Thanks for the input.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On 13 Jun 2012 08:29:05 GMT, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

and especially lack PHP's security vulnerabilities.

Thanks for the link.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Tue, 12 Jun 2012 16:48:27 +0200, Matej Cepl mc...@redhat.com
wrote:
I don't think it is a proper description of the situation (please, 
somebody correct my mistakes, I am not 100% sure about it myself). WSGI 
applications (which is basically all web applications in Python) could 
run in the hosted servers (using for example mod_wsgi for Apache), and I 
would expect that it is the situation with most production uses.

I have a couple more questions:

1. Today what is the recommended way to connect a long-running Python
web application with a web server running in the front? FastCGI? WSGI?
Other?

2. Which solid web server is recommended to connect to Python web
applications in the back?

3. What Python web framework would you recommend to get started, and
possibly more heavy duty framework in case I need something bigger
later?

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


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 19:41:41 +1000, Chris Angelico ros...@gmail.com
wrote:
For high-availability servers, I can't speak for Python, as I've never
done that there; but it seems likely that there's good facilities. My
personal preference is Pike, but that's off-topic for this list. :)
But the simple answer for simple tasks is: Don't bother with
frameworks, run an HTTP server.

Thanks. What do you mean with Don't bother with frameworks, run an
HTTP server? Subclassing BaseHTTPServer?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 20:00:59 +1000, Chris Angelico ros...@gmail.com
wrote:
Most high level languages probably have some sort of HTTP server
available. Some make it trivially easy to plug some code in and start
serving. Python is advertised as batteries included, and one of its
packets of batteries is a fairly full-featured set of internet
protocol handlers.

Thanks for the longer explanation. With so many frameworks, I'd like
to know what benefits they offer as compared to writing an application
from scratch, and if they do offer obvious benefits, which one to pick
:-/

http://wiki.python.org/moin/WebFrameworks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 18:01:23 +, Prasad, Ramit
ramit.pra...@jpmorgan.com wrote:
Maybe this article will help you 
http://www.infoworld.com/d/application-development/pillars-python-six-python-web-frameworks-compared-169442
The comments on /. should round out anything missing from the article (I hope)
http://developers.slashdot.org/story/11/08/10/2111203/six-python-web-frameworks-compared

Thanks for the links.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 17:27:21 +0200, Christian Heimes
li...@cheimes.de wrote:
A long running process has lots of benefits that makes design and
development easier and makes your app faster.

Thanks much for the infos. Makes you wonder why commercial companies
still choose PHP to write their web site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On 13 Jun 2012 22:16:51 GMT, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Surely the obvious answer is that a framework offers the benefit that you 
don't have to write the application from scratch.

Yes, but between receiving the query and sending the response, what
features do frameworks offer that I'd have to write myself otherwise?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Gilles
On Wed, 13 Jun 2012 23:16:31 +0200, Christian Heimes
li...@cheimes.de wrote:
PHP was developed for non-developers. (see
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ ).
It's much easier and also cheaper to find bad coders and non-developers
than code people. The outcome is bad performance and lots of security
issues.

And as to why Facebook chose PHP...
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >