Re: changing URLs in webpages, python solutions?

2009-01-17 Thread Abandoned
On Jan 18, 4:07 am, Simon Forman sajmik...@gmail.com wrote: Hey folks, I'm having trouble finding this through google so I figured I'd ask here. I want to take a webpage, find all URLs (links, img src, etc.) and rewrite them in-place, and I'd like to do it in python (pure python

How can i find a file size on the web ?

2007-12-02 Thread Abandoned
Hi.. Can i find a file size witdhout download? For example: www.roche.com/rochea_z_sp.pdf How can i find its size with python ? I'm sorry for my bad english. -- http://mail.python.org/mailman/listinfo/python-list

Mod python set cookie for all subdomains

2007-12-02 Thread Abandoned
Hi.. I set cookie from www.domain.com but i'cant read this cookie from subdomain.domain.com How can i set cookie for all subdomains ? My set cookie code is: cookie = Cookie.Cookie('Login-Data', data) cookie.expires = time.time() + 992 Cookie.add_cookie(req, cookie) --

Re: return image in mod python

2007-11-20 Thread Abandoned
On Nov 19, 5:32 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: On Nov 19, 12:36 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: Hi i have a problem. def showimage(req): from PIL import Image im=Image.open(c:\image-2.jpg

Re: how can i return a image in mod python ?

2007-11-19 Thread Abandoned
On Nov 18, 10:27 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Nov 18, 6:46 am, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to show the pictures with mod python directly. def showimage(req): some process... open /var/www/a.jpg and print for example if i open

return image in mod python

2007-11-19 Thread Abandoned
Hi i have a problem. def showimage(req): from PIL import Image im=Image.open(c:\image-2.jpg) im.thumbnail((800,600), Image.ANTIALIAS) req.sendfile(im) give me some error. How can i return this image witdhout save ? --

Re: return image in mod python

2007-11-19 Thread Abandoned
On Nov 19, 12:36 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: Hi i have a problem. def showimage(req): from PIL import Image im=Image.open(c:\image-2.jpg) im.thumbnail((800,600), Image.ANTIALIAS) req.sendfile(im) give me some error

how can i return a image in mod python ?

2007-11-17 Thread Abandoned
Hi.. I want to show the pictures with mod python directly. ( it support cache and image headers) def showimage(req): some process... open /var/www/a.jpg and print How can i do it ? I'm sorry for my bad english. Kind Regards -- http://mail.python.org/mailman/listinfo/python-list

how can i return a image in mod python ?

2007-11-17 Thread Abandoned
Hi.. I want to show the pictures with mod python directly. def showimage(req): some process... open /var/www/a.jpg and print for example if i open: domain.com/a.py/showimage It must show me image directly (no redirect or html) How can i do it ? I'm sorry for my bad english. Kind

Re: Copy database with python..

2007-11-02 Thread Abandoned
On Nov 2, 4:19 pm, Paul McNett [EMAIL PROTECTED] wrote: Abandoned wrote: Hi. I want to copy my database but python give me error when i use this command. cursor.execute(pg_dump mydata old.dump) What is the problem ? And how can i copy the database with python ? You are just going

Re: Copy database with python..

2007-11-02 Thread Abandoned
On Nov 2, 4:11 pm, Martin Sand Christensen [EMAIL PROTECTED] wrote: Abandoned == Abandoned [EMAIL PROTECTED] writes: Abandoned I want to copy my database but python give me error when i Abandoned use this command. cursor.execute(pg_dump mydata old.dump) Abandoned What is the problem

Copy database with python..

2007-11-02 Thread Abandoned
Hi. I want to copy my database but python give me error when i use this command. cursor.execute(pg_dump mydata old.dump) What is the problem ? And how can i copy the database with python ? Note: The database's size is 200 GB -- http://mail.python.org/mailman/listinfo/python-list

3 number and dot..

2007-10-31 Thread Abandoned
Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? -- http://mail.python.org/mailman/listinfo/python-list

Re: 3 number and dot..

2007-10-31 Thread Abandoned
On Oct 31, 10:18 pm, Paul McNett [EMAIL PROTECTED] wrote: Abandoned wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? Assuming that the dots are always in the 3rd and 7th position in the string: def conv(s, sep=.): l = [s[0:3], s[3:6], s[6

Re: 3 number and dot..

2007-10-31 Thread Abandoned
On Oct 31, 10:38 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Oct 31, 2:58 pm, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? x = (12332321,) while (x[0]0): x=divmod(x[0],1000)+x[1:] ... x (0, 12, 332, 321) ..join

Re: 3 number and dot..

2007-10-31 Thread Abandoned
On Oct 31, 10:38 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Oct 31, 2:58 pm, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? x = (12332321,) while (x[0]0): x=divmod(x[0],1000)+x[1:] ... x (0, 12, 332, 321) ..join

Re: 3 number and dot..

2007-10-31 Thread Abandoned
On Oct 31, 10:50 pm, Roberto Bonvallet [EMAIL PROTECTED] wrote: On 31 oct, 16:58, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? x = 12332321 '.'.join(''.join(i for n, i in g) for k, g in groupby(enumerate(reversed

Re: 3 number and dot..

2007-10-31 Thread Abandoned
On Oct 31, 10:50 pm, Roberto Bonvallet [EMAIL PROTECTED] wrote: On 31 oct, 16:58, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? x = 12332321 '.'.join(''.join(i for n, i in g) for k, g in groupby(enumerate(reversed

interesting threading result..

2007-10-29 Thread Abandoned
Hi.. I have a interesting threading result.. class GetData(threading.Thread): def __init__(self, name): threading.Thread.__init__(self) self.name = name def run(self): self.data={2:3, 3:4...} current = GetData(a) nlist.append(current) current.start() end=[] dd=nlist[0]

Re: interesting threading result..

2007-10-29 Thread Abandoned
On Oct 29, 11:29 pm, Alan Franzoni [EMAIL PROTECTED] wrote: Il Mon, 29 Oct 2007 09:08:01 -0700, Abandoned ha scritto: I'm sorry my bad english. King regards.. You must have messed up with something. You didn't post a working snippet in first place, so you should do it now. I suppose

insert string problems..

2007-10-28 Thread Abandoned
Hi.. I want to insert some data to postgresql.. My insert code: yer=019 cursor.execute(INSERT INTO ids_%s (id) VALUES (%s), (yer, id)) I don't want to use % when the insert operation. in this code give me this error: psycopg2.ProgrammingError: syntax error at or near '019' LINE 1: SELECT link_id

Re: insert string problems..

2007-10-28 Thread Abandoned
Also.. a=123,245,1235,663 cursor.execute(SELECT id, name FROM data WHERE id in (%s), (a,)) In this query must be: SELECT id, name FROM data WHERE id in (123,245,1235,663) but it looks: SELECT id, name FROM data WHERE id in (123,245,1235,663) How can i delete ? --

Re: insert string problems..

2007-10-28 Thread Abandoned
On Oct 28, 9:45 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 28 Oct 2007 00:24:34 -0700, Abandoned wrote: Hi.. I want to insert some data to postgresql.. My insert code: yer=019 cursor.execute(INSERT INTO ids_%s (id) VALUES (%s), (yer, id)) I don't want to use

Which index can i use ?

2007-10-28 Thread Abandoned
Hi.. I want to do index in postgresql python. My table: id(int) | id2(int) | w(int) | d(int) My query: select id, w where id=x and id2=y (sometimes and d=z) I have too many insert and select operation on this table. And which index type can i use ? Btree, Rtree, Gist or Hash ? Also I want to

How can i do proxy in urllib.urlopen?

2007-10-27 Thread Abandoned
Hi i want to do proxy in urllib.urlopen how can i do this ? And which proxy type have i can prefer ? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i do proxy in urllib.urlopen?

2007-10-27 Thread Abandoned
I read the urllib reference and set http_proxy=my proxy. But it didn't work. I can't even get authenticated. Is there anyway that we can set the proxy? -- http://mail.python.org/mailman/listinfo/python-list

Parallel insert to postgresql with thread

2007-10-25 Thread Abandoned
Hi.. I use the threading module for the fast operation. But i have some problems.. This is my code sample: = conn = psycopg2.connect(user='postgres',password='postgres',database='postgres') cursor = conn.cursor() class paralel(Thread): def __init__ (self, veriler, sayii):

Delete all not allowed characters..

2007-10-25 Thread Abandoned
Hi.. I want to delete all now allowed characters in my text. I use this function: def clear(s1=): if s1: allowed = [u'+',u'0',u'1',u'2',u'3',u'4',u'5',u'6',u'7',u'8',u'9',u' ', u'Ş', u'ş', u'Ö', u'ö', u'Ü', u'ü', u'Ç', u'ç', u'İ', u'ı', u'Ğ', u'ğ', 'A', 'C', 'B', 'E', 'D', 'G', 'F',

threading problem..

2007-10-25 Thread Abandoned
Hi.. I want to threading but i have a interesting error.. == class SelectAll(threading.Thread): def __init__(self, name): threading.Thread.__init__(self) self.name = name #kelime def run(self): self.result=... nglist=[] current = SelectAll(name)

How can i protect text format ?

2007-10-23 Thread Abandoned
Hi.. I want to do a forum with python but i have a problem.. I have a textarea and i write: line 1 hi line 2 how r u And then i save to this database ( colomn data type is text) And than it looks line 1 hi line 2 how r u.. How can i protect \n characters ? --

Re: How can i protect text format ?

2007-10-23 Thread Abandoned
On Oct 23, 4:41 pm, J. Clifford Dyer [EMAIL PROTECTED] wrote: On Tue, Oct 23, 2007 at 06:30:18AM -0700, Abandoned wrote regarding How can i protect text format ?: Hi.. I want to do a forum with python but i have a problem.. I have a textarea and i write: line 1 hi line 2 how r u

Re: Selection error...

2007-10-21 Thread Abandoned
cursor.execute(SELECT id from templinks where url=%s, (URL,) ) Yes i already try this before ask. URL.decode('latin-1').encode('utf-8') to transcode it into utf-8. i know this but how do you know the html encoding's a latin-1 ? Html encoding is to be iso-8859-9 or ascii or cp1254 ... For this

How can i store pickle dumps data ?

2007-10-20 Thread Abandoned
Hi.. I have some dictionary as {2:3, 4:6, 5:7.} I want to pickle to these dictionary and save to database but i couldn't.. My code for adding.. a=eval(dict) a=pickle.dumps(a, -1) cursor2.execute(INSERT INTO cache VALUES ('%s', %s), (x[0],a)) conn2.commit() i try in UTF-8 postresql

Re: How can i store pickle dumps data ?

2007-10-20 Thread Abandoned
On Oct 20, 5:32 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned schrieb: Hi.. I have some dictionary as {2:3, 4:6, 5:7.} I want to pickle to these dictionary and save to database but i couldn't.. My code for adding.. a=eval(dict) a=pickle.dumps(a, -1) cursor2

Selection error...

2007-10-20 Thread Abandoned
Hi.. I want to select datas but some datas give me this error: psycopg2.ProgrammingError: invalid byte sequence for encoding UTF8: 0xc720 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by client_encoding. My select

Convert string to command..

2007-10-18 Thread Abandoned
I want to convert a string to command.. For example i have a string: a=['1'] I want to do this list.. How can i do ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Abandoned
Thanks you all answer.. But eval is very slow at very big dictionary {2:3,4:5,6:19} (100.000 elements) Is there any easy alternative ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:14 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: Thanks you all answer.. But eval is very slow at very big dictionary {2:3,4:5,6:19} (100.000 elements) Is there any easy alternative ? How big? How slow? For me, a 1-element list takes 0.04 seconds

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:26 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Abandoned [EMAIL PROTECTED] writes: 173.000 dict elements and it tooks 2.2 seconds this very big time for my project If you're generating the string from Python, use cPickle instead. Much faster: import time d = dict((i, i+1

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:35 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: On Oct 18, 6:14 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: Thanks you all answer.. But eval is very slow at very big dictionary {2:3,4:5,6:19} (100.000 elements) Is there any

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:51 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 18 Oct 2007 08:41:30 -0700, Abandoned wrote: import cPickle as pickle a={2:3,4:6,2:7} s=pickle.dumps(a, -1) g=pickle.loads(s); print g '{2:3,4:6,2:7}' Thank you very much for your answer but result

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 6:57 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: On Oct 18, 6:35 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: On Oct 18, 6:14 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Abandoned wrote: Thanks you all answer.. But eval is very

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 7:02 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Abandoned [EMAIL PROTECTED] writes: import cPickle as pickle a={2:3,4:6,2:7} s=pickle.dumps(a, -1) g=pickle.loads(s); print g '{2:3,4:6,2:7}' Thank you very much for your answer but result is a string ?? Because you gave

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 7:40 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Abandoned [EMAIL PROTECTED] writes: Sorry i can't understand :( Yes my database already has data in the {..} format and i select this and i want to use it for dictionary.. But, do you use Python to create that data? If so, simply

Re: Convert string to command..

2007-10-18 Thread Abandoned
On Oct 18, 8:53 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Abandoned [EMAIL PROTECTED] writes: When you load it, convert the string to dict with cPickle.loads instead of with eval. Yes i understand and this very very good ;) Good! :-) psycopg2.ProgrammingError: invalid byte

Order by value in dictionary

2007-10-17 Thread Abandoned
Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element.. Result must be: [b, a, d, c .] ( first 100 element) I done this using FOR and ITERATOR but it tooks 1 second and this

Re: Order by value in dictionary

2007-10-17 Thread Abandoned
Very very thanks everbody.. These are some method.. Now the fastest method is second.. 1 === def sortt(d): items=d.items() backitems=[ [v[1],v[0]] for v in items] backitems.sort() #boyut=len(backitems) #backitems=backitems[boyut-500:] a=[ backitems[i][1] for i in

Re: Order by value in dictionary

2007-10-17 Thread Abandoned
I tried these: def largest_sort(d, n): return sorted(d, key=d.__getitem__, reverse=True)[:n] def largest_heap(d, n): return heapq.nlargest(n, d, d.__getitem__) def sortt(d): sorted_items = sorted((item[1], item[0]) for item in d.iteritems(), reverse=True)

int to str in list elements..

2007-10-14 Thread Abandoned
Hi.. I have a list as a=[1, 2, 3 ] (4 million elements) and b=,.join(a) than TypeError: sequence item 0: expected string, int found I want to change list to a=['1','2','3'] but i don't want to use FOR because my list very very big. I'm sorry my bad english. King regards --

configure urllib.urlretrieve timeout

2007-10-07 Thread Abandoned
Hi.. I want to set 30 second urllib.urlretrieve timeout.. Because if urllib.urlretrieve can't connect to page wait 1-2 hour... I download the images to my server with urlretrieve if you know the better way please help me. I'm sorry my bad english.. --

Pil image module, mode bug..

2007-10-07 Thread Abandoned
Hi.. I find the picture color with: im=Image.open(/%s %name) color=im.mode #p=black beyaz rgb=color L=grey This usually work true but in these pictures: http://malatya.meb.gov.tr/images/alt/ilsis_logo.gif http://malatya.meb.gov.tr/images/meb.gif Say me P (blackwhite) but these pictures are

Re: Pil image module, mode bug..

2007-10-07 Thread Abandoned
On Oct 7, 4:47 pm, Michal Bozon [EMAIL PROTECTED] wrote: On Sun, 07 Oct 2007 06:03:06 -0700, Abandoned wrote: Hi.. I find the picture color with: im=Image.open(/%s %name) color=im.mode #p=black beyaz rgb=color L=grey This usually work true but in these pictures: http

Segmentation fault..

2007-10-06 Thread Abandoned
Hi.. I run a my script and 3-4 minutes later give me an error segmentation fault. What is the reason of this error ? I use in my script: Threading Psycopg2 open write to txt urlopen My platform is ubuntu linux. I'm sorry my bad english. King regards.. --

Re: Boolean parser..

2007-10-05 Thread Abandoned
On 4 Ekim, 22:29, Abandoned [EMAIL PROTECTED] wrote: Hi.. I try a boolean parser in python since 1 weak.. But i can't do this because this is very complicated :( Do you know any blooean parser script in python or how do i write a boolean parser ? example query: ((google or yahoo) or (live

Re: Boolean parser..

2007-10-05 Thread Abandoned
http://pyparsing.wikispaces.com/space/showimage/searchparser.py this is searchparser but i can't understant to use this. Can anybody explain this how to use ? -- http://mail.python.org/mailman/listinfo/python-list

remove list elements..

2007-10-05 Thread Abandoned
Hi.. I have a problem.. list1=[11, 223, 334, 4223...] 1 million element list2=[22,223,4223,2355...] 500.000 element I want to difference list1 to list2 but order very importent.. My result must be: list3=[11,334,...] I do this use FOR easly but the speed very imported for me. I want to the

Boolean parser..

2007-10-04 Thread Abandoned
Hi.. I try a boolean parser in python since 1 weak.. But i can't do this because this is very complicated :( Do you know any blooean parser script in python or how do i write a boolean parser ? example query: ((google or yahoo) or (live msn)) not web I'm sorry my bad english. King Regards.. --

Duplicate content filter..

2007-10-03 Thread Abandoned
Hi.. I'm working a search engine project now. And i have a problem. My problem is Duplicate Contents.. I can find the percentage of similarity between two pages but i have a 5 millions index and i search 5 million page contents to find one duplicate :( I want to a idea for how can i find

Re: Select as dictionary...

2007-10-01 Thread Abandoned
On 1 Ekim, 18:13, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: J. Clifford Dyer a écrit : On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote regarding Re: Select as dictionary...: IIRC, postgres' db-api connector (well, at least one of them - I don't know which

Re: Select as dictionary...

2007-10-01 Thread Abandoned
Also if i need a list id what can i do ? aia.execute(SELECT id, w from list) links=aia.fetchall() I want to.. idlist=[1, 2, 3] ( I don't want to use FOR and APPEND because the query have 2 million result and i want to speed) -- http://mail.python.org/mailman/listinfo/python-list

Combine two dictionary...

2007-10-01 Thread Abandoned
Hi.. dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and 3 millions element I want to combine dict1 and dict2 and i don't want to use FOR because i need to performance. I'm sorry my bed english. King regards.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Combine two dictionary...

2007-10-01 Thread Abandoned
On 1 Ekim, 20:41, Carsten Haese [EMAIL PROTECTED] wrote: On Mon, 2007-10-01 at 10:24 -0700, Abandoned wrote: Hi.. dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and 3 millions element I want to combine dict1 and dict2 and i don't want to use FOR because i need