Re: SMTPHandler and Unicode
> Well, you could use an approach like the one suggested here: > > http://plumberjack.blogspot.com/2010/07/using-custom-formatter-to-dea... That's nice, thanks. I'll use something like this. Just a thought : I will use "errors=replace" in the call to the encode method to be sure that the logger does not raise any exception. -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTPHandler and Unicode
> > Ouch. Implicit encoding sounds like a bad behaviour. Looking at the FileHandler source ( http://svn.python.org/view/python/trunk/Lib/logging/__init__.py?view=markup ) : the utf-8 encoding is a fallback. But *FileHandler family let you specify the encoding you want, so that's OK I think. But SMTPHandler does not have such a thing it sends its email with : msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % ( self.fromaddr, ",".join(self.toaddrs), self.getSubject(record), formatdate(), msg) ... smtp.sendmail(from,to,msg) And there is no encoding in all this. It seems pretty dangerous to me (so my first post) because your application will work without any problem with a FileHandler and the day you'll decide to send email in case of serious problem, it will crash with a UnicodeError. I can't see any workaround, except by subclassing SMTPHandler's emit method to be unicode-aware or at least URF-8 aware. -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTPHandler and Unicode
On 5 juil, 14:32, Chris Withers wrote: > norbert wrote: > > Your package has the same unicode problem : > > import logging,logging.handlers > > from mailinglogger.MailingLogger import MailingLogger > > mailingLogger = MailingLogger(mailhost=('smtp.example.com', > > 25),fromaddr='t...@example.com',toaddrs=('t...@example.com',)) > > LOG = logging.getLogger() > > LOG.addHandler(mailingLogger) > > LOG.error(u"sans accent") > > LOG.error(u"accentu\u00E9") > > > --> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' > > in position 7: ordinal not in range(128) > > Interesting, I don't know what the logging framework's position is on > unicode... > > What happens when you try the same logging with just a FileHandler > registered? What encoding does the log file use? > a FileHandler works as expected, the log file being UTF-8 encoded. The SMTPHandler is the only logger I know with this problem, maybe connected to SMTPLib implementation ? -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTPHandler and Unicode
On 5 juil, 13:17, Chris Withers wrote: > try MailingLogger: > > If you have unicode problems with that, I'd be interested in fixing them! Your package has the same unicode problem : import logging,logging.handlers from mailinglogger.MailingLogger import MailingLogger mailingLogger = MailingLogger(mailhost=('smtp.example.com', 25),fromaddr='t...@example.com',toaddrs=('t...@example.com',)) LOG = logging.getLogger() LOG.addHandler(mailingLogger) LOG.error(u"sans accent") LOG.error(u"accentu\u00E9") --> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 7: ordinal not in range(128) -- http://mail.python.org/mailman/listinfo/python-list
SMTPHandler and Unicode
Hello, I want to send error messages with SMTPHandler logging. But SMTPHandler does not seem to be unicode aware. Is there something doable without playing with sys.setdefaultencoding ? import logging,logging.handlers smtpHandler = logging.handlers.SMTPHandler(mailhost=("smtp.example.com",25), fromaddr="t...@example.com", toaddrs="t...@example.com", subject=u"error message") LOG = logging.getLogger() LOG.addHandler(smtpHandler) LOG.error(u"sans accent") LOG.error(u"accentu\u00E9") gives : UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 117: ordinal not in range(128) Thank you ! -- http://mail.python.org/mailman/listinfo/python-list
Hint :Easy_Install Documentation
Hello list, just in the moment I wanted to write about then lacking documentation about Easy_Install, but then I found this one : http://www-128.ibm.com/developerworks/library/l-cppeak3.html. Just for google. HTH Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: python.org not current
On 8 Dez., 08:40, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Norbert wrote: > > the python websitehttp://www.python.org/mentions Version 2.3.6 and > > 2.4.4 on the most prominent place. Shouldn't this be changed to 2.5.x > > ?you're looking at the news section: the 2.3.6 and 2.4.4 maintenance > releases were made after 2.5 was released. Did not notice that, maybe a subheding would be in order ? > > Norbert -- http://mail.python.org/mailman/listinfo/python-list
python.org not current
Hello all, the python website http://www.python.org/ mentions Version 2.3.6 and 2.4.4 on the most prominent place. Shouldn't this be changed to 2.5.x ? Regards Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: EasyInstall under Windows - strange behaviour
[EMAIL PROTECTED] schrieb: > > I'm no expert, but it sounds like you associated the .py file extension > with the pythonwin program, so that's what's being used to open it > (instead of the desired python.exe). See > http://support.microsoft.com/kb/320033 for more information. > > hth, > Don Thank you for the tip, but I checked this and this is not the case. I presume that I missed a step in the ez_setup process. Thanks again Norbert -- http://mail.python.org/mailman/listinfo/python-list
EasyInstall under Windows - strange behaviour
Hello all, i try to install ZSI under python 2.5 and windows 2000. I Downloaded the egg and tried the following c:\Python25\Scripts>easy_install.exe c:\download\ZSI-2.0_rc3-py2.5.egg The result is that pythonwin pops up and shows the file : c:\Python25\Scripts\easy_install-script.py : !C:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe # EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c3','console_scripts','easy_install' __requires__ = 'setuptools==0.6c3' import sys from pkg_resources import load_entry_point sys.exit( load_entry_point('setuptools==0.6c3', 'console_scripts', 'easy_install')() ) What is going on here ? I presume that there are some trivial things I don't understand, can someone provide apointer or hint ? Thank you for your time ! Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: small python cgi webserver
Fabian Braennstroem wrote: [...] >>In your response (cgi-script) you have to divide the header from the >>content '\r\n\r\n'. > > > I am not sure, what that means!? ... but it works :-) > We are talking about HTTP, take a look at the HTTP response in version 1.1: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6 As you may see you separate the header of a response from the body by an empty line, generated with CRLF. Since one CRLF ends the line inside the header you need two of them. Bye Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: small python cgi webserver
Fabian Braennstroem wrote: [...] > > Maybe, I understood something wrong, but I thought that the > above 'webserver' script would replace apache in my case; at > least I hoped!? > It does. The 'ServerRoot' and 'DocumentRoot' directories are the directories you are starting your webserver in. Create a 'cgi' directory inside this and consider that you have to name it in the serverscript in relation to the serverroot! cgi_directories=["/home/fab/Desktop/cgi-bin"] This means you have to start your server inside directory '/'. If you start your server in your home dir '/home/fab' then you have to name your cgi_directories ['/Desktop/cgi-bin']. In your response (cgi-script) you have to divide the header from the content '\r\n\r\n'. HTH Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you practice Python?
Ray wrote: [...] > Um, I mean, what if you have to use something other than > Python/Jython/IronPython? :) How do you keep your Python skill sharp? > You could use IPython as your primary shell. Than you have the opportunity to do all these nasty automation tasks -- create test data, deploy configuration files, search in logfiles for errors, etc. -- for your project in Python. Convince your project manager to develop prototypes. No one in your company is better and faster in prototyping than the Python expert Ray. HTH Norbert -- It is easier to get forgiveness than permission. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pywin32: How to import data into Excel?
Simon Brunning wrote: > On 08/11/05, Dmytro Lesnyak <[EMAIL PROTECTED]> wrote: > > I need to import some big data into Excel from my Python script. I have TXT > > file (~7,5 Mb). > > Have you considered converting your text data to CSV format? Excel > opens CSV files happily enough, and you could always automate > save-as-workbook and any formatting you need afterwards. But there are thorny issues with different locales and number formats. Excel is also just too clever in recognising dates All the best Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: Formated String in optparse
Thank You for your help, its working! Now I have an additional question. The problem is the encoding of the Text I'm using German, Can you tell me how to encode the textstring that the Windows commandline shows the special letters right? For exampel i get 'f³r' but i want 'für' (maybe reader with only an english enabled browser wouldn't see a difference..) I tried to work with the encode method of string but It didn't work for me some hint what to do? Norbert -- http://mail.python.org/mailman/listinfo/python-list
Formated String in optparse
Hi I'm using Python 24 on Windows > (2k) Is there an easy way to convince optparse to accept newline in the helpstring? and more importand also in the 'desc' string. I tried everything (from the os.linesep) to \n, \r, \r\n, ... Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading Problem
Thanks Alan, i hoped it would be something trivial :) Norbert -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading Problem
Thanks a lot, Steve, for your fast reply. But the behaviour is the same if 'threadfunction' sleeps longer than just 1 second. 'threadfunction' is of course a dummy to show the problem, imagine a longrunning background-task. If you are right, the question remains 'How can I assure that the starting function finishes, while the other thread still runs ?' . As I said, this is the purpose of threading. Thanks again Norbert -- http://mail.python.org/mailman/listinfo/python-list
Threading Problem
Hello *, i am experimenting with threads and get puzzling results. Consider the following example: # import threading, time def threadfunction(): print "threadfunction: entered" x = 10 while x < 40: time.sleep(1) # time unit is seconds print "threadfunction x=%d" % x x += 10 print "start" th = threading.Thread(target = threadfunction()) th.start() print "start completed" # (the dots are inserted becaus Google mangles the lines otherwise) This program gives the following result : start threadfunction: entered threadfunction x=10 threadfunction x=20 threadfunction x=30 start completed My aim was that the main program should continue to run while threadfunction runs in parallel. That's the point of threads after all, isn't it ? I awaited something like the following : start threadfunction: entered start completed<--- threadfunction x=10 threadfunction x=20 threadfunction x=30 Does anyone know what's going on here ? Thanks for listening ! Norbert -- http://mail.python.org/mailman/listinfo/python-list