[Tutor] Python, CGI and CSS
Hi, I've looked all over the internet but have not found an answer to my question. How do I apply an external stylesheet to the XHTML in a Python script? I tried to include the standard """ in with the rest of the printed XHTML. But that didn't work. I changed the href attribute to "/style1.css", then to "../style1.css" and finally to "http://localhost/cgi-bin/style1.css";, all failed attempts. Just so you know, both sets of permissions for these two files have been set to 755. I tried other cgi scripts (still residing in the cgi-bin) and they did work. I checked the error log, and this is what I'm getting: (2)No such file or directory. When I took both files out of my cgi-bin, as a test, the CSS rules were implemented. I'm not sure why it stops working when located in the cgi-bin folder. Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python, CGI and CSS
Eric, I'm sorry, I never actually managed to get any stylesheets to work with my cgi scripts. The scripts that did work are just simple HTML. I'm using Apache 2.2.8 on a Mac OS X 10.4.11 system. When I get home I'll definitely look up the log file and paste it here. I'll also have to fool around with the permissions and httpd.conf file. I did look into CGI tutorials, but they didn't use Python code. They used something like: start_html(-title => $title, -head => style({type => 'text/css'} ) Thanks for the suggestions though. On 4/10/08, Eric Walstad <[EMAIL PROTECTED]> wrote: > > Hi Alex, > > On Thu, Apr 10, 2008 at 1:22 PM, Alex Krycek <[EMAIL PROTECTED]> > wrote: > > Hi, > > > > I've looked all over the internet but have not found an answer to my > > question. How do I apply an external stylesheet to the XHTML in a Python > > script? I tried to include the standard " > type='text/css' href='style1.css' />"" in with the rest of the printed > > XHTML. > > Try writing your html file by hand, tweaking the href and/or server > config and/or file permissions by hand until it *does* work. Once you > have a working reference point, then make your Python script duplicate > what you know works. > > > > > I > > tried other cgi scripts (still residing in the cgi-bin) and they did > work. > > View the HTML source of these working CGI scripts to see what the css > link tag looks like. How does it differ from the css link tag output > of your Python script? > > > > > I > > checked the error log, and this is what I'm getting: (2)No such file or > > directory. > > Paste the actual log file line here. > > > > > When I took both files out of my cgi-bin, as a test, the CSS rules were > > implemented. I'm not sure why it stops working when located in the > cgi-bin > > folder. > > It feels like a permissions problem or a configuration problem with > your web server. > > > What webserver are you using? > Have you followed any of the CGI tutorials? > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python, CGI and CSS
Thank you all for your help. I've finally figured it out. I took people's suggestions and typed in the path for the CSS file into my browser. Well, I received an internal service error. When I checked the error log, I had received the following: [Thu Apr 10 20:38:47 2008] [error] [client ::1] (8)Exec format error: exec of '/usr/local/apache2/cgi-bin/style1.css' failed If I understand this correctly, Apache was apparently trying to execute my CSS file. So I moved the CSS file into my /~username/Sites folder (I'm on a Mac), changed the href link in my Python script, and finally my CSS rules were applied to the selected XHTML. I read somewhere that it's not a good idea to have anything other than scripts in one's cgi-bin anyways. Thanks again! On Thu, Apr 10, 2008 at 3:22 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Alex Krycek wrote: > > > Eric, > > > > I'm sorry, I never actually managed to get any stylesheets to work with > > my cgi scripts. The scripts that did work are just simple HTML. > > > > Where are the css files that work located? What URL is used to fetch them? > If you put the css for your cgi into the same location and fetch with a > similar URL it should work. > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Problems sending POST data
Hello all, I've been trying to send POST data to this library database with Python's urllib, but I can't get it to work. The website is http://catalog.denverlibrary.org/cgi-bin/cw_cgi?getLimitedTerms+2307(although the session expires after a short period of time. So it's better to first go to denverlibrary.org and then navigate to the advanced search page). This is the script that I used: ### import urllib queryString = "database=10&search1=%2F%2Fw&terms1=&bool1=and&search2=%2F%2Fn&terms2=&bool2=and&search3=%2F%2Ftw%2F&terms3=nanking&bool3=and&search4=%2F%2Fsd%2F&terms4=&bool4=and&search5=%2F%2Fed%2F&terms5=&spellcheck=false&keywords1=qdvds&keywords2=--none--&datelimit=%3E&year1=&year2=&limiter_count=3&branch=&Search=Search&Available=yes" url = " http://catalog.denverlibrary.org/cgi-bin/cw_cgi?customSearchFinish+17410"; print urllib.urlopen(url, queryString).read() ### However, whenever I run the script I receive the page I was on (Advanced Search page) again. I'd like to get the page with the search results. This is what I got from livehttpheaders when I initiated a search from the website: ### http://catalog.denverlibrary.org/cgi-bin/cw_cgi?customSearchFinish+17410 POST /cgi-bin/cw_cgi?customSearchFinish+17410 HTTP/1.1 Host: catalog.denverlibrary.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://catalog.denverlibrary.org/cgi-bin/cw_cgi?getLimitedTerms+17410 Cookie: __utma=109436176.390208191.1209600128.1209671991.1209676393.6; __utmz=109436176.1209600128.1.1.utmccn=(referral)|utmcsr= catalog.denverlibrary.org|utmcct=/cgi-bin/cw_cgi|utmcmd=referral; __utma=125080728.808666458.1209606982.1209606982.1209606982.1; __utmz=125080728.1209606982.1.1.utmccn=(referral)|utmcsr=denverlibrary.org|utmcct=/catalogs/index.html|utmcmd=referral; __utmc=109436176; __utmb=109436176 Content-Type: application/x-www-form-urlencoded Content-Length: 322 database=10&search1=%2F%2Fw&terms1=&bool1=and&search2=%2F%2Fn&terms2=&bool2=and&search3=%2F%2Ftw%2F&terms3=nanking&bool3=and&search4=%2F%2Fsd%2F&terms4=&bool4=and&search5=%2F%2Fed%2F&terms5=&spellcheck=false&keywords1=qdvds&keywords2=--none--&datelimit=%3E&year1=&year2=&limiter_count=3&branch=&Search=Search&Available=yes HTTP/1.x 302 Found Date: Thu, 01 May 2008 21:13:54 GMT Server: Apache/2.2.0 (Unix) DAV/2 mod_ssl/2.2.0 OpenSSL/0.9.8b PHP/5.1.6 JRun/4.0 Location: http://catalog.denverlibrary.org:80/cgi-bin/cw_cgi?resultsScreen+17410+1+1+0 Content-Length: 260 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=iso-8859-1 ### I'd appreciate any suggestions. Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Wave module
Hello, I'm trying to join two .wav files with the wave module. But when I try to use wave.open(filename, "rb") I receive the following error: Traceback (most recent call last): File "", line 1, in File "F:\PortablePython1.0\lib\wave.py", line 483, in open return Wave_read(f) File "F:\PortablePython1.0\lib\wave.py", line 162, in __init__ self.initfp(f) File "F:\PortablePython1.0\lib\wave.py", line 143, in initfp self._read_fmt_chunk(chunk) File "F:\PortablePython1.0\lib\wave.py", line 264, in _read_fmt_chunk raise Error, 'unknown format: %r' % (wFormatTag,) wave.Error: unknown format: 85 I read somewhere that there are various wave formats, only some supported by Python. Is this true? If so, is there any way I can convert my wave files into a supported kind? Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Wave error (solved)
Per someone's suggestion I changed my wave files from 32 bit to 16 bit. I can now open (and manipulate) them without any error. I'm not sure why it worked but it worked. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Logging In To Forum
Hello, I would like to have my script log in to a vBulletin forum. My script does seem to do this (as I can check my control panel, etc.). But although I can get access to my account, the forum fails to update the date when I last visited. That date updates just fine when I do it manually through a browser. I was wondering if I was maybe messing something up with cookies. Any suggestions would be appreciated. Thanks! #!/usr/bin/python # forumlogin.py # Logs into vBulletin forum import urllib2, time import cgitb; cgitb.enable() def main(): print "Content-type: text/html\n" url = "http://forums.x10hosting.com/login.php?do=login"; queryString = "..." opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) response = opener.open(url, queryString) logfile() response.close() def logfile(): fileIn = open("../logfile.txt", "a") fileIn.write("\n") fileIn.write(time.ctime()) fileIn.close() *if* __name__ == "__main__": main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging In To Forum
Kent, I tried reading several pages with the read() function. Unfortunately nothing changed. I'll take a look at Firebug. Thanks. On Fri, Aug 1, 2008 at 1:20 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > On Fri, Aug 1, 2008 at 2:47 PM, Alex Krycek <[EMAIL PROTECTED]> > wrote: > > Hello, > > > > I would like to have my script log in to a vBulletin forum. My script > does > > seem to do this (as I can check my control panel, etc.). But although I > can > > get access to my account, the forum fails to update the date when I last > > visited. That date updates just fine when I do it manually through a > > browser. I was wondering if I was maybe messing something up with > cookies. > > Any suggestions would be appreciated. Thanks! > > You might try actually reading the response data with response.read(). > Otherwise you should look closely at the interaction with the browser; > you need to mimic that. Firebug and other browser tools can help. > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Creating simple windows in XP
Hello, I'd like to create very simple GUI's in XP. For the sake of simplicity, I'm trying to avoid downloading and installing anything (although I am considering EasyGui). To see how well it works, I've tried having my program run a Visual Basic script ( i.e. subprocess.call(someScript.vbs, shell = True) ). It seemed to work ok. I was just wondering if there was a better and/or easier way of doing this. Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating simple windows in XP
Thanks for the suggestions guys. I had looked at Tkinter before and liked that it comes w/ Python. It's just that it's so complex writing anything. EasyGui is pretty simple, but I relying on standard tools. I liked how in VB, for example, to open a dialog box you could write: MsgBox("Text", vbOKOnly, "Title"). I'll probably go with EasyGui. Thanks again. On Thu, Jan 15, 2009 at 5:33 AM, Kent Johnson wrote: > On Thu, Jan 15, 2009 at 1:29 AM, Alex Krycek > wrote: > > Hello, > > > > I'd like to create very simple GUI's in XP. For the sake of simplicity, > I'm > > trying to avoid downloading and installing anything (although I am > > considering EasyGui). To see how well it works, I've tried having my > > program run a Visual Basic script ( i.e. subprocess.call(someScript.vbs, > > shell = True) ). It seemed to work ok. I was just wondering if there was > a > > better and/or easier way of doing this. > > Tkinter is the only GUI framework that comes with Python. If EasyGUI > meets your needs, why not use it? > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor