IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-04-02 18:00:08
Channels: 41
Logged Lines: 6229042
Size: 1810.00 MB
Powered by
Channel Info
Network: freenodeChannel: #python |
Search in www.irclog.org
Log from #python at freenode 2006-05-20
[04:00]<gnwsxrd>anyone know how to take a win32 file handle and hook it up to sys.stdout?
[04:02]<vgzzvjzg>newsham: you mean you want things written to sys.stdout to go to the handle?
[04:04]<gnwsxrd>yah. see, I called AllocConsole to create a new console window but it isnt hooked up to sys.std{in,out,err} (I guess those were initialized previously)
[04:04]<gnwsxrd>and I would like to direct stdio to the new console
[04:04]<gnwsxrd>i can GetStdHandle(STD_OUTPUT_HANDLE).WriteConsole('test') and that gets displayed in the new window
[04:05]<gnwsxrd>i would like to attach that handle to sys.stdout, but I need to make it a file() first somehow.
[04:05]<zzz2jg>newsham, you could just make a wrapper class
[04:05]<vgzzvjzg>yeah write a file-like class that does WriteConsole() in its write() method
[04:05]<gnwsxrd>true, but surely there's a way to go from a file handle to a file()
[04:06]<gnwsxrd>i mean, internally thats what sys.stdin is already.
[04:06]<zzz2jg>hm
[04:06]<zzz2jg>you're right
[04:06]<gnwsxrd>the moral equivalent of os.fdopen for unix?
[04:06]<zzz2jg>>>> type(sys.stdin)
[04:06]<zzz2jg> <type 'file'>
[04:06]<zzz2jg>i mean, you're literally right
[04:07]<zzz2jg>you should just be able to do "sys.stdin = whatever", presuming whatever is a file
[04:07]<gnwsxrd>yes, so I need to make a file() out of a file handle.
[04:07]<gnwsxrd>(which is how stdin was created during python initialization)
[04:07]<vgzzvjzg>newsham: there might be something in the python win32 extensions
[04:07]<zzz2jg>ah, hm
[04:08]<vgzzvjzg>in any case, you probably need to be using WriteConsole API
[04:08]<rxdggy>heh
[04:08]<vgzzvjzg>that isn't a normal win32 "File" API
[04:08]<rxdggy>sys.stdout = blah screws up my python shell, heh
[04:08]<gnwsxrd>tera: fine. but surely python is also using WriteConsole :)
[04:08]<vgzzvjzg>doubt it
[04:08]<gnwsxrd>for the normal sys.stdout
[04:09]<vgzzvjzg>probably just writing to the correct fd
[04:09]<vgzzvjzg>C-library style
[04:10]<vgzzvjzg>hmm
[04:10]<vgzzvjzg>well i'm not 100% sure... maybe check the python source?
[04:11]<gnwsxrd>if i could get a fileno somehow i guess i could use fdopen
[04:11]<vgzzvjzg>what's wrong w/ the wrapper idea?
[04:11]<gnwsxrd>tera: inelegant if the functionality already exists elsewhere.
[04:59]<fjffrc>DarshanaC: you can set the paths used by changing sys.path
[05:01]<dzzsxzgzc>polpak: how to change sys.path
[05:03]<jjxggdl>where is python mostly being used?
[05:05]<fjffrc><wchun> sys.path.append(path) or sys.path.insert(0, path)
[05:20]<xvzdlyznx>zenwryly: There are some cool websites written in Python using the frameworks such as django
[05:21]<xvzdlyznx>Python wiki was built using moinmoin = python.
[05:21]<gggwzdfd>XVampireX: yeah, I'm familiar with a few of the frameworks, I was just wondering which one(s) python.org is using
[05:21]<xvzdlyznx>I think Python website is built using zope
[05:21]<gggwzdfd>XVampireX: ah, cool, thanks
[05:21]<xvzdlyznx>heh
[05:22]<gggwzdfd>XVampireX: actually I finally found it
[05:22]<gggwzdfd>http://www.python.org/dev/pydotorg/website/
[05:23]<xvzdlyznx>Yeah, notice zope is required
[05:23]<xvzdlyznx>"
[05:23]<xvzdlyznx>The following packages are required:
[05:23]<xvzdlyznx>Zope Interfaces version 3.1.0.c1 (homepage):
[05:24]<gggwzdfd>XVampireX: yeah, but its just uding it for interfaces
[05:24]<gggwzdfd>XVampireX: and that's only because its a requirement for twisted
[05:24]<xvzdlyznx>I know, which is what lead me to think it was zope
[05:25]<gggwzdfd>XVampireX: it looks like the answer I was looking for is pyramid
[05:25]<gggwzdfd>http://www.python.org/dev/pydotorg/website/
[05:25]<gggwzdfd>oops
[05:25]<xvzdlyznx>Yeah
[05:25]<xvzdlyznx>pyramid
[05:25]<gggwzdfd>http://pyramid.pollenation.net/cgi-bin/trac.cgi
[05:25]<gggwzdfd>cools
[05:25]<gggwzdfd>thanks
[05:25]<gggyxpzj>Is there any printable version of the Python Library Reference?
[05:27]<mnfvr2>yes
[05:27]<mnfvr2>docs.python.org/lib/
[05:27]<mnfvr2>er
[05:27]<mnfvr2>http://docs.python.org/download.html
[05:34]<gnwsxrd>so i bit the bullet and mimicked the file interface for console objects. *sigh*
[05:34]<gnwsxrd>another thing that sucks is that it looks like com catches all exceptions, so I cant easily make it drop to pdb when an uncaught exception occurs
[05:43]<svjzdzddnz_drd>could someone help me to transform a python script into a .exe file?
[05:44]<rd2nzrj2zr>stormrider_may: google for py2exe
[05:45]<svjzdzddnz_drd>cybercobra, yeah, i already downloaded and installed it but don't know what i have to do now
[05:46]<svjzdzddnz_drd>in Lib\site-packages\py2exe
[05:46]<svjzdzddnz_drd>there are lots of file, i don't know which one i have to use
[05:46]<dzjrpzjrrd>stormrider_may: have you read the docs?
[05:46]<zxzzfns`>which jabber library is the best?
[05:48]<rd2nzrj2zr>stormrider_may: according to the docs, it will generate several files by default
[05:48]<rd2nzrj2zr>stormrider_may: all of which you'll need
[05:48]<rd2nzrj2zr>stormrider_may: or if you *really* want 1 .exe
[05:48]<svjzdzddnz_drd>ironfroggy, i was trying to read but i don't know what is distutils setup-script. Sorry asking this before spending a long time reading the docs, but i have to make this program work in less than 1 hour :/
[05:48]<rd2nzrj2zr>stormrider_may: add -b 1 to the args of py2exe
[05:49]<dzjrpzjrrd>you shouldnt have to touch anything in site-packages directly.
[05:49]<dzjrpzjrrd>py2exe is a command you use to package your scripts up with python into the exe
[05:50]<dzjrpzjrrd>so i dont see where you are confused.
[05:51]<svjzdzddnz_drd>so i enter on myscript's.py folder and do py2exe my_program_name?
[05:52]<dzjrpzjrrd>try it.
[12:54]<zzvn>But learning is why I'm doing this, so that's good.
[12:54]<wyfm_crv>heh
[13:03]<sfudrrfd>hm
[13:03]<sfudrrfd>how would i insert a DWORD into a data buffer?
[13:04]<vl77>What type of "data buffer" and what is a DWORD?
[13:12]<zjzdd>+squiggly: have you looked at the struct module yet?
[13:15]<sfudrrfd>+rorry, the documentation is confusing
[13:16]<zjzdd>+squiggly: ok, what don't you understand?
[13:17]<sfudrrfd>+what is this 'v1, v2, ...' stuff
[13:18]<zjzdd>+the values you want to pack
[13:19]<zjzdd>+struct.pack('l',1) #=> '\x01\x00\x00\x00'
[13:19]<zjzdd>+that packs the value '1' into a C long int (a 32-bit int, which may or may not be a DWORD -- i can't remember what that is)







