Re: PIL: The _imaging C module is not installed

2011-05-09 Thread Nico Grubert
I had this happening to me as well someday. I recall that first installing it (python setup.py install), and then rerunning selftest, solved that error. I tried that as well. Here is the summary of the install process: build/temp.linux-x86_64-2.4/libImaging/ZipEncode.o -L/usr/local/lib

Re: Python-list Digest, Vol 92, Issue 40

2011-05-06 Thread Nico Grubert
PIL will compile and install if you don't have some development libraries and then simply not work or not work up to full steam when used. To avoid this, you need to install the appropriate libraries, among which are: libjpeg-devel freetype-devel libpng-devel Dear Albert Thank you for your

Re: PIL: The _imaging C module is not installed

2011-05-06 Thread Nico Grubert
PIL will compile and install if you don't have some development libraries and then simply not work or not work up to full steam when used. To avoid this, you need to install the appropriate libraries, among which are: libjpeg-devel freetype-devel libpng-devel Dear Albert Thank you

PIL: The _imaging C module is not installed

2011-05-05 Thread Nico Grubert
Hi there I am having trouble to install PIL 1.1.7 on CentOS. I read and followed the instructions from http://effbot.org/zone/pil-imaging-not-installed.htm However, I still get the The _imaging C module is not installed error if I run the selftest: $ python selftest.py *** The _imaging C

Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert
Dear list members I have this python list that represets a sitemap: tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, {'indent': 2, 'title':'Sub

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert
Use a stack? Whenever you start a new list, push the corresponding closing tag onto a stack. Whenever your indent level decreases, pop the stack and write out the closing tag you get. It's straightforward to use a python list as a stack. Thanks for the tip, Kushal. Do you have a short code

Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert
Hi there I have the following list 'mylist' that contains some dictionaries: mylist = [{'title':'the Fog', 'id':1}, {'title':'The Storm', 'id':2}, {'title':'the bible', 'id':3}, {'title':'The thunder', 'id':4} ] How I can sort (case insensitive) the list

Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert
Er, that should have been mylist.sort(key = lambda d: d['title'].lower()) of course. Thanks a lot for the tip, chris. Unfortunately, I only have Python 2.3.5 installed and can't upgrade to 2.4 due to an underliying application server. In python 2.3 the 'sort()' function does not excepts

Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert
Thanks a lot Stefan Peter. I'm almost there (except sorting of umlauts does not work yet). import locale def sorted(items, key): decorated = [(key(item), index, item) for index, item in enumerate(items)] decorated.sort() return [item[2] for item in decorated]

Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert
http://wiki.python.org/moin/HowTo/Sorting#Topicstobecovered Works fine. Thanks a lot for your help, Stefan. Regards Nico -- http://mail.python.org/mailman/listinfo/python-list

Re: ftplib timeout in Python 2.4

2009-12-18 Thread Nico Grubert
Try the timelimited function from this recipe http://code.activestate.com/recipes/576780/ Works perfect! Thanks a lot, Jean! -- http://mail.python.org/mailman/listinfo/python-list

ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert
Hi there, The ftplib has a timeout parameter in Python 2.6 and above. Is there a way to set a timeout in Python 2.4? Regards Nico -- http://mail.python.org/mailman/listinfo/python-list

Re: ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert
I don't know of one so you may need a workaround. What platforms do you need to support? Suse Linux Enterprise 10, 64 Bit with Python 2.4.4. I need the Python 2.4.4 for a running application Server (Zope). -- http://mail.python.org/mailman/listinfo/python-list

Re: List of paths

2009-04-08 Thread Nico Grubert
Here's a tricky case that doesn't show up in your example: In each case above, the directory names are distinct. how about: ['/desk', '/desk/ethanallen', '/desk/ikea', '/desktop', /desktop/pc', '/desktop/mac'] Should the answer be ['/desk'] or ['/desk', '/desktop'] ? Hi Scott good point.

List of paths

2009-04-01 Thread Nico Grubert
Dear Python developers I have the following (sorted) list. ['/notebook', '/notebook/mac', '/notebook/mac/macbook', '/notebook/mac/macbookpro', '/notebook/pc', '/notebook/pc/lenovo', '/notebook/pc/hp', '/notebook/pc/sony', '/desktop', '/desktop/pc/dell', '/desktop/mac/imac',

Re: List of paths

2009-04-01 Thread Nico Grubert
May be not so much pythonic, but works for i in range(len(q)): for x in q[i:]: if x.startswith(q[i]) and x!=q[i]: q.remove(x) ...but works fine. Thanks, Eugene. Also thanks to Andrew. Your example works fine, too. Thanks to remind me of the 'yield' statement! ;-)

Rebuild list of objects with redundancies on objects' attribute

2008-01-10 Thread Nico Grubert
Hi there I have a list of dummy objects which have the attributes 'location', 'name', 'gender'. Now I want to rebuild this list in order to avoid redundancies on objects with the same 'location'. Example: #-- class Dummy:

Find Replace hyperlinks in a string

2007-11-26 Thread Nico Grubert
Hi there, I have a string containing some hyperlinks. I'd like to replace every hyperlink with a HTML style link. Example: Replace 'http://www.foo.com/any_url' with 'a href=http://www.foo.com/any_url;http://www.foo.com/any_url/a' What's the best way to do this if I have a few

How to use unix_md5_crypt from Perl in Python?

2007-03-22 Thread Nico Grubert
Dear list members, I have a Perl script which crypts a password using a clearteaxt password and a username. Example: username = '[EMAIL PROTECTED]' password = 'root' The crypted password is: 'roK20XGbWEsSM' The crypted password always starts with the first 2 characters of the username

Python's email module - problem with umlauts in some email clients

2006-12-08 Thread Nico Grubert
Hi there, I wrote a short python script that sends an email using python's email module and I am using Python 2.3.5. The problem is, that umlauts are not displayed properly in some email clients: + On a windows machine running thunderbird 1.0.2 umlauts are displayed properly. The email

ldapsearch example in python-ldap?

2006-11-23 Thread Nico Grubert
Hi there, on a linux machine I am running this ldapsearch from the command line: ldapsearch -x -h myldaphost.mydomain.com \ -D CN=ldapuser,CN=Users,DC=mydomain,DC=com -w secret \ -b CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=com How can I do this with python-ldap? Regards, Nico --

PIL on Python 2.4 - ImportError: No module named _imagingft

2006-10-31 Thread Nico Grubert
Dear list members, I have installed Python 2.4.3. and PIL 1.1.5. on a Suse Linux 10 64 Bit machine. If I try import _imagingft I get this error: ImportError: No module named _imagingft Did I miss something? On my 32 But Linux with Python 2.3.5. everything works fine. Kind regards,

Re: PIL on Python 2.4 - ImportError: No module named _imagingft [Solved]

2006-10-31 Thread Nico Grubert
If I try import _imagingft I get this error: ImportError: No module named _imagingft Did I miss something? Yes, I did. Somehow, there was no _imagingft.so in the PIL directory. -- http://mail.python.org/mailman/listinfo/python-list

Convert binary image to JPEG with 72 dpi

2006-10-20 Thread Nico Grubert
Dear list members,I have the binary content of an image file and it's filename.I neither know the resolution nor the dpi of the image.No I need to convert this binary content into a 72 dpi jpeg image. Furthermore I have to resize the image so neither the width nor the height is bigger than 250

Re: Installing Python on a 64-Bit OS

2006-09-21 Thread Nico Grubert
Several changes have been made to Python 2.4 and 2.5 to support AMD64-Linux better, and not all of these changes have been incorporated into Python 2.3, as this software is no longer maintained. As others have said: you should really try to use the python 2.4 that comes with the operating

Installing Python on a 64-Bit OS

2006-09-19 Thread Nico Grubert
Hi there, I'd like to install Python 2.3.5. on a 64-Bit OS (Suse Linux Enterprise Server 10) on an AMD Opteron 64-Bit machine. I have to use Python 2.3.5. Do I need a special source archive or can I use Python-2.3.5.tgz from http://www.python.org/ftp/python/2.3.5/Python-2.3.5.tgz ? Is there

Re: Searching a string and extract all occurancies of a substring

2006-09-01 Thread Nico Grubert
is this XML, or just something that looks a little like XML ? Unfortunately, something that looks a little XML so I can't use a XML parser. But the HTML parser does the job. -- http://mail.python.org/mailman/listinfo/python-list

Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
Hi there, in a text with no carriage returns I need to look for all occurancies of this string: source id=boxparameter key=path.../parameter/source The ... can contain different values. I need to extract the string between source id=boxparameter key=path and /parameter/source. Example text:

Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
Try Beautiful Soup, or if your input is simple enough, the re module. Hi Gabriel, I first tried HTMLParser and wrote this short script: from HTMLParser import HTMLParser from htmlentitydefs import entitydefs class MyDocParser(HTMLParser): def __init__(self): self.paths = []

Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
This works as long as there are no other paramter Tags in the content that I parse. Got it. I forgot to handle the 'attrs' parameter in handle_starttag(). Changed it to: def handle_starttag(self, tag, attrs): if tag == 'parameter': if attrs == [('key',

How to change the path for python binary?

2006-08-10 Thread Nico Grubert
Hi there, I have installed Python 2.3.5 on Suse Linux 10. If I enter python in the shell, the Python 2.3.5 interpreter is called. After I installed Python 2.4.3. the Python 2.4.3 interpreter is called which is the default behaviour I guess. which python brings me /usr/local/bin/python which

Search substring in a string and get index of all occurances

2006-06-21 Thread Nico Grubert
Hi there, I would like to search for a substring in a string and get the index of all occurances. mystring = 'John has a really nice powerbook.' substr = ' ' # space I would like to get this list: [4, 8, 10, 17, 22] How can I do that without using for i in mystring which might be

Re: os.popen3() - how to close cmd window automatically?

2006-06-01 Thread Nico Grubert
replace console=[... by windows=[... in your setup.py Works perfect. Thank you, Rony! -- http://mail.python.org/mailman/listinfo/python-list

os.popen3() - how to close cmd window automatically?

2006-05-31 Thread Nico Grubert
Dear Python developers, I use a short python script in order to run an external application plus to open a browser displaying a default page. My Setup: Python 2.4.3. / Windows2000 # -- # Script shortcut.py import os import

Re: How to open https Site and pass request?

2006-05-24 Thread Nico Grubert
That depends on your OS. In Windows, I believe you would have to recompile Python from source. On Linux, you could probably just get a package. From Debian, I know that it's python-ssl. I'm sure most the others would have one as well. Hi Jerry, thank you for your reply. I use Linux and

Re: How to find out a date/time difference

2006-05-24 Thread Nico Grubert
I use datetime class in my program and now I have two fields that have the datetime format like this datetime.datetime(2006, 5, 24, 16, 1, 26) How can I find out the date/time difference ( in days) of such two fields? Hi Lad, you could do this: a = datetime.datetime(2006, 5, 24,

How to open https Site and pass request?

2006-05-23 Thread Nico Grubert
Hi there, I am trying to open an https site and pass a request to it in order to simulate the submit of an HTML form on a https site that sets an authentication cookie for a tomcat application, so the the URL I am trying to open points to a web form provided by the tomcat webserver. I tried

Re: How to open https Site and pass request?

2006-05-23 Thread Nico Grubert
import urllib import urllib2 the_url = https://myserver/application/login.do; user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } values = { 'username' : 'myuser', 'password' : 'mypasswd' } data = urllib.urlencode(values)

Re: Zope Guru...

2006-05-04 Thread Nico Grubert
In doing some research into Workflow apps regarding document management, I came across Zope. Given that it's Python Based, I figured I'd shout to the group here... If you want to develop an application with Zope+Python from scratch, there are a few Zope products out there that handle

Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Nico Grubert
Hi there, I am looking for a way to sort a list containing dictionaries. This is my example list: [{'Title': 'ABC', 'from_datetime': DateTime('2006/04/25 12:45:00 GMT+2')}, {'Title': 'DEF', 'from_datetime': DateTime('2006/04/18 12:45:00 GMT+2')}, {'Title': 'GHI', 'from_datetime':

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Nico Grubert
assuming that DateTime returns something that compares correctly, you can do something like: def sortkey(item): return item.get(from_datetime) data.sort(key=sortkey) (assuming Python 2.4 or later) Thank you very much, Frederik. Unfortunately, I can only use Python

Splitting a string

2006-02-13 Thread Nico Grubert
Dear Python users, I'd like to split a string where 'and', 'or', 'and not' occurs. Example string: s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green' I need to split s in order to get this list: ['Smith, R.', 'White', 'Blue, T.', 'Back', 'Red', 'Green'] Any idea, how I can

Re: python-soappy

2006-01-11 Thread Nico Grubert
can anybody point me to a tutorial, howto or example code of python-soappy...? google did not have really useful results about... This might be helpful: http://www-128.ibm.com/developerworks/library/ws-pyth5/ http://users.skynet.be/pascalbotte/rcx-ws-doc/python.htm Nico --

String question - find all possible versions of a person's firstname

2006-01-10 Thread Nico Grubert
Hi there, I have a string 'Michèle' that represents the firstname of a person. What's the best way to get all possible versions of this name if I consider to use these characters: e, è, é, ê I'd like to have a function that returns a list of the following names when passing 'Michèle' as

Re: String question - find all possible versions of a person's firstname

2006-01-10 Thread Nico Grubert
This sounds like a homework problem. You might try splitting the name at the e's, check the length of the resulting list and do that many nested loops. This was my idea too but I am wondering if there are any scripts for tasks like this. Nico --

How to ping in Python?

2005-12-05 Thread Nico Grubert
Hi there, I could not find any ping Class or Handler in python (2.3.5) to ping a machine. I just need to ping a machine to see if its answering. What's the best way to do it? Kind regards, Nico -- http://mail.python.org/mailman/listinfo/python-list

Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
add ftp.set_debuglevel(3) so you can see what the goes on the wire (without that information, it's hard to tell if it's a bug in the library or a glitch in your server). /F Hello Fredrik , thank you for your reply. I did a ftp.set_debuglevel(3) and ftp.nlst() now prints:

Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
it's not obvious how Python could translate '' to anything other than an empty list, so it sure looks like a server issue. (or is a problem with running in passive mode? can you test with- out using passive mode on the same server?) I thought using ftp.set_pasv(0) sets active mode so I

ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-24 Thread Nico Grubert
Hi there, I am using the ftplib library to connect to a ftp server. After I got connected, I can see a list of file in the current directory using ftp.dir() or ftp.retrlines('LIST'). But using ftp.nlst() returns an empty list which seems somehow strange to me. Here is, what I did: from

Question about parsing a string

2005-10-10 Thread Nico Grubert
Hi there, I would like to parse a string in Python. If the string is e.g. '[url=http://www.whatever.org][/url]' I would like to generate this string: 'a href=http://www.whatever.org;http://www.whatever.org/a' If the string is e.g. '[url=http://www.whatever.org]My link[/url]' I would like to

How to use a timer in Python?

2005-09-23 Thread Nico Grubert
Hi there, on a Linux machine running Python 2.3.5. I want to create a file 'newfile' in a directory '/tmp' only if there is no file 'transfer.lock' in '/temp'. A cronjob creates a file 'transfer.lock' in '/temp' directory every 15 minutes while the cronjob is doing something. This job takes

Re: How to use a timer in Python?

2005-09-23 Thread Nico Grubert
Hi Sybren and Wolfram, thank you very much for the time.sleep() tip. My program reads like this now. import os import time WINDOWS_SHARE = 'C:\\Temp' while 'transfer.lock' in os.listdir( WINDOWS_SHARE ): print Busy, please wait... time.sleep(10) f = open(WINDOWS_SHARE + '/myfile',

Re: How to use a timer in Python?

2005-09-23 Thread Nico Grubert
That all sounds very race-y to me! The cron-job and the other process need to take the same lock, otherwise the cron-job will start 1ms after the other process checks for transfer.lock and before it has a chance to create newfile and there will be trouble. Using files as locks isn't

How to use writelines to append new lines to an existing file

2005-09-22 Thread Nico Grubert
Hi there, I would like to open an existing file that contains some lines of text in order to append a new line at the end of the content. My first try was: f = open('/tmp/myfile', 'w') #create new file for writing f.writelines('123') #write first line f.close() f =

How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
Hi there, I would like to copy a file from one machine (machine #01) to another (machine #02). machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5 machine #02: Windows Machine, Destination Dir: Share\temp\files\ Both machines are in one network so they can communicate each other. In order to

Re: How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
This isn't really a Python question, as this problem would exist irrespective of the language you are using. One possibility would be to run Samba (www.smaba.org) on the Linux machine so it offered a share to the Windows machine. Then you could just write to a UNC path

Remove HTML tags (except anchor tag) from a string using regular expressions

2005-02-01 Thread Nico Grubert
Hello, I want to remove all html tags from a string content except a ...xxx/a. My script reads like this: ### import re content = re.sub('([^!]([^]|\n)*)', '', content) ### It works fine. It removes all html tags from content. Unfortunately, this also removes a ...xxx/a occurancies. Any idea,