From mark at microenh.com Tue Oct 14 02:48:46 2008 From: mark at microenh.com (Mark Erbaugh) Date: Mon, 13 Oct 2008 20:48:46 -0400 Subject: [CentralOH] struct module Message-ID: <1223945326.11359.7.camel@P1900> I'm trying to use the struct module to read some data that was created by saving a C++ struct. The C++ program was compiled using quad word (8 byte) alignment. According to the struct docs: Hint: to align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a repeat count of zero. For example, the format 'llh0l' specifies two pad bytes at the end, assuming longs are aligned on 4-byte boundaries. This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment. struct.calcsize('@h0f') returns 4 (2 byte short, plus padding to 4 bytes) as expected however, struct.calcsize('@h0d') also returns 4 bytes. Shouldn't it to return 8 bytes, padding the 2 byte short to 8 bytes. struct.calcsize('@d') returns 8 This is with: Python 2.4.3 (#2, Jul 31 2008, 21:56:52) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Thanks, Mark From mark at microenh.com Tue Oct 21 15:50:48 2008 From: mark at microenh.com (Mark Erbaugh) Date: Tue, 21 Oct 2008 09:50:48 -0400 Subject: [CentralOH] web.py Message-ID: <1224597048.10660.7.camel@P1900> I'm using the web server built in to web.py. In this particular application, it may be all that is needed as it is low-volume, in-house and limited use. web.py has the ability to statically serve binary files from a directory /static/. The client application expects binary files to be served from a directory /data/. Is there any way to have web.py treat requests for files from /data/ like it does for /static/? I found the code that does this (it's in httpserver.py) and modified it to work in this case, but I dislike monkeying with "library" code so I'm wondering if there is a better way? Thanks, Mark From gacsinger at gmail.com Tue Oct 21 16:01:53 2008 From: gacsinger at gmail.com (Greg Singer) Date: Tue, 21 Oct 2008 10:01:53 -0400 Subject: [CentralOH] web.py In-Reply-To: <1224597048.10660.7.camel@P1900> References: <1224597048.10660.7.camel@P1900> Message-ID: I think the only solution (besides changing httpserver.py) is something like the below, which I haven't tested but I think should work: url = ( "/data/(.*)", "StaticContent" ) class StaticContent: def GET(self, fname): try: i = open("static/" + fname) print i.read() except IOError: web.notfound() On Tue, Oct 21, 2008 at 9:50 AM, Mark Erbaugh wrote: > I'm using the web server built in to web.py. In this particular > application, it may be all that is needed as it is low-volume, in-house > and limited use. > > web.py has the ability to statically serve binary files from a > directory /static/. The client application expects binary files to be > served from a directory /data/. Is there any way to have web.py treat > requests for files from /data/ like it does for /static/? > > I found the code that does this (it's in httpserver.py) and modified it > to work in this case, but I dislike monkeying with "library" code so I'm > wondering if there is a better way? > > Thanks, > Mark > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > http://mail.python.org/mailman/listinfo/centraloh > From mark at microenh.com Tue Oct 21 16:56:04 2008 From: mark at microenh.com (Mark Erbaugh) Date: Tue, 21 Oct 2008 10:56:04 -0400 Subject: [CentralOH] web.py In-Reply-To: References: <1224597048.10660.7.camel@P1900> Message-ID: <1224600964.14399.2.camel@P1900> On Tue, 2008-10-21 at 10:01 -0400, Greg Singer wrote: > I think the only solution (besides changing httpserver.py) is > something like the below, which I haven't tested but I think should > work: > > url = ( > "/data/(.*)", "StaticContent" > ) > > class StaticContent: > def GET(self, fname): > try: > i = open("static/" + fname) > print i.read() > except IOError: > web.notfound() Greg, Thanks. I already tried that and found that the binary data was messing up the file transfer. I think binary data can be sent, but it would require building mime headers and encoding the data stream. Modifying httpserver.py was much easier. Maybe I should suggest to the developers the ability to add multiple static folders. Mark From gacsinger at gmail.com Tue Oct 21 18:28:54 2008 From: gacsinger at gmail.com (Greg Singer) Date: Tue, 21 Oct 2008 12:28:54 -0400 Subject: [CentralOH] web.py In-Reply-To: <1224600964.14399.2.camel@P1900> References: <1224597048.10660.7.camel@P1900> <1224600964.14399.2.camel@P1900> Message-ID: On Tue, Oct 21, 2008 at 10:56 AM, Mark Erbaugh wrote: > Greg, > > Thanks. I already tried that and found that the binary data was messing > up the file transfer. > > I think binary data can be sent, but it would require building mime > headers and encoding the data stream. Modifying httpserver.py was much > easier. > > Maybe I should suggest to the developers the ability to add multiple > static folders. > > Mark Mark, If you're running on Windows, you may need to open the file "rb" in order to handle binary files properly. This is something that has bit me in the past. But I agree that simply modifying the module is much easier. - Greg From catherine.devlin at gmail.com Tue Oct 21 23:45:21 2008 From: catherine.devlin at gmail.com (Catherine Devlin) Date: Tue, 21 Oct 2008 17:45:21 -0400 Subject: [CentralOH] Game Creation Club Message-ID: <6523e39a0810211445k2988e50l40a7424d2231d0af@mail.gmail.com> Hi, Python friends! Peter Dietz just alerted me to the existence of a new club: the Game Creation Club at OSU. http://gcc.accad.ohio-state.edu/ I don't know yet how much Python they use, but it must be at least some because they take part in PyWeek (the recurring Python weeklong game competition). If you're interested and near Columbus, check them out! I'm inviting them to get involved with PyOhio, too - the possibilities for game creation and/or gaming workshops at PyOhio are too cool to contemplate. 'cause geeks just wanna have fu-un, oh geeks, they wanna have that's all they really wa-a-a-ant (etc.) -- - Catherine http://catherinedevlin.blogspot.com/ *** PyCon * March 27-29, 2009 * Chicago * us.pycon.org *** From catherine.devlin at gmail.com Wed Oct 22 10:03:22 2008 From: catherine.devlin at gmail.com (Catherine Devlin) Date: Wed, 22 Oct 2008 04:03:22 -0400 Subject: [CentralOH] CodeMash abstracts due today Message-ID: <6523e39a0810220103tdf6a964t556be816475b69f0@mail.gmail.com> ... CodeMash is a pretty awesome January conference in Sandusky. The organizers are very Python-friendly and it's a fun time. I did a Python intro at CodeMash 2008 and got a great crowd. If you'd like to do a talk there, move fast - today's the day! (Sorry, this is a REALLY late reminder.) ---------- Forwarded message ---------- From: Dianne Marsh Date: Tue, Oct 21, 2008 at 9:57 AM Subject: reminder: CodeMash abstracts due by tomorrow To: undisclosed-recipients Hi all, I'm sending out a reminder to people in the community that might want to submit a talk for CodeMash, and that possibly haven't. I also included people who might *know* people that might want to submit a talk. Either way, please consider submitting. Just a reminder: CodeMash will be held January 7-9 at the Kalahari Resort (indoor water park) in Sandusky, OH. Targeting developers of all platforms and languages, CodeMash's philosophy is to "mash, not bash", bringing together people to learn more about their own languages of choice as well as about languages that they don't use. We feel that by learning more about other languages, you broaden your mind. We have submissions for Python, .NET, Java, Ruby, Erlang. F#, and Scala and we're open to more. We have many tracks to choose from, but don't feel constrained by what you see. If there's something that you feel would be a great talk, we may as well. Submit it. Last year's conference attracted over 300 developers from mainly the midwest (but some people traveled from far reaches of the country). This year, I think that we may sell out at 500! We have had a lot of submissions already, and we're thrilled to have such a great pool to choose from. That's why I'm bothering you ... to raise that bar even higher. Please submit at http://codemash.org/BeASpeaker.aspx If you do NOT receive a message box confirming your submission, let me know! If you've already submitted, I would be happy to make sure that your abstract made it into the database. Just email me and I'll check. And if you choose not to submit a talk, I hope that you will attend. Let me know if you want a reminder when registration opens. Or just check back at www.codemash.org. We're hoping to make registration live sometime next week. Dianne -- Dianne Marsh Founder/Software Consultant SRT Solutions 206 S. Fifth Ave, Suite 200 Ann Arbor, MI 48104 (734) 649-8987 -- - Catherine http://catherinedevlin.blogspot.com/ *** PyCon * March 27-29, 2009 * Chicago * us.pycon.org *** From mark at microenh.com Tue Oct 28 17:32:32 2008 From: mark at microenh.com (Mark Erbaugh) Date: Tue, 28 Oct 2008 12:32:32 -0400 Subject: [CentralOH] Idle / Ubuntu Installation Tip Message-ID: <1225211552.8704.12.camel@quad> I use Idle, the "standard" Python IDE. I know there are fancier IDE's available but Idle is "lean and mean" and I feel pretty productive with it. On a Windows platform, Idle's Help (F1) menu displays Python help from locally stored HTML files. However, under Ubuntu Linux, the Help menu displays online help from www.python.org. This has two problems for me: 1) I have a slow connection (satellite) to the Internet and have to watch the amount of data I download (daily download limits). 2) The help that is displayed is now for Python 2.6 and I just got around to upgrading to 2.5. While you can add you own custom help pages to the Help menu, I looked into getting Idle on Ubuntu working with local help files. It's not too difficult. The file idlelib.EditorWindow.py sets up the global variable, help_url. On a Linux system it looks for a file: /usr/share/doc/python-docs-2.5.2/Doc/index.html If it doesn't find this file, help_url will be set to use the online help. If you install the python-doc (not python2.5-doc package, which python-doc also installs), the needed html files are installed locally, but index.html is at: /usr/share/doc/python2.5-doc/html/index.html The solution for me was to create a new directory /usr/share/doc/python-docs-2.5.2 and in that directory create a symbolic link named Doc to /usr/share/doc/python2.5-doc/html here are the commands I used: sudo mkdir /usr/share/doc/python-docs-2.5.2 cd /usr/share/doc/python-docs-2.5.2 sudo ln -s /usr/share/doc/python2.5-doc/html Doc Since Idle's help_url is only setup at startup, you'll have to restart Idle for the change to take effect. Note: I'm currently using Python 2.5.2, change the version numbers above as appropriate for your Python version. I hope this is helpful. Criticisms and improvements are welcome. Mark