Query regarding python 2.7.11 release
Hi, We are currently using Python 2.6.7 in our product. We have received below vulnerabilities from field: CVE-2014-7185 Integer overflow in bufferobject.c in Python before 2.7.8 allows context-dependent attackers to obtain sensitive information from process memory via a large size and offset in a "buffer" function. CVE-2013-1752 python: multiple unbound readline() DoS flaws in python stdlib CVE-2014-1912 python: buffer overflow in socket.recvfrom_into() CVE-2014-4650 It was discovered that the CGIHTTPServer module incorrectly handled URL encoded paths. A remote attacker could use this flaw to execute scripts outside of the cgi-bin directory, or disclose source of scripts in the cgi-bin directory Currently I can see the 2.7.11 is the latest release as per the below link: https://www.python.org/downloads/ Could you please suggest if the above mentioned vulnerabilities are resolved in the latest release? Regards Gaurav -- https://mail.python.org/mailman/listinfo/python-list
UnicodeDecodeError
I am getting this error while some testing on Python2.6, File "/usr/lib64/python2.6/httplib.py", line 774, in _send_output #msg = "\r\n".join(self._buffer) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 14: ordinal not in range(128) I tried the change suggested on this link http://web.archiveorange.com/archive/v/PJbOg9pxJoUpQA9AHp3X, its working fine after that. There seems to be some problem in httplib with unicode handling. I am running it on centos5. I am still not sure why its happening and what will be ideal solution for this? Thanks, Gaurav -- http://mail.python.org/mailman/listinfo/python-list
Get careers in Management work.
Wide ranges of careers opportunity. Management careers. http://rojgars1.webs.com/hrm.htm http://topcareer.webs.com/qualitymanagement.htm HRM, PM, marketing manager jobs and accounts jobs move to your next career start earning with manager level. http://todayvacancy.blogspot.com/2011/07/account-assistant.html http://freshersemployment.blogspot.com/2011/07/finance-management.html High-quality careers. All types of Management careers. http://sites.google.com/site/jobinmanagement/operation-management-jobs -- http://mail.python.org/mailman/listinfo/python-list
Globalize Management careers.
Site of computer jobs starts with freelance, graphics, data entry too many options in print media make career. http://rojgars1.webs.com/gov.htm http://jobscore.webs.com/retailjob.htm Get careers in Management work. Earn unlimited in Management careers. http://jobshunter.webs.com/index.htm http://topcareer.webs.com/executivemanager.htm All type of Management careers for U. Get careers in Management stage. http://macrojob.webs.com/index.htm http://macrojob.webs.com/railwayjobs.htm http://macrojob.webs.com/salesmanagement.htm http://macrojob.webs.com/humanresourcemgmt.htm http://macrojob.webs.com/financemanagement.htm http://macrojob.webs.com/supplychainmanagement.htm http://macrojob.webs.com/logisticmanagement.htm http://macrojob.webs.com/qualityassurancemgmt.htm http://macrojob.webs.com/brandmanagement.htm http://macrojob.webs.com/operationmanagement.htm http://macrojob.webs.com/investmentmanagement.htm http://macrojob.webs.com/disastermanagement.htm http://macrojob.webs.com/constructionmanagement.htm -- http://mail.python.org/mailman/listinfo/python-list
High respected career - Careers in next month
Potential income in Management careers. Work in Management careers. Visit: http://managementjobs.webs.com/index.htm http://jobscore.webs.com/executivemanager.htm Careers for Management - Careers in next month http://employmentsmanagement.blogspot.com/ http://rojgars1.webs.com/gov.htm -- http://mail.python.org/mailman/listinfo/python-list
Chances in Management careers.
Careers for fresher. Great earning in Management careers. http://topcareer.webs.com/index.htm http://jobshunter.webs.com/index.htm Government Vacancies for all graduates earn in salary. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Great chance for Management work.
Railroad employers, opportunities in only on the site for government, banking and data entry. http://rojgars.webs.com/Railwayjobs.htm http://rojgars1.webs.com/gov.htm Cash income in Management careers. Globalize Management careers. http://managementjobs.webs.com/mm.htm http://jobshunter.webs.com/industrialmanagement.htm -- http://mail.python.org/mailman/listinfo/python-list
All types of Management careers.
Rush for Perfect computer part time online home jobs to earn unlimited. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm Management careers to earn extra. Employments in Management careers. http://managementjobs.webs.com/pm.htm http://jobshunter.webs.com/index.htm -- http://mail.python.org/mailman/listinfo/python-list
Option in Management careers.
Rush for career in computer and government jobs potential revenue. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm Huge chance in Management careers. Management careers for you. http://managementjobs.webs.com/pm.htm http://topcareer.webs.com/humanresourcemgmt.htm -- http://mail.python.org/mailman/listinfo/python-list
Employments Chance in Management work.
The Greatest site to Start your own Work from Home earn start earning. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm Great earning in Management careers. Sales and Management work. http://managementjobs.webs.com/pm.htm & http://topcareer.webs.com/humanresourcemgmt.htm -- http://mail.python.org/mailman/listinfo/python-list
You can get careers in Management work.
Great careers in Management work. Management careers bases. http://topcareer.webs.com/executivemanager.htm http://rojgars1.webs.com/gov.htm -- http://mail.python.org/mailman/listinfo/python-list
Career in IT and management
Latest job listing with IT manager job search and government jobs http://topcareer.webs.com/itmanagement.htm Are you looking for a job in government, this is the right place to start. http://rojgars1.webs.com/gov.htm http://printmediajobs.webs.com/fl.htm -- http://mail.python.org/mailman/listinfo/python-list
Management careers.
Big chance in Management careers. Careers recruitment in Management work. http://topcareer.webs.com/executivemanager.htm http://topcareer.webs.com/executivemanager.htm Government Jobs in site lot of opportunities for graduates. http://rojgars1.webs.com/gov.htm http://printmediajobs.webs.com/fl.htm -- http://mail.python.org/mailman/listinfo/python-list
Get careers in Management stage.
Great careers in Management work. Institutional careers in Management http://topcareer.webs.com/humanresourcemgmt.htm & http://rojgars.webs.com/bankingjobs.htm Full ranges of Banking and insurance banking jobs, railway jobs opportunities to make career. http://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Fresher career in Management work.
Recent recruitment you can reach your goal. Careers recruitment. http://managementjobs.webs.com/itm.htm http://topcareer.webs.com/businessmanagement.htm Latest government works to earn money, other vacancies in office jobs. http://printmediajobs.webs.com/index.htm http://rojgars1.webs.com/gov.htm -- http://mail.python.org/mailman/listinfo/python-list
Great chance for Management work.
Best site for management careers. Career in Management. http://jobscore.webs.com/executivemanager.htm http://topcareer.webs.com/businessmanagement.htm Chances for banking career listing to all over cites person can get work as bank employee. http://rojgars1.webs.com/gov.htm http://printmediajobs.webs.com/fl.htm -- http://mail.python.org/mailman/listinfo/python-list
Earn in Management careers.
On Management careers base, Earn monthly. Supporting Management careers. http://managementjobs.webs.com/pm.htm & http://topcareer.webs.com/humanresourcemgmt.htm Offers for job seekers Opportunities for you Make your career. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Cash your skill in Management careers.
Careers in Management work. Careers for your future. http://managementjobs.webs.com/hrm.htm http://topcareer.webs.com/businessmanagement.htm Fresh coming up complete government career, computer jobs. http://rojgars1.webs.com/gov.htm http://printmediajobs.webs.com/fl.htm -- http://mail.python.org/mailman/listinfo/python-list
Big opportunity.
Complete resource for free or paid Work at home jobs online/offline. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm Get start earning at your Management work. Great career in Management Visit: http://managementjobs.webs.com/pm.htm & http://topcareer.webs.com/humanresourcemgmt.htm -- http://mail.python.org/mailman/listinfo/python-list
Lot of chance in Management work.
Great earning in Management careers. Start career in Management work. http://topcareer.webs.com/humanresourcemgmt.htm http://managementjobs.webs.com/pm.htm Big money receives by Part Time Jobs in computer or government jobs. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Live careers in Management work.
Employments in Management careers. Management careers earn cash. Wide range in Management careers. http://managementjobs.webs.com/pm.htm http://topcareer.webs.com/humanresourcemgmt.htm Today vacancies for railway engineers, the site updating daily for government, banking and computer jobs. http://rojgars.webs.com/Railwayjobs.htm http://rojgars1.webs.com/gov.htm -- http://mail.python.org/mailman/listinfo/python-list
Earn unlimited in Management careers.
Additional income resources - Fresher or experience candidate can grow career http://managementjobs.webs.com/pm.htm Get careers in Management work. Careers recruitments. http://topcareer.webs.com/businessmanagement.htm Work from home genuine bulk data entry, home and government jobs sources. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Careers recruitments.
Lot of chance in Management work. Computer jobs, internet jobs, earn at home unlimited. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm Careers recruitments in Management work. All types of Management careers. http://managementjobs.webs.com/pm.htm & http://jobscore.webs.com/executivemanager.htm -- http://mail.python.org/mailman/listinfo/python-list
Great career in Management
Work from home genuine bulk data entry, home and government jobs sources. http://rojgars1.webs.com/gov.htm http://rojgars.webs.com/bankingjobs.htm Easy Management careers for you. Get start earning at your Management work. Visit: http://managementjobs.webs.com/pm.htm & http://jobscore.webs.com/executivemanager.htm -- http://mail.python.org/mailman/listinfo/python-list
Institutional careers in Management work.
Careers recruitments in Management work. Employments in Management careers. http://managementjobs.webs.com/pm.htm & http://jobscore.webs.com/executivemanager.htm Rush for career in government and computer jobs potential revenue. http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check all elements of a list are same or different
Thanks! That works! On Wed, Apr 15, 2009 at 6:14 PM, Chris Rebert wrote: > > On Wed, Apr 15, 2009 at 5:49 PM, Chris Rebert wrote: > >> > >> On Wed, Apr 15, 2009 at 2:36 PM, Gaurav Moghe wrote: > >> > Hi, > >> > > >> > I am an amateur python user I wanted to know how do I know whether all > >> > the > >> > contents of a list are all same or all different? Now, I could > certainly > >> > write a loop with a counter. But is there a ready command for that? > >> > Checked > >> > a lot of docs and this mailing list, but didnt get anything > worthwhile. > >> > Would be glad to know. > >> > >> All same: > >> > >> list_1 == list_2 > >> > >> All different: > >> > >> all(x != y for x, y in zip(list_1, list_2)) > >> > On Wed, Apr 15, 2009 at 2:55 PM, Gaurav Moghe wrote: > > Hi Chris, > > > > Thanks for the reply. But I am interested in analysing the contents of > just > > one list. For example, > > > > list1=[1,2,3,4,5,6] > > So, the logical statement would probably be: > > if list1==(contains all same values), print "Same">False > > if list1==(contains all different values), print "Different" >True > > > > I wanted to know here whether there is a command/function that can do > > exactly this. I hope I am more clearer than my last try! > > Ah, okay. Then you want: > > def all_same(lst): >return len(set(lst)) == 1 > > def all_different(lst): >return len(set(lst)) == len(lst) > > Note that these require all the elements of the list to be hashable. > > Cheers, > Chris > -- > I have a blog: > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check all elements of a list are same or different
Hi Chris, Thanks for the reply. But I am interested in analysing the contents of just one list. For example, list1=[1,2,3,4,5,6] So, the logical statement would probably be: if list1==(contains all same values), print "Same">False if list1==(contains all different values), print "Different" >True I wanted to know here whether there is a command/function that can do exactly this. I hope I am more clearer than my last try! Thanks! Gaurav On Wed, Apr 15, 2009 at 5:49 PM, Chris Rebert wrote: > On Wed, Apr 15, 2009 at 2:36 PM, Gaurav Moghe wrote: > > Hi, > > > > I am an amateur python user I wanted to know how do I know whether all > the > > contents of a list are all same or all different? Now, I could certainly > > write a loop with a counter. But is there a ready command for that? > Checked > > a lot of docs and this mailing list, but didnt get anything worthwhile. > > Would be glad to know. > > All same: > > list_1 == list_2 > > All different: > > all(x != y for x, y in zip(list_1, list_2)) > > Cheers, > Chris > -- > I have a blog: > http://blog.rebertia.com > -- Gaurav Moghe Graduate Student Evolutionary Genomics Lab Dept of Plant Biology Michigan State University USA -- http://mail.python.org/mailman/listinfo/python-list
How to check all elements of a list are same or different
Hi, I am an amateur python user I wanted to know how do I know whether all the contents of a list are all same or all different? Now, I could certainly write a loop with a counter. But is there a ready command for that? Checked a lot of docs and this mailing list, but didnt get anything worthwhile. Would be glad to know. Thanks! Gaurav -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.4 vs 2.5 - Unicode error
On Jan 21, 7:08 pm, John Machin wrote: > > To replace non-ASCII characters in a UTF-8-encoded string by spaces: > | >>> u8 = ' and 25\xc2\xb0F' > | >>> u = u8.decode('utf8') > | >>> ''.join([chr(ord(c)) if c <= u'\x7f' else ' ' for c in u]) > | ' and 25 F' Thanks John for your reply. This is what I needed. Cheers, Gaurav -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.4 vs 2.5 - Unicode error
> The 0xc2 strongly suggests that you are feeding the beast data encoded > in UTF-8 while giving it no reason to believe that it is in fact not > encoded in ASCII. Curiously the first errant byte is a long way (4KB) > into your data. Consider doing > print repr(data) > to see what you've actually got there. >>> sqlStr[4352:4362] ' and 25\xc2\xb0F' All I want to do is to just replace all the non-ascii characters by a space. > I'm a little skeptical about the "2.4 works, 2.5 doesn't" notion -- > different versions of mysql, perhaps? I am trying to put content into the mysql server running on machine A, from machine B & machine C with different versions of python. So I don't think this is a mysql issue. > Show at the very least the full traceback that you get. Try to write a > short script that demonstrates the problem with 2.5 and no problem > with 2.4, so that (a) it is apparent what you are doing (b) the > problem can be reproduced if necessary by someone with access to > mysql. Traceback (most recent call last): File "", line 1, in File "putDataIntoDB.py", line 164, in cursor.execute(sqlStr) File "/usr/lib64/python2.5/site-packages/MySQLdb/cursors.py", line 146, in execute query = query.encode(charset) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4359: ordinal not in range(128) > You might like to explain why you think that doubling backslashes in > your SQL is a good idea, and amplify "some processing on the text". I thought this will achieve 2 things. a) It will escape any unicode character (obviously, I was wrong. Got carried away by the display. I thought \xc2 will get escaped to \\xc2, which is completely preposterous). b) It will make sure that the escape sequences in the string (e.g. '\n') are received by mysql as an escape sequence. Thanks for your reply! Gaurav > HTH, > John -- http://mail.python.org/mailman/listinfo/python-list
Python 2.4 vs 2.5 - Unicode error
Hi, I am trying to put some webpages into a mysql database using python (after some processing on the text). If I use Python 2.4.2, it works without a fuss. However, on Python 2.5, I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4357: ordinal not in range(128) Before sending the (insert) query to the mysql server, I do the following which I think should've taken care of this problem: sqlStr = sqlStr.replace('\\', '') (where sqlStr is the query). Any suggestions? Thanks! Gaurav -- http://mail.python.org/mailman/listinfo/python-list
receive data through a python program from javascript
Hi all, I have a javascript.I want to send some data from this javascript to a python program that is on zope on my local system... What can be the python program -- http://mail.python.org/mailman/listinfo/python-list
setting permissions to a file from linux.
Hi all, I have a text file in a directory on unix system. Using a python program i want to change that file's permissions. How could this be done. Thanks -- http://mail.python.org/mailman/listinfo/python-list
open a new terminal window from another terminal window in linux/unix system
Dear all, I am using Microsoft Windows XP.Using putty.exe,I connected to LINUX server and a terminal window gets opened.Here i logeed in as root. What i want to do is open another terminal window from already opened terminal window. Can this be achieved.If yes,please provide a tested solution Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How to open a shell prompt from an existing shell prompt
Dear Tino, There is no subprocess module in python 2.3.5. My goal is: 1.Open a terminal window and login as root. 2.Issue some command in the terminal window that will open another terminal,similar to the onealready opened. Am i clear now. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to open a shell prompt from an existing shell prompt
Dear Tino, I am using python 2.3.5. on POSIX system,I have the simple query as: I log into the shell as root.Can i issue some command that will open another terminal?(i.e I get a duplicate copy of the shell prompt already opened) -- http://mail.python.org/mailman/listinfo/python-list
Re: open a shell prompt froma python program
HI, I am getting the following error: konsole: cannot connect to X server do i need to install the related files. -- http://mail.python.org/mailman/listinfo/python-list
Re: open a shell prompt froma python program
On Oct 30, 2:59 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote: > gaurav kashyap wrote: > > Dear all, > > > Can u tell me a python program that when executed in a shell > > prompt,opens another shell prompt. > > > Simply i want to open a shell prompt from a python program. > > I think you're looking for: > > import os > os.system("/bin/sh") Dear, Its not opening a new window, I want to do that only from already opened shell prompt window -- http://mail.python.org/mailman/listinfo/python-list
open a shell prompt froma python program
Dear all, Can u tell me a python program that when executed in a shell prompt,opens another shell prompt. Simply i want to open a shell prompt from a python program. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How to open a shell prompt from an existing shell prompt
reply please -- http://mail.python.org/mailman/listinfo/python-list
Re: How to open a shell prompt from an existing shell prompt
Do we have subprocess module in python 2.3 -- http://mail.python.org/mailman/listinfo/python-list
How to open a shell prompt from an existing shell prompt
Dear all. On windows platform python 2.4,i can use os.startfile("filename") to execute a file on a new command prompt but on unix platform and python 2.3 what is the alternate for executing a file like above in a new shell prompt -- http://mail.python.org/mailman/listinfo/python-list
Regarding shared memory
Dear all, I have a server program that listens to a particular port and a number of client programs that connect to the server. Now i want to put some data in form of python list in main memory on server.Hence whenver a client program is run it connects to the server and access the data in main memory.Here the server calls a module that processes the data as per the client request and the returns some information to the client. I can create client and server programs using socket programming,but i am not able to put the data in shared memory and then access it. NOTE:I want to put the data in main memory only once(on the server using server program) i.e. whenever client connects to the server it should only access the data and not create a replica of data already loaded in memory.How can this be achieved thanks. -- http://mail.python.org/mailman/listinfo/python-list
How to open a shell prompt from an existing shell prompt
Dear all, I have a file in which i have written some shell commands to execute. Herein i require to open another shell prompt from this file. or simply i want to open a new shell prompt from an existing shell prompt. How could this be achieved. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How to execute a makefile from LINUX system.
Thanks -- http://mail.python.org/mailman/listinfo/python-list
How to execute a makefile from LINUX system.
Hi all, I am using Link-41b parser in my program. The windows version of it has an .exe file that can be executed using os.system command On Linux version,I have a makefile. so my question is: How to run the makefile using some python function. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Hi, I am getting the following errorTypeError: sort() takes no keyword arguments
Hi all, I am using python version 2.3.in a program , I have called the sort function.Wherein, a.sort(reverse=True) is giving the following error: TypeError: sort() takes no keyword arguments. It works in python 2.4,What can be the alternative in python 2.3 Thanks , Gaurav -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments from a python program to other while executing it with exec() or spawn() in LINUX
Thanks for the help Peter.Its working fine now -- http://mail.python.org/mailman/listinfo/python-list
passing arguments from a python program to other while executing it with exec() or spawn() in LINUX
HI all, i have two python programs as 1.py and 2.py 1.py import os import sys processID=os.spawnl(os.P_WAIT,'/usr/local/bin/python','python','/ mywork/2.py ' + 'hi') 2.py import sys domain= str(sys.argv[1] ) print domain IN LINUX while executing 1.py,the argument 'hi' is not passed to the 2.py and error message is displayed as : python: can't open file '/mywork/2.py'.If i execute the program from shell like: python 2.py hi,then it works fine IN WINDOWS this is working fine PLEASE HELP. thanks gaurav -- http://mail.python.org/mailman/listinfo/python-list
mod_python fails to load under wamp
Hi, Am using WAMP5 and python 2.4.3. I tried to install mod_python 3.2.5 for python2.4. When i tried starting wamp, Firstly there was no error message in the apache error log. I saw error message in windows event viewer : "The Apache service named Apache.exe reported the following error: >>> Syntax error on line 194 of c:/wamp/apache/conf/httpd.conf: <<< before the error.log file could be opened. "The Apache service named Apache.exe reported the following error: >>> Cannot load c:/wamp/apache/modules/mod_python.so into server: (126) The >>> specified module could not be found: <<< before the error.log file could be opened." I tried searching the net and found this http://www.modpython.org/FAQ/faqw.py?req=all#2.10 but i don't have depends.exe. if somebody has faced this problem before, can you please assist in fixing this bug.. thanks and regards, Gaurav Agarwal -- http://mail.python.org/mailman/listinfo/python-list
Re: converting file formats to txt
tks this ws really helpful, i used catdoc, catppt, xls2csv, pdftotext from xdf and ps2txt from ghostview!.. BJörn Lindqvist wrote: > On 4 Jul 2006 08:38:47 -0700, Gaurav Agarwal > <[EMAIL PROTECTED]> wrote: > > Thanks Steven, Actually i wanted a do text processing for my office > > where I can view all files in the system and use the first three to > > give a summary of the document. Instead of having somebody actually > > entering the summary. Seems there is no one code that can act as > > convertor across formats, i'll have to check out convertors for > > individual formats. > > I have some old code that does just that. It uses pdftotext, catdoc > and links to convert .doc, .pdf and .html to text. > > ## > import mimetypes > from subprocess import call, Popen, PIPE > import sys > > class ConversionError(Exception): > pass > > class UnknownMimeType(ConversionError): > pass > > class NotAMimeType(ConversionError): > pass > > class ParseError(ConversionError): > pass > > def has_program(progname): > return call(["which", progname], stdout = PIPE) == 0 > > def check_requirements(): > missing = [] > for prog in "catdoc", "pdftotext", "links": > if not has_program(prog): > missing.append(prog) > if missing: > print "You need to have the programs:", " ".join(missing) > return False > return True > > if not check_requirements(): > print "Needed external programs not found, quitting" > sys.exit(1) > > def get_catdoc_args(infile): > return ["catdoc", "-s", "8859-1", infile] > > def get_pdftotext_args(infile): > return ["pdftotext", infile, "-"] > > def get_links_args(infile): > return ["links", infile, "-dump"] > > def totext(document): > filetype_to_args_map = {"application/msword" : get_catdoc_args, > "application/pdf" : get_pdftotext_args, > "text/html" : get_links_args} > > ftype, ign = mimetypes.guess_type(document) > if not ftype: > raise NotAMimeType, "Couldn't detect mimetype for %s" % document > try: > argfunc = filetype_to_args_map[ftype] > except KeyError: > s = "Don't know how to handle %s documents" % ftype > raise UnknownMimeType, s > > p = Popen(argfunc(document), stdout = PIPE, stderr = PIPE) > text = p.stdout.read() > if p.wait(): > # Force a better exception to be thrown if the file doesn't exist. > open(document) > raise ParseError, "Failed to parse %s" % document > return text > > if __name__ == "__main__": > print totext("testpdf.pdf") > > > > -- > mvh Björn -- http://mail.python.org/mailman/listinfo/python-list
Re: converting file formats to txt
Hi All, Thanks for the advise. Am trying to play around with InfoCon, part of from Dspace project. It does file conversions. But it is written in java and uses open office plugin. Regards, Gaurav Agarwal BartlebyScrivener wrote: > I suspect you will have to process those formats separately. But the > good news, at least for doc files, is that there is a script in the > Python Cookbook 2Ed that does what you want for MS Word docs and > another script that does it for Open Office docs. > > The scripts are 2.26 and 2.27 pages 101-102. > > I think you can probably find them at the ActiveState repository also. > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/279003 > > In the book, the title of the script is "Extracting Text from Microsoft > Word Documents" > > It uses PyWin32 extension and COM to perform the conversion. > > rd -- http://mail.python.org/mailman/listinfo/python-list
Re: converting file formats to txt
Thanks Steven, Actually i wanted a do text processing for my office where I can view all files in the system and use the first three to give a summary of the document. Instead of having somebody actually entering the summary. Seems there is no one code that can act as convertor across formats, i'll have to check out convertors for individual formats. Thanks and Regards, Gaurav Agarwal Steven D'Aprano wrote: > On Tue, 04 Jul 2006 06:32:13 -0700, Gaurav Agarwal wrote: > > > Hi, > > > > I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS > > etc) to text format. > > RTF, HTML and PS are already text format. > > DOC is a secret, closed proprietary format. It will be a lot of work > reverse-engineering it. Perhaps you should consider using existing tools > that already do it -- see, for example, the word processors Abiword and > OpenOffice. They are open-source, so you can read and learn from their > code. Alternatively, you could try some of the suggestions here: > > http://www.linux.com/article.pl?sid=06/02/22/201247 > > Or you could just run through the .doc file, filtering out binary > characters, and display just the text characters. That's a quick-and-dirty > strategy that might help. > > PDF is (I believe) a compressed, binary format of PS. Perhaps you should > look at the program pdf2ps -- maybe it will help. > > If you explain your needs in a little more detail, perhaps people can give > you answers which are a little more helpful. > > > > -- > Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: converting file formats to txt
Hi, I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS etc) to text format. Regards, Gaurav Agarwal Fredrik Lundh wrote: > Marc 'BlackJack' Rintsch wrote: > > > What do you mean by 'fileformats'? A script that automagically converts > > *anything* to text? What about pictures? > > that's a one-and-a-half-liner: > > import Image, sys; print list(Image.open(sys.argv[1]).getdata()) > > -- http://mail.python.org/mailman/listinfo/python-list
converting file formats to txt
Hi All, Am looking for a python script that can convert fileformats to txt format. Am unable to find anything in python. Currently the InfoCon projects looks pretty good to use, but it is return in java. Thanks and Regards, Gaurav Agarwal -- http://mail.python.org/mailman/listinfo/python-list
converting file formats to txt
Hi All, Am looking for a python script that can convert fileformats to txt format. Am unable to find anything in python. Currently the InfoCon projects looks pretty good to use, but it is return in java. Thanks and Regards, Gaurav Agarwal -- http://mail.python.org/mailman/listinfo/python-list