Re: CGI templating with python
Django will probably get you where you want to go the fastest: http://www.djangoproject.com/ In particular, its admin interface will probably automatically generate a usable UI for you without your having to write many templates at all. Robert, Thank you very very much. I had a brief peruse of django last night and it does indeed look like what I am after! Will take me some time :) to delve into it deeper but I wanted to thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Developement Question?
On Apr 1, 3:34 am, Wayne infotech...@fairpoint.net wrote: My town office uses Microsoft operating system. They have a proprietary accounting system that uses excel for their accounting reports. I would like to read these report and reproduce the report so that the report can be seen on the web. I was thinking about using xlrd and xlwt along with some sort of software for building the web pages. I use linux only and do not use Microsoft. Q. Does python have to be installed on there computer to run the script? Q. Am I approaching this the wrong way? If so, what would be a better approach? Wayne, check out google group python-excel. They are very helpful there, and I believe there are threads on how to compile what you are looking for into a .exe for just such a situation (Disclaimer: I am far from an expert, so I may have misunderstood from the python-excel thread if python is/isn't required on the target machine once the .exe is built, but try that group - John Machin is very responsive) -- http://mail.python.org/mailman/listinfo/python-list
CGI templating with python
Hi there, Years ago I wrote a LAMP app using python. I find I need a simple web data entry tool to store records (stock research) and when I enter a stock ticker, to pull up all the past research I have done. I am imagining fields like ticker, date, pulldown menus for various options, long text for comments etc.. It's a very light weight application, so I was wondering if using something like Cheetah is the best way to do this? Or should I research Zope further or are there any other suggestions? Environment: - Python 2.5 (w/ MySQLdb) - MySQL 5.1 - Windows Vista Many thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: pythoncom.CoInitialize() not recognised in Eclipse
On Mar 28, 8:16 pm, Jason Scheirer jason.schei...@gmail.com wrote: On Mar 28, 7:14 pm, KB ke...@nekotaku.com wrote: Hi there, I have in the past used PythonWin to write python for COM, and switched to Eclipse. I am getting an error from the IDE saying it does not recognise CoInitialize(): import pythoncom pythoncom.CoInitialize() pythoncom.CoUninitialize() (red X next to the two bottom lines saying: Undefined variable from import: CoInitialize) If I open a PyDev/Python Console window in Eclipse, I can type the above, no errors, no problem. I tried removing my Python Interpreter and re-adding/re-building but no change. python 2.5.2 eclipse 3.5.1 pydev 1.5.0 Thanks! PyDev is probably only looking at functions/classes defined in Python source files and not ones defined in C extensions. To confirm, try typing this in the window: import _ctypes _ctypes._Pointer() If it says that _ctypes._Pointer doesn't exist, then that's obviously the problem. No problems at all with the editor recognising the above. Also note that I tried the pythoncom snippet in my OP from the IDE's python console without issue... weird. -- http://mail.python.org/mailman/listinfo/python-list
Re: pythoncom.CoInitialize() not recognised in Eclipse
On Mar 28, 10:59 pm, Dieter Verfaillie diet...@optionexplicit.be wrote: Quoting KB ke...@nekotaku.com: I am getting an error from the IDE saying it does not recognise CoInitialize(): import pythoncom pythoncom.CoInitialize() pythoncom.CoUninitialize() It works out of the box with PyDev 1.5.5.2010030420 on Eclipse 3.5.2 on Windows XP. If nothing seems to work for you, you could try adding pythoncom to the Forced Builtins tab of your Python interpreter configuration to see if it helps (restart eclipse after you've done that, sometimes changes to the symbols database don't get picked up without restarting eclipse...) Dieter, Thanks, I tried updating my PyDev and Eclipse to your versions. Still same issue. How exactly would I add pythoncom to the Forced Builtins ? I tried simply adding pythoncom to the Forced Builtin's tab but no change. Any suggestions? -- http://mail.python.org/mailman/listinfo/python-list
pythoncom.CoInitialize() not recognised in Eclipse
Hi there, I have in the past used PythonWin to write python for COM, and switched to Eclipse. I am getting an error from the IDE saying it does not recognise CoInitialize(): import pythoncom pythoncom.CoInitialize() pythoncom.CoUninitialize() (red X next to the two bottom lines saying: Undefined variable from import: CoInitialize) If I open a PyDev/Python Console window in Eclipse, I can type the above, no errors, no problem. I tried removing my Python Interpreter and re-adding/re-building but no change. python 2.5.2 eclipse 3.5.1 pydev 1.5.0 Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Utility to screenscrape sites using javascript ?
Hi there, I have a service I subscribe to that uses javascript to stream news. Ideally I would like to use python to parse the information for me. Note there is an option to take a static snapshot of the current stream but that is still done via Javascript. (I can reference the snapshot with a unique URL though, so I can pass that to a parser as long as it can resolve the javascript and get at the content) I had a quick look at Windmill but it doesn't appear to be what I am looking for. Does anyone else have any experience in screenscraping sites that utilise javascript? Can you share how you did it and perhaps some sample code if possible? Thanks a bunch! -- http://mail.python.org/mailman/listinfo/python-list
Re: Utility to screenscrape sites using javascript ?
On Sat, 30 Jan 2010 06:21:01 -0800, KB wrote: I have a service I subscribe to that uses javascript to stream news. There's a Python interface to SpiderMonkey (Mozilla's JavaScript interpreter): http://pypi.python.org/pypi/python-spidermonkey Thanks! I don't see a documentation page, but how would one use this? Would you download the HTML using urllib2/mechanize, then parse for the .js script and use spider-monkey to execute the script and the output is passed back to python? TIA. -- http://mail.python.org/mailman/listinfo/python-list
Using jython to call python procedures/methods
Hi there, I have an application that only publishes a Java API. I can use jython to access java classes, but jython currently (to the best of my knowledge) does not support numpy/scipy. Ideally I would like to have jython call a native python routine where I have the numpy/scipy procedures already written. Does anyone have any experience with this? Is it possible? I had toyed with the idea of having jython/java write the data to a file/database and then manually kick off the python process, but ideally I would like this as automated as possible. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using jython to call python procedures/methods
Hmmm, XML is an interesting angle... I'll noodle it... -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and java application
Kutlu, I already have a first born, else I would name her after you. You are brilliant. That's what it was. Kudos. For future ref for fellow boneheads like me, in Eclipse, under Project properties, Jython Class Path, Add External JAR... Thanks a million! -- http://mail.python.org/mailman/listinfo/python-list
jython and java application
Hi there, Apologies if this is on the wrong group, this is a jython question. Please redirect me to the correct group if this is in error. I have a java application that takes no arguements. When I run it, it spits out output, and finishes. I am trying to run this java application from jython 2.5.1, JRE6. I have made simple Hello World java classes be callable from a simple jython script, yet I am stumbling on the java main construct in the application. print krbtest.SimpleHistoricTutorial().main() obviously gives me an args error (expected 1, got 0) as the definition in the java application is: public static void main(String[] args) The jython code is as follows: import krbtest # was messing with this to pass a java formatted string but to no avail from java.lang import String print krbtest.SimpleHistoricTutorial().main() # Any advice greatly appreciated! Especially with how to call main() with arguments from jython. Apologies in advance again if this is the wrong group. -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and java application
Hmmm, for some reason my follow up post didn't make it. Modified jython script to: # Eclipse package name for java application import krbtest import java.lang as lang from java.lang import String from jarray import array myargs=array([],String) krbtest.SimpleHistoricTutorial().main(myargs) Now I get: Traceback (most recent call last): File test.py, line 15, in module krbtest.SimpleHistoricTutorial().main(myargs) at krbtest.SimpleHistoricTutorial.run(SimpleHistoricTutorial.java:27) at krbtest.SimpleHistoricTutorial.main(SimpleHistoricTutorial.java: 22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: com/ bloomberglp/blpapi/Session I would post the java app but its quite large, but the main defn: public static void main(String[] args) throws Exception { SimpleHistoricTutorial example = new SimpleHistoricTutorial(); example.run(); } Is pretty vanilla. I have tried making the run() a public method and call it, all to no avail. Note, the Java app works fine standalone, I just need to call it from jython. Again, any help appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Parsing a large number of parms to a print statement.
Hi, I have to pass over 150 parameters to a print statement ala: print %s text %s other text %s 150'th unique text %s % (v [0], v[1], ... v[150]) I can't use a for loop like I normally would over the list v due to the different text fragments between each var. Is there a lambda function I can use in place of '% (v[0],v[1]...v [150])' ??? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing a large number of parms to a print statement.
Excuse the top-post, but thanks to all, the tuple was the way to go. On Oct 22, 2:16 pm, KB ke...@nekotaku.com wrote: Hi, I have to pass over 150 parameters to a print statement ala: print %s text %s other text %s 150'th unique text %s % (v [0], v[1], ... v[150]) I can't use a for loop like I normally would over the list v due to the different text fragments between each var. Is there a lambda function I can use in place of '% (v[0],v[1]...v [150])' ??? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Problem with reading CSV file from URL, last record truncated.
Hi, I am trying to download from a URL, a CSV using the following: import re import urllib, urllib2, cookielib import mechanize import csv import numpy import os def return_ranking(): cj = mechanize.MSIECookieJar(delayload=True) cj.load_from_registry() # finds cookie index file from registry # set things up for cookies opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) reply = opener.open('http://ichart.finance.yahoo.com/table.csv? s=CSCOa=00b=01c=2009d=01e=2f=2010g=dignore=.csv').read() fout=open('csco.csv','wb') fout.write(reply) fout.close fin=open('csco.csv','rb') table = csv.reader(fin) fin.close for row in table: print row return_ranking() I need to use cookies etc (mechanize/urllib2) for a different, more complex URL but since it wasn't working, I went back to a simple Yahoo example (above) which I have working with urllib (not urllib2). The behaviour I am seeing is that the last record is being truncated: (sample output) ['2009-04-08', '17.29', '17.33', '16.94', '17.13', '45389100', '17.13'] ['2009-04-07', '17.20', '17.25', '16.58', '16.85', '59902600', '16.85'] ['200'] A friend said I should do the above writing out to a file and have csvreader read in the file, but as you can see, to no avail! Any help greatly appreciated! Note that urllib.urlretrieve works perfectly but I give up the ability to import cookies from my registry which is all important (AFAIK anyway mechanize requires urllib2). Any help greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with reading CSV file from URL, last record truncated.
On Aug 3, 3:54 pm, KB ke...@nekotaku.com wrote: Hi, I am trying to download from a URL, a CSV using the following: import re import urllib, urllib2, cookielib import mechanize import csv import numpy import os def return_ranking(): cj = mechanize.MSIECookieJar(delayload=True) cj.load_from_registry() # finds cookie index file from registry # set things up for cookies opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) reply = opener.open('http://ichart.finance.yahoo.com/table.csv? s=CSCOa=00b=01c=2009d=01e=2f=2010g=dignore=.csv').read() fout=open('csco.csv','wb') fout.write(reply) fout.close return_ranking() I need to use cookies etc (mechanize/urllib2) for a different, more complex URL but since it wasn't working, I went back to a simple Yahoo example (above) which I have working with urllib (not urllib2). The behaviour I am seeing is that the last record is being truncated: (sample output) ['2009-04-08', '17.29', '17.33', '16.94', '17.13', '45389100', '17.13'] ['2009-04-07', '17.20', '17.25', '16.58', '16.85', '59902600', '16.85'] ['200'] A friend said I should do the above writing out to a file and have csvreader read in the file, but as you can see, to no avail! Any help greatly appreciated! Note that urllib.urlretrieve works perfectly but I give up the ability to import cookies from my registry which is all important (AFAIK anyway mechanize requires urllib2). Any help greatly appreciated. By moving: fin=open('csco.csv','rb') table = csv.reader(fin) fin.close for row in table: print row outside of the routine and into the mainline, it works like a charm. Would like to know why though, so would love to hear any clues! -- http://mail.python.org/mailman/listinfo/python-list
Re: Use existing IE cookie
Winner, winner, chicken dinner... resolved. http://wwwsearch.sourceforge.net/mechanize/doc.html import mechanize cj = mechanize.MSIECookieJar(delayload=True) cj.load_from_registry() # finds cookie index file from registry Thanks Mr Lee! -- http://mail.python.org/mailman/listinfo/python-list
Use existing IE cookie
Hi there, Relevant versions: Python 2.5, Vista Home, IE7 I am trying to scrape a website I have browsed manually in the past, and also manually selected my options, and now want python to use my existing cookie from the manual browse when downloading data. Using: http://code.activestate.com/recipes/80443/ I have found the name of the relevant cookie, just after reading urllib2 docs, I can't see how to send or have my python instance use MY existing cookie. Using the following: *** import re import urllib2, cookielib # set things up for cookies opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) urllib2.install_opener(opener) reply = urllib2.urlopen('foo.html').read() print reply *** This does return data, just default data, not the data from the options I set up when manually browsing. My sense is that I need something in the () part of HTTPCookieProcessor() but I have no idea as to what... the docs say cookiejar but the only code examples I have found are to create a cookiejar for the existing Python session, not to use the cookies from my prior manual meanderings. Any help greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Use existing IE cookie
Using:http://code.activestate.com/recipes/80443/ Thanks for the prompt reply, Diez! Using the above I have found the name of the cookie (I did google how to use IE cookies in python and that was the best match) but it only tells me the name of the cookie, not how to use it. Any clues? TIA! -- http://mail.python.org/mailman/listinfo/python-list
Re: Use existing IE cookie
What does you full example look like, including the cookie-acquisition-stuff? Diez I ran them seperately, hoping for a clue as to what my cookiejar was. The cookie-acquisition stuff returns screener.ashx?v=151 when I search with my domain I am interested in. I have tried urllib2.HTTPCookieProcessor('screener.ashx?v=151') but that failed with attr has no cookie header. From the HTTPCookieProcessor doco, it appears that non-IE browsers have a cookie file (and example code) but from what I can tell IE uses a hidden folder. (you can set your location in IE but it appends a folder \Temporary Internet Files - From: http://docs.python.org/dev/library/cookielib.html *** This example illustrates how to open a URL using your Netscape, Mozilla, or Lynx cookies (assumes Unix/Netscape convention for location of the cookies file): import os, cookielib, urllib2 cj = cookielib.MozillaCookieJar() cj.load(os.path.join(os.environ[HOME], .netscape/cookies.txt)) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open(http://example.com/;) *** Not sure how to adapt this for IE. -- http://mail.python.org/mailman/listinfo/python-list
Re: Use existing IE cookie
On Jul 30, 9:23 am, Diez B. Roggisch de...@nospam.web.de wrote: KB wrote: What does you full example look like, including the cookie-acquisition-stuff? Diez I ran them seperately, hoping for a clue as to what my cookiejar was. The cookie-acquisition stuff returns screener.ashx?v=151 when I search with my domain I am interested in. I have tried urllib2.HTTPCookieProcessor('screener.ashx?v=151') but that failed with attr has no cookie header. From the HTTPCookieProcessor doco, it appears that non-IE browsers have a cookie file (and example code) but from what I can tell IE uses a hidden folder. (you can set your location in IE but it appends a folder \Temporary Internet Files - From:http://docs.python.org/dev/library/cookielib.html *** This example illustrates how to open a URL using your Netscape, Mozilla, or Lynx cookies (assumes Unix/Netscape convention for location of the cookies file): import os, cookielib, urllib2 cj = cookielib.MozillaCookieJar() cj.load(os.path.join(os.environ[HOME], .netscape/cookies.txt)) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) r = opener.open(http://example.com/;) *** Not sure how to adapt this for IE. You could create a file that resembles the cookies.txt - no idea how that looks, but I guess it's pretty simple. Diez- Hide quoted text - - Show quoted text - Yeah unfortunately I just tried Firefox and it uses cookies.sqlite now... more dead ends :) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to quit a Windows GUI program gracefully with Python under Cygwin?
Thanks. After I confirmed 'Alt-F4' would terminate and close a win32 application running independently, I installed 'SendKeys' module and tested with the following code under both Cygwin and Python Windows import os, SendKeys os.system('program datafile') SendKeys.SendKeys( {PAUSE 0.25} %{F4} ) What happened was that the 'program' ran correctly, but it stayed, not closing the window under Cygwin and Python Windows. So it seems to me that this does not work. One more thing: How do I control the pause time if I do not know the execution time of an application? Thanks in advance. KB -- http://mail.python.org/mailman/listinfo/python-list
Re: How to quit a Windows GUI program gracefully with Python under Cygwin?
Of course, I downloaded the source of 'SendKeys' and installed it under both Cygwin and Python Windows with $ python setup.py install although this did not help me. KB -- http://mail.python.org/mailman/listinfo/python-list
How to quit a Windows GUI program gracefully with Python under Cygwin?
Hi, I want to write a Python script that controls and automates a Windows GUI computation program. My problem is that I do not know how to quit the Windows GUI program gracefully with a command (program's or Python) in Cygwin. 'kill' or CTRL-C command in Cygwin does not finish it gracefully, meaning that some outputs do not come out normally. The only thing I know is to click 'File-Exit' menu, but this requires a manual intervention that prevents scripting. Is there a way to quit a Windows GUI program gracefully with Python under Cygwin, of course, after the program finishes normal execution? Thanks, KB -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert a string like '777' to an octal integer like 0777?
Thanks, John. But my point is how to keep the leading zero in 0777, in order to be used in os.chmod('myfile', 0777)? -- http://mail.python.org/mailman/listinfo/python-list
How to convert a string like '777' to an octal integer like 0777?
Hi, This may be a rudimentary question: How to convert a string like '777' to an octal integer like 0777, so that it can be used in os.chmod('myfile',0777)? I know the leading zero is important in os.chmod. KB -- http://mail.python.org/mailman/listinfo/python-list