Telephony project
I'm new to Python and need to do a (low level, I think) telephony project ( POTS, all local calling) in WinXp. 1. Fetch phone number from my ASCII data. 2. Dial (always a local number) phone (through USRobotics 56K? ). 3. Ask @3 questions to called phone number. Y/N Y/N Y/N 4. Save answers to ASCII file. 5. Say 'Thanks', hang up. Repeat till eof() And...I've not seen any telephony books in/for Python. Any and all help, suggestions, directions, etc. would be *GREATLY* appreciated. TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: Telephony project
"CheckOn" is the working name for my project. Our church community has many elderly who are at home but close to assisted living placements. Many do not have family and rely on volunteer caretakers and lunch providers for their socialization. We are trying to make phone contact with these members to check on their needs, wellbeing, and ability to take care of themselves. In sharing that information with other denominations in our city, we discovered that others were having identical issues. The numbers are larger than we anticipated. Thus the project. Thanks for your interest. -- http://mail.python.org/mailman/listinfo/python-list
Re: Telephony project
Thanks for all the helpful postings! A clearer specification for my project is that the CALLER speaks directly to list_member. And enters, thru GUI checkbox(s), answering: r_u_ok?; Send chuch member to visit list_member; call Social Worker, help needed, etc. An important element is to verify that the elderly member has been called. When, and by whom. And if additional care, contact is needed. After reading replys I think I can do all Python work. I'm looking at pySerial to manage the phone calls.The s/w needs to be GUI, ez to use (elderly volunteers) and work on donated (read 'old') hardware. Thank you all for your advice, pointers, and suggestions. rm -- http://mail.python.org/mailman/listinfo/python-list
Predicting Thumbnail Sizes from PIL
I need to calculate the thumbnail sizes PILL will produce from an image. In most cases I can divide and round by adding .5, but PIL seems to round differently on odd sized images. For example, I want to reduce an 800x816 image to have a maximum size of 697. (697/816) * 800 = 683.33, so my rounding results in 683. But PIL produces an image of 684x697. Is there an easy rule that will always work -- like adding .67 instead of .5? Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and version control
Johann C. Rocholl wrote: Robert Brewer wrote: Peter Hansen wrote: Carl wrote: What is the ultimate version control tool for Python if you are working in a Windows environment? I never liked coupling the two together like that. Instead I use tools like TortoiseCVS or (now) TortoiseSVN with a Subversion repository. These things let you access revision control features from context (right-button) menus right in Windows Explorer, as you browse the file system. Seconded. Thirded. Johann Fourth-ed! Roger -- http://mail.python.org/mailman/listinfo/python-list
Is it possible to use the logging-module in a threadless environment?
I'd like to use a program (roundup) that imports the logging.config module on a machine where I could not get the thread and threading modules to compile. How dangerous is it to changing /lib/python2.4/logging/config.py to something like: import dummy_thread as thread, dummy_threading as threading Thanks in advance, Roger Erens -- http://mail.python.org/mailman/listinfo/python-list
PILGraph Upgrade or Alternative Suggestion
Anyone have an updated version of PILGraph beyond 0.1a7 or a suggestion for a light-weight alternative? By light-weight I mean something that doesn't require many/any packages other than PIL and will create plain old round pie-chart PNG graphics with titles and legends. I do need multi-platform for both Linux and Windows. The intended use is to create graphics for web pages on the fly. TIA, Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
Jay wrote: > I, too, am a hardcore fan of jEdit. It's nice to finally see some user > support on this forum. :-) The biggest problem I have with anything written in Java is the long startup time. The editor may be great but the platform is mediocre. I am a SciTE bigot. I have recently tried SPE and UliPad. UliPad would be my second choice and is still installed, but SPE was quickly removed. One feature I like about SciTE is being able to position the cursor anywhere on a word and hit CTL-F to find the NEXT occurrence. With UliPad, you have to select the entire word you want to search for, and then when you hit CTL-F -- it first finds the same occurrence you selected -- you have to hit F3 to find the next. I think SciTE is better engineered. Still, much of your choice is personal preference. I have noticed that any two people using the same editor will use different keystroke and mouse sequences when presented with similar editing problems. Good discussion - I thank the originator of the thread. Roger -- http://mail.python.org/mailman/listinfo/python-list
smtplib, gmail, quit vs. close and SSL3_GET_RECORD:wrong version number
I am having a problem sending email through smtp.gmail.com using
smtplib. Everything works and the mail is sent and received, except
quit. The following shows the problem (without bothering to login or do
the sendmail):
>>>> import smtplib
>>>> server = smtplib.SMTP('smtp.gmail.com',25)
>>>> server.ehlo()
> (250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
> 28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
>>>> server.starttls()
> (220, '2.0.0 Ready to start TLS')
>>>> server.ehlo()
> (250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
> 28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
>>>> server.noop()
> (250, '2.0.0 OK')
>>>> server.quit()
>
> Traceback (most recent call last):
> File "", line 1, in
> server.quit()
> File "c:\Python25\lib\smtplib.py", line 716, in quit
> self.docmd("quit")
> File "c:\Python25\lib\smtplib.py", line 378, in docmd
> return self.getreply()
> File "c:\Python25\lib\smtplib.py", line 352, in getreply
> line = self.file.readline()
> File "c:\Python25\lib\smtplib.py", line 160, in readline
> chr = self.sslobj.read(1)
> sslerror: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version
> number')
>>>>
I have not had this problem with other mail servers (but only tried
two). A solution for gmail seems to be to replace the server.quit()
with server.close(). The difference between the two commands is quit()
sends a 'QUIT' string before calling close(). Because close() is not
included in the smtplib docs, it does not appear to be the right solution.
What is the correct way to terminate a gmail session?
Roger
--
http://mail.python.org/mailman/listinfo/python-list
Alternatives for Extracting EXIF and JPEG Data from Images
Does anybody have a pointer to a Python library/utility that will extract the chrominance and luminance quantization tables from JPG images? I have been using the _getexif method from PIL, which works fine, but doesn't extract the quantization data. I am a bit fuzzy on the terminology, but the quantization data seems to be JPEG data rather than EXIF data. One utility that extracts the quantization tables is JPEGsnoop -- there is a link to download the utility here: http://www.impulseadventure.com/photo/jpeg-quantization.html The source code for the above isn't available and may not be callable from a Python script even if it were available. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternatives for Extracting EXIF and JPEG Data from Images
Max Erickson wrote:
> Roger <[EMAIL PROTECTED]> wrote:
>
>> Does anybody have a pointer to a Python library/utility that will
>> extract the chrominance and luminance quantization tables from
>> JPG images?
>>
>> I have been using the _getexif method from PIL, which works fine,
>> but doesn't extract the quantization data. I am a bit fuzzy on
>> the terminology, but the quantization data seems to be JPEG data
>> rather than EXIF data. One utility that extracts the
>> quantization tables is JPEGsnoop -- there is a link to download
>> the utility here:
>>http://www.impulseadventure.com/photo/jpeg-quantization.html
>>
>> The source code for the above isn't available and may not be
>> callable from a Python script even if it were available.
>>
>> Roger
>>
>
> I don't know what the format is, etc, but jpegs I open with PIL have a
> quantization attribute, e.g:
>
>>>> im.quantization
> {0: array('b', [6, 4, 4, 5, 4, 4, 6, 5, 5, 5, 6, 6, 6, 7, 9, 14, 9, 9,
> 8, 8, 9, 18, 13, 13, 10, 14, 21, 18, 22, 22, 21, 18, 20, 20, 23, 26,
> 33, 28,
>
>
>
> max
>
Thank you, I wasn't aware of the quantization method. I was unable to
find any documentation for it.
The 0: array() output would appear to be the luminance 8x8 array and the
1: array() to be the chrominance 8x8 array. A curiosity is the values
disagree with the output of the JPEGsnoop utility. For my Canon
Powershot S2 IS set to "fine", im.quantization yields (after formatting):
{0: array('b', [
1, 1, 1, 2, 1, 1, 2, 2,
2, 2, 3, 2, 2, 3, 3, 6,
4, 3, 3, 3, 3, 7, 5, 8,
4, 6, 8, 8, 10, 9, 8, 7,
11, 8, 10, 14, 13, 11, 10, 10,
12, 10, 8, 8, 11, 16, 12, 12,
13, 15, 15, 15, 15, 9, 11, 16,
17, 15, 14, 17, 13, 14, 14, 14
]),
1: array('b', [
4, 4, 4, 5, 4, 5, 9, 5,
5, 9, 15, 10, 8, 10, 15, 26,
19, 9, 9, 19, 26, 26, 26, 26,
13, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26])}
The JPEGsnoop output for the same jpg file is (pardon the line wrap):
Precision=0 bits
Destination ID=0 (Luminance)
DQT, Row #0: 1 1 1 2 3 6 8 10 AnnexRatio: 16.0
11.0 10.0 8.0 8.0 6.7 6.4 6.1
DQT, Row #1: 1 1 2 3 4 8 9 8 AnnexRatio: 12.0
12.0 7.0 6.3 6.5 7.3 6.7 6.9
DQT, Row #2: 2 2 2 3 6 8 10 8 AnnexRatio: 7.0
6.5 8.0 8.0 6.7 7.1 6.9 7.0
DQT, Row #3: 2 2 3 4 7 12 11 9 AnnexRatio: 7.0
8.5 7.3 7.3 7.3 7.3 7.3 6.9
DQT, Row #4: 3 3 8 11 10 16 15 11 AnnexRatio: 6.0
7.3 4.6 5.1 6.8 6.8 6.9 7.0
DQT, Row #5: 3 5 8 10 12 15 16 13 AnnexRatio: 8.0
7.0 6.9 6.4 6.8 6.9 7.1 7.1
DQT, Row #6: 7 10 11 12 15 17 17 14 AnnexRatio: 7.0
6.4 7.1 7.3 6.9 7.1 7.1 7.2
DQT, Row #7: 14 13 13 15 15 14 14 14 AnnexRatio: 5.1
7.1 7.3 6.5 7.5 7.1 7.4 7.1
Approx quality factor = 92.96 (scaling=14.08 variance=5.28)
Precision=0 bits
Destination ID=1 (Chrominance)
DQT, Row #0: 4 4 5 9 15 26 26 26 AnnexRatio: 4.3
4.5 4.8 5.2 6.6 3.8 3.8 3.8
DQT, Row #1: 4 4 5 10 19 26 26 26 AnnexRatio: 4.5
5.3 5.2 6.6 5.2 3.8 3.8 3.8
DQT, Row #2: 5 5 8 9 26 26 26 26 AnnexRatio: 4.8
5.2 7.0 11.0 3.8 3.8 3.8 3.8
DQT, Row #3: 9 10 9 13 26 26 26 26 AnnexRatio: 5.2
6.6 11.0 7.6 3.8 3.8 3.8 3.8
DQT, Row #4: 15 19 26 26 26 26 26 26 AnnexRatio: 6.6
5.2 3.8 3.8 3.8 3.8 3.8 3.8
DQT, Row #5: 26 26 26 26 26 26 26 26 AnnexRatio: 3.8
3.8 3.8 3.8 3.8 3.8 3.8 3.8
DQT, Row #6: 26 26 26 26 26 26 26 26 AnnexRatio: 3.8
3.8 3.8 3.8 3.8 3.8 3.8 3.8
DQT, Row #7: 26 26 26 26 26 26 26 26 AnnexRatio: 3.8
3.8 3.8 3.8 3.8 3.8 3.8 3.8
Approx quality factor = 88.24 (scaling=23.52 variance=21.42)
I don't understand the "AnnexRatio" data JPEGsnoop is adding to each
row. Anyone have an explanation on how to translate the im.quantization
values to the JPEGsnoop values? Or am I looking at two different types
of "quantization" tables?
Roger
--
http://mail.python.org/mailman/listinfo/python-list
Unbinding Tkinter default bindings for Listbox
Hi Everyone,
I have a behavior associated with a default binding with Tkinter
Listbox that I want to get rid of but I can't no matter if I return
"break" on the binding or unbind it directly. If you have a Listbox
where the bounding box is not completely revealed in the window that
holds it and you use the mouse to drag the list box, the contents of
the listbox will move in the X direction to reveal the area that's
hidden. After searching the internet for hours I found the behavior I
want to remove is a default binding as described here:
http://tcltk.free.fr/man/TkCmd/listbox.php3
"[3] If the mouse leaves the listbox window with button 1 down, the
window scrolls away from the mouse, making information visible that
used to be off-screen on the side of the mouse. The scrolling
continues until the mouse re-enters the window, the button is
released, or the end of the listbox is reached. "
After further searching I found that the code for this in tcl is
described here:
http://www.openmash.org/lxr/source/library/listbox.tcl?c=tk8.3
50 bind Listbox {
51 set tkPriv(x) %x
52 set tkPriv(y) %y
53 tkListboxMotion %W [%W index @%x,%y]
54 }
Now I've found no way to successfully unbind B1-Motion from the
listbox, as I said above. Nor return "break" on receiving the event.
I do want to eventually have my own B1-Motion binding applied to the
listbox for a different reason (with add='+' if necessary). My next
step was to see if I could just unbind B1-Motion then programmatically
delete tkListboxMotion in my code but tkListboxMotion is not available
in the Tkinter source (it's part of a compiled binary I can't reach?).
Any help would be greatly appreciated. Thanks!
Roger.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Unbinding Tkinter default bindings for Listbox
On Jan 12, 6:31 am, James Stroud wrote:
> James Stroud wrote:
> > py> b.tk.call('bind', 'Listbox', '', _)
>
> You want b.tk.call('bind', 'Listbox', '', "") of course.
>
> James
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
>
> http://www.jamesstroud.com
Knowing this is actually extremely useful (looking at Tkinter.py i see
this is equivalent to the unbind method). Unfortunately it's not
working to unbind B1-Motion from Listbox even though I get the same
output results as you've gotten above. =(
Thanks a ton James. This is still very educational to me.
Roger.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Unbinding Tkinter default bindings for Listbox
I'm sorry for harassing the list but any suggestions would be greatly appreciated. =) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unbinding Tkinter default bindings for Listbox
On Jan 12, 5:58 pm, James Stroud wrote:
> James Stroud wrote:
> > tk.tk.call('bind', str(lb), '', "break")
>
> Which is equivalent to
>
> lb.bind('', "break")
>
> But I checked and overriding the default behavior of Listbox does not
> work (tk.tk.call('bind', "Listbox", '', "break")).
>
> So I would subclass Listbox and do the bindings in the __init__:
>
> class MyListbox(Listbox):
> def __init__(self, *args, **kwargs):
> Listbox.__init__(self, *args, **kwargs)
> self.bind('', "break")
>
> James
You sir are awesome. Thank you so much. I've so far been really good
at troubleshooting Tkinter, the library has really melded with my
thinking naturally since I started using Python on a regular basis a
year ago. I had mixed feelings about asking for help on this because
I wanted so badly to figure it out myself but I became so exasperated
especially after combing through the TCL source to no affect. Now
that you've given me the correct solution it seems like the Leave
event should have been a natural binding for me to break in all my
fiddling.
Ah well, it's a lesson I won't forget thanks to you. Thanks so much
again, you're help is invaluable. =D
Roger.
--
http://mail.python.org/mailman/listinfo/python-list
Re: basic python list/dict/key question/issues..
On Jan 13, 11:59 am, "bruce" wrote:
> Hi..
>
> quite new to python, and have a couple of basic question:
>
> i have
> ("term":["1","2","3"])
>
> as i understand it, this is a list, yes/no?
>
> how can i represent this as a dict/list?
>
> i've got a few of these that i'm trying to deal with..
>
> thanks
x = {"term":["1","2","3"]} is a dictionary and the value of the key
"term" is a list.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why this code is working?
On Jan 14, 8:08 am, r wrote: > I guess where i come from > freedom is second nature so i took to python pretty quick. Wow, that's presumptive, assuming, and harsh. Not at all helpful and unnecessary. Geez... -- http://mail.python.org/mailman/listinfo/python-list
Re: is None vs. == None
> And, just for completeness, the "is" test is canonical precisely because > the interpreter guarantees there is only ever one object of type None, > so an identity test is always appropriate. Even the copy module doesn't > create copies ... > Does the interpreter guarantee the same for False and True bools? -- http://mail.python.org/mailman/listinfo/python-list
Re: is None vs. == None
> Why do you think it matters? Intellectual curiosity hence why I asked the question. It doesn't matter if I know why the sky is blue but it's interesting to know regardless. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter unbinding
I've done a lot of googling for this topic and I fear that it's not
possible. I have a widget that is overloaded with several bindings.
I want to be able to unbind one method form the same Event without
destroying all the other bindings to the same event that's associated
to the same widget.
For example:
import Tkinter
def test():
print 'test'
def test2():
print 'test2'
root = Tkinter.Tk()
funcid1 = root.bind("<1>", lambda e: test())
funcid2 = root.bind("<1>", lambda e: test2(), add='+')
root.unbind("<1>", funcid2)
root.mainloop()
When run neither <1> binding will exist against the root because the
unbind will unbind all the functions associated with that event.
However, in this example, I only want to unbind test2 not test1.
Any help is greatly appreciated. Thanks!
Roger.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
>funcid1 = root.bind("<1>", lambda e: test())
>funcid2 = root.bind("<1>", lambda e: test2(), add='+')
>root.unbind("<1>", funcid2)
Isn't this what I've done in my example code?
--
http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
On Dec 18, 11:40 am, r wrote: > Yea, my answer was really not a helping answer(sorry) just showing > exactly why this will not work with w.unbind(). Why do you need two > separate functions to bind the same event?? You cannot combine the > two?? I can't combine the two in my app unfortunately. The binding is to a custom widget that upon it being destroyed the binding is no longer valid. I can work around this by being hacky but I prefer to delete the one binding itself which would make things cleaner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
On Dec 18, 12:49 pm, r wrote: > Maybe someone will chime in with an answer, sorry i could not help. > ponder this, i must... Regardless, thanks for your help! I truly appreciate it. Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
On Dec 18, 12:49 pm, r wrote: > Maybe someone will chime in with an answer, sorry i could not help. > ponder this, i must... Regardless, thanks for your help! I truly appreciate it. Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
On Dec 18, 12:49 pm, r wrote: > Maybe someone will chime in with an answer, sorry i could not help. > ponder this, i must... Regardless, thanks for your help! I truly appreciate it. Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
On Dec 18, 12:49 pm, r wrote: > Maybe someone will chime in with an answer, sorry i could not help. > ponder this, i must... Regardless, thanks for your help! I truly appreciate it. Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
> Note that I took out the lambdas and gave event arguments to the
> functions; if you did that on purpose, because you need to call the same
> functions without events, then just ignore that...
> SO, the other workaround, which I've used, is to bind the event to a
> generic function, and have that generic function conditionally call
> the functions you want. I'll go back and try to make an example from
> your example. -Chuckk
Thanks Chuckk! You've done exactly what I did so far. I went through
the source in Tkinter.py and had an inkling of what the unbind
function was doing. I believe, and please correct me if I'm wrong,
in: self.tk.call('bind', self._w, sequence, '') , the '' is unbinding
all methods and I believe the self.deletecommand(funcid) is a
workaround for a memory leak otherwise. Perhaps self.tk.call('bind',
self._w, sequence, funcid) would work but that's a pure guess. I
would have liked to investigate the tcl source directly to see if I
could develop a workaround through a tk.call() but that was hitting a
wall in terms of any documentation I could research. I'm interested
in any workaround you may have however!
You now, I really considered going over to wxwidgets, and I definitely
want to try it after the current app I'm developing is complete, but
I've so much experience with Tkinter now after banging my head against
a wall for months (productive months mind you) on various projects,
it's like an old persnickety friend you just can't give up. =)
Thanks a ton!
Roger.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter unbinding
> either. I'd suggest a plain-python workaround along the lines of Wow. You just blew my mind. I'm going to play with this. Thanks a lot, I've really learned a lot in just that small bit. I don't have much experience in playing with a lot of the 'private' calls such as __call__. I need to do some more reading. Roger. -- http://mail.python.org/mailman/listinfo/python-list
"return" in def
Hi Everyone, First I want to thank everyone that posts to this group. I read it daily and always learn something new even if I never feel like I have anything to contribute but my questions. When I define a method I always include a return statement out of habit even if I don't return anything explicitly: def something(): # do something return Is this pythonic or excessive? Is this an unnecessary affectation that only adds clock ticks to my app and would I be better off removing "returns" where nothing is returned or is it common practice to have returns. Even when I'm not explicitly returning something I like to add "return" because it's a good additional visual marker for me to see where a method definition ends especially in cases where I may use a nested method. Thanks for the discussion! Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: "return" in def
> Curious. When I see a bare return, the first thing I think is that the > author forgot to include the return value and that it's a bug. > > The second thing I think is that maybe the function is a generator, and > so I look for a yield. If I don't see a yield, I go back to thinking > they've left out the return value, and have to spend time trying to > understand the function in order to determine whether that is the case or > not. > > In other words, even though it is perfectly valid Python, bare returns > always make the intent of the function less clear for me. I'm with Bruno > -- if you have a function with early exits, and you need to make the > intent of the function clear, explicitly return None. Otherwise, leave it > out altogether. > > -- > Steven To me this is the soundest argument. Thanks for the advice. I think I'll follow this as a rule of thumb hereafter. -- http://mail.python.org/mailman/listinfo/python-list
Re: "return" in def
On Dec 28, 5:12 pm, John Machin wrote: > On Dec 29, 7:06 am, Roger wrote: > > > > > > Curious. When I see a bare return, the first thing I think is that the > > > author forgot to include the return value and that it's a bug. > > > > The second thing I think is that maybe the function is a generator, and > > > so I look for a yield. If I don't see a yield, I go back to thinking > > > they've left out the return value, and have to spend time trying to > > > understand the function in order to determine whether that is the case or > > > not. > > > > In other words, even though it is perfectly valid Python, bare returns > > > always make the intent of the function less clear for me. I'm with Bruno > > > -- if you have a function with early exits, and you need to make the > > > intent of the function clear, explicitly return None. Otherwise, leave it > > > out altogether. > > > > -- > > > Steven > > > To me this is the soundest argument. Thanks for the advice. I think > > I'll follow this as a rule of thumb hereafter. > > Please don't. Follow MRAB's advice, with the corollary that a > generator is forced by the compiler to be a "procedure" in MRAB's > terminology. Yup, this is what I took away from this discussion. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: tkInter constraining the width only
On Dec 29, 3:23 pm, akineko wrote: > Hello everyone, > > I'm writing a Tkinter program and trying to constraint the window > size. > I want to set the minimum of the width and the height and the maximum > of the width, but not the height. You want to set the max height to 0. I know this is counter- intuitive. Both values must be a number or None, not mixed. So to do what you want to do it would be this: some_window.wm_minsize(width=min_width, height=min_height) some_window.wm_maxsize(width=max_width, height=0) Note that these numbers are in pixels if you're using .pack() and according to the docs it's in grid coordinates if you're using .grid() Good luck! Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not Ruby?
On Dec 31, 12:55Â pm, Xah Lee wrote: > Just spent 3 hours looking into Ruby today. Here's my short impression > for those interested. > Who are you? In case no one tells you, you are a cocky, egotistical windbag with opinions that border constructive but never gets there. Why would anyone care what you think? Again, who are you? Xah Lee? And? I didn't subscribe to read reviews on Ruby. And I'm pretty sure anyone that bothers to subscribe to a group about programming has the wherewithal to research a language themselves and come to their own determiniation. Also, this is a Python group and not Ruby. I knew I should have avoided this post and read the one about Nike Shoes from China. At least those bits of trolling spam don't try to mask themselves as something worthwhile. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
On Jan 5, 11:52 am, Collin D wrote:
> On Jan 5, 6:25 am, "Djames Suhanko" wrote:
>
>
>
> > Hello!
> > I'm sorry my terrible english (my native language is portuguese).
> > I has a litle program that open another window. When I close de root
> > window in quit button, I need clicking 2 times to close. is where the
> > problem?
>
> > The source:
> > 1 #!/usr/bin/env python
> > 2 from Tkinter import *
> > 3 import sys
> > 4 import random
> > 5 class App:
> > 6 def __init__(self, master):
> > 7 frame = Frame(master)
> > 8 frame.pack()
> > 9 rotulo = Label(frame, text="Clique em 'Gerar' e boa
> > sorte!",borderwidth=2,bg="gray",justify=C ENTER,relief=SUNKEN)
> > 10 rotulo.pack()
> > 11
> > 12 self.button = Button(frame, text="Sair", fg="red",
> > command=frame.quit,borderwidth=1)
> > 13 self.button.pack(side=LEFT)
> > 14 self.hi_there = Button(frame, text="Gerar Numero",
> > command=self.say_hi,borderwidth=1)
> > 15 self.hi_there.pack(side=RIGHT,padx=2,pady=2)
> > 16
> > 17 def gera_seis(self):
> > 18 a = {}
> > 19 for i in range(6):
> > 20 a[i] = "%02d" % int (random.randint(0,60))
> > 21 resultadoA = "%s-%s-%s-%s-%s-%s" %
> > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5]))
> > 22 return resultadoA
> > 23
> > 24 def say_hi(self):
> > 25 resultado = self.gera_seis()
> > 26 raiz = Tk()
> > 27 F = Frame(raiz)
> > 28 F.pack()
> > 29 hello = Label(F, text=resultado)
> > 30 hello.pack()
> > 31 F.mainloop()
> > 32
> > 33 root = Tk()
> > 34 root.title("$$$ Loteria $$$")
> > 35 app = App(root)
> > 36 root.mainloop()
>
> > --
> > Djames Suhanko
> > LinuxUser 158.760
>
> Also for style, you might want to group the import lines so they look
> like this:
>
> from Tkinter import *
> import sys, random
>
> A bit more pythonic. :P
In that case you probably want to take out the 'from' import and:
import Tkinter, sys, random
in order to avoid any namespace issues especially if you have a large
project with lots of gui manipulations. But that's just me being
pedantic. ;)
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python subprocess question
On Jan 6, 7:46 am, Duncan Booth wrote: > "Alexi Zuo" wrote: > > Hi everyone, > > > Here I have a simple program which starts a thread and the thread use > > Popen to execute a shell cmd which needs a long time. I want to stop > > the thread once I type "ctrl+C" (KeyboardInterrupt). But in fact this > > program enters a dead loop. Can anyone tell me what is wrong? > > The KeyboardInterrupt exception is being raised in your main thread which > doesn't handle it so it just terminates. Your child thread isn't marked as > a daemon thread so the program won't exit until the child thread has also > terminated. I've been recently working with threads for the first time and I've been unclear on the setDaemon flag though I've sifted through the documentation for a clear answer (most likely my reading comprehension has failed me and not the documentation). I think I had the notion of that flag backwards. .setDaemon(True) means the thread gets destroyed when the program exits and default .setDaemon(False) means that the thread continues to process even when the main program is gone? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python subprocess question
On Jan 6, 1:18 pm, [email protected] wrote: > Roger> .setDaemon(True) means the thread gets destroyed when the program > Roger> exits and default .setDaemon(False) means that the thread > Roger> continues to process even when the main program is gone? > > Approximately. The main thread (and thus the program) will exit only when > all non-daemon threads have finished. A thread can't continue to run if the > main program has exited. > > -- > Skip Montanaro - [email protected] -http://smontanaro.dyndns.org/ Gotcha. Thank you, that makes it clearer. =) -- http://mail.python.org/mailman/listinfo/python-list
Re: State of the art: Tkinter, Tk 8.5, Tix?
On Jan 7, 2:31 pm, excord80 wrote: > Does Python work with Tk 8.5? I'm manually installing my own Python > 2.6.1 (separate from my system's Python 2.5.2), and am about to > install my own Tcl/Tk 8.5 but am unsure how to make them talk to > eachother. Should I install Tk first? If I put Tk into my home > directory (under "~/opt" most likely), is there some configure option > I need to pass Python to tell it where to find my Tk? > > Also, I see that Python comes with Tix. Was Tix supposed to be > something to make up for what was lacking in Tk prior to its 8.5 > release? Is Tix here to stay, or has it been eclipsed by what comes > with Tk 8.5 OOTB? I'm curious about this too. If no one responds please let us know how it goes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where's Psyco now?
On Jan 9, 2:21 pm, "Chris Rebert" wrote: > On Fri, Jan 9, 2009 at 10:41 AM, Vicent wrote: > > Hello. This is my first message to the list. > > > In this article written in 2002 > > >http://www.ibm.com/developerworks/library/l-psyco.html > > > they talk about Psyco as a module that makes it possible to accelerate > > Python. > > > Is it still a state-of-the-art module? > > > I found it here also:http://pypi.python.org/pypi/psyco/1.6 > > > Do you think it's useful, or it depends...? > > Its present homepage ishttp://psyco.sourceforge.net/, and yes, it is > still useful and fairly current. > However, it should be used judiciously; only bother with it if you're > having a performance problem and would otherwise be tempted to rewrite > the algorithm in C. Don't casually use it as an all-purpose > accelerator, as that's not what it was built for. > > Cheers, > Chris > > -- > Follow the path of the Iguana...http://rebertia.com If that's the case where's the point of diminishing returns on using psyco? Why would it not be useful in a general setting? -- http://mail.python.org/mailman/listinfo/python-list
I wander which is better? JSP or Python? And is there a place for JSP?
As I plan to study JSP, I find it extremly complicated and a part of J2EE. I did not attend to get the whole of J2EE. I hope anybody can describe the future of JSP. Is there a place for JSP? -- http://mail.python.org/mailman/listinfo/python-list
How To Use Python/GDAL to create a KML file from an Image?
Hi All, I'd have a contour image file, in either svg, gif or png format. I know the GPS coordinates for the four corners of the image. I'd like to create a KML file from that image. I will view the KML file in Google Earth or ARCGIS. I understand that GDAL can do this, and I saw a tutorial for GDAL2TILES. But I would like to do this function within Python. As I am using Python to create the contour from a countour2d function. Any suggestions on how to Georeference an image in Python? ( to turn an image file into a KML file that can be opened by Google Earth). Are there example Python scripts of how to do it somewhere? Any ideas appreciated! Cheers Roger Zimmerman -- http://mail.python.org/mailman/listinfo/python-list
Re: An ODBC interface for Python 3?
kozmikyak wrote: > Does anyone here have a Python 3 environment that can access MSSQL > using SQLAlchemy, running on a Windows 7 box? If so, I would like > some assistance making it happen. > > The last post on this was mid-2010. It was mentioned that pyodbc had > a Python 3 branch. I've been unable to get it compiled and working on > Windows 7 32-bit or 64-bit, even after applying patches mentioned in > one of the project's tracking issues. > > Right now anyone forced to support Windows clients, Microsoft SQL, and > SQLAlchemy has no option if wanting to use Python 3.2. Neither > pymssql or pyodbc compiles out-of-the-box for Python 3.2. ceODBC > compiles and runs, but SQLAlchemy project has stated that it has no > desire to write yet another dialect supporting ceODBC for MSSQL. > > I'm not mentioning this just to complain; I'm just stating it out in > the open so that it's known. Indeed, even if one doesn't want to use > MSSQL, the only free ODBC interface I know of that works on Python 3 > is ceODBC, and it is not supported by other modules such as > SQLAlchemy. > > I'm wondering how I could best make something like this happen. I've > written to the SQLAlchemy and pyodbc projects. I have average Python > programming skills and have a Windows Python environment with C > compiler installed; perhaps if the authors respond I can assist. > > If someone else has already figured out how to make this happen, > please let me know. Pywin32 has an odbc module that works with Python 3.2. Roger -- http://mail.python.org/mailman/listinfo/python-list
Is it possible to execute Python code from C++ without writing to a file?
I'm a Python newbie who's been given a task requiring calls of Python code from a C++ program. I've tried various tutorials and dug into The Python/C API doc and the Extending and Embedding Python doc, but I haven't been able to answer this question: Is it possible in a C++ program to generate Python code, execute it, and get output back (say a tuple of 10 or so items) without doing any file i/o? Clearly it works to write the generated Python to a file and then use PyImport_Import and PyObject_CallObject to call a function returning the output tuple. But it seems like it should be possible to do this without writing the Python code to a file. I tried PyRun_String, but I can't see how it can be used to return a tuple (the Py_file_input option always returns None). Any help will be greatly appreciated. Roger House Software Developer -- http://mail.python.org/mailman/listinfo/python-list
Pickling over a socket
Hi,
I'm trying to understand how to pickle Python objects over a TCP
socket.
In the example below (based on code from Foundations of Python Network
Programming), a client creates a dictionary (lines 34-38) and uses
pickle.dump at line 42 to write the pickled object using file handle
make from a socket. The server de-pickles with pickle.load (line 24),
again using a file handle made from a socket.
When I run the program, the following output is produced:
Listening at ('127.0.0.1', 1060)
Accepted connection from ('127.0.0.1', 49938)
Traceback (most recent call last):
File "pickles.py", line 24, in
d = pickle.load( s_fh )
File "/usr/local/lib/python2.7/pickle.py", line 1378, in load
return Unpickler(file).load()
File "/usr/local/lib/python2.7/pickle.py", line 857, in load
key = read(1)
File "/usr/local/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
socket.error: [Errno 107] Transport endpoint is not connected
I'm at a loss, can anyone provide any guidance?
Thanks,
Roger Alexander
1 import pickle
2 import socket, sys
3
4 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
5
6 HOST = sys.argv.pop() if len(sys.argv) == 3 else '127.0.0.1'
7 PORT = 1060
8
9 if sys.argv[1:] == ['server']:
10
11 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
12 s.bind((HOST, PORT))
13 s.listen(1)
14
15 print 'Listening at', s.getsockname()
16
17 sc, sockname = s.accept()
18
19 print 'Accepted connection from', sockname
20
21 sc.shutdown(socket.SHUT_WR)
22 sf = s.makefile( "rb" )
23
24 d = pickle.load(sf)
25
26 sc.close()
27 s.close()
28
29 elif sys.argv[1:] == ['client']:
30
31 s.connect((HOST, PORT))
32 s.shutdown(socket.SHUT_RD)
33
34 d = dict()
35
36 d[ 'Name' ] = 'Jake Thompson.'
37 d[ 'Age' ] = 25
38 d[ 'Location' ] = 'Washington, D.C.'
39
40 sf = s.makefile( "wb" )
41
42 pickle.dump( d, sf, pickle.HIGHEST_PROTOCOL )
43
44 s.close()
45
46 else:
47 print >>sys.stderr, 'usage: streamer.py server|client [host]'
--
http://mail.python.org/mailman/listinfo/python-list
Re: Pickling over a socket
Thanks everybody, got it working. I appreciate the help! Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess considered harmfull?
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Steven Bethard wrote: > >> > Using the following snippet: >> > p = >> > subprocess.Popen(nmake,stderr=subprocess.PIPE,stdout=subprocess.PIPE, \ >> >universal_newlines=True, bufsize=1) >> > os.sys.stdout.writelines(p.stdout) >> > os.sys.stdout.writelines(p.stderr) >> > Works fine on the command line, but fails when called from within >> > Visual Studio, with the following error: >> > File "C:\Python24\lib\subprocess.py", line 549, in __init__ >> > (p2cread, p2cwrite, >> > File "C:\Python24\lib\subprocess.py", line 609, in _get_handles >> > p2cread = self._make_inheritable(p2cread) >> > File "C:\Python24\lib\subprocess.py", line 650, in _make_inheritable >> > DUPLICATE_SAME_ACCESS) >> > TypeError: an integer is required >> >> This looks like these known bugs: >> http://python.org/sf/1124861 >> http://python.org/sf/1126208 >> >> Try setting stderr to subprocess.PIPE. I think that was what worked for >> me. (You might also try setting shell=True. That's what I currently >> have in my code that didn't work before.) > > if someone wants to investigate, is seeing this problem, and have the win32 > extensions on their machine, try changing this line in subprocess.py: > >if 0: # <-- change this to use pywin32 instead of the _subprocess driver > > to: > >if 1: # <-- change this to use _subprocess instead of the pywin32 driver > > and see if it either fixes the problem (not very likely) or gives you a better > error message (very likely). > > > The error msg is only slightly better: error: (6, 'DuplicateHandle', 'The handle is invalid.') Basically, gui apps like VS don't have a console, so GetStdHandle returns 0. _subprocess.GetStdHandle returns None if the handle is 0, which gives the original error. Pywin32 just returns the 0, so the process gets one step further but still hits the above error. Subprocess.py should probably check the result of GetStdHandle for None (or 0) and throw a readable error that says something like "No standard handle available, you must specify one" Roger == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess considered harmfull?
"Uri Nix" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Roger Upole wrote: >> "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> > Steven Bethard wrote: >> > >> >> > Using the following snippet: >> >> > p = >> >> > subprocess.Popen(nmake,stderr=subprocess.PIPE,stdout=subprocess.PIPE, \ >> >> >universal_newlines=True, bufsize=1) >> >> > os.sys.stdout.writelines(p.stdout) >> >> > os.sys.stdout.writelines(p.stderr) >> >> > Works fine on the command line, but fails when called from within >> >> > Visual Studio, with the following error: >> >> > File "C:\Python24\lib\subprocess.py", line 549, in __init__ >> >> > (p2cread, p2cwrite, >> >> > File "C:\Python24\lib\subprocess.py", line 609, in _get_handles >> >> > p2cread = self._make_inheritable(p2cread) >> >> > File "C:\Python24\lib\subprocess.py", line 650, in _make_inheritable >> >> > DUPLICATE_SAME_ACCESS) >> >> > TypeError: an integer is required >> >> >> >> This looks like these known bugs: >> >> http://python.org/sf/1124861 >> >> http://python.org/sf/1126208 >> >> >> >> Try setting stderr to subprocess.PIPE. I think that was what worked for >> >> me. (You might also try setting shell=True. That's what I currently >> >> have in my code that didn't work before.) >> > >> > if someone wants to investigate, is seeing this problem, and have the win32 >> > extensions on their machine, try changing this line in subprocess.py: >> > >> >if 0: # <-- change this to use pywin32 instead of the _subprocess driver >> > >> > to: >> > >> >if 1: # <-- change this to use _subprocess instead of the pywin32 driver >> > >> > and see if it either fixes the problem (not very likely) or gives you a >> > better >> > error message (very likely). >> > >> > >> > >> >> The error msg is only slightly better: >> >> error: (6, 'DuplicateHandle', 'The handle is invalid.') >> >> Basically, gui apps like VS don't have a console, so >> GetStdHandle returns 0. _subprocess.GetStdHandle >> returns None if the handle is 0, which gives the original >> error. Pywin32 just returns the 0, so the process gets >> one step further but still hits the above error. >> >> Subprocess.py should probably check the >> result of GetStdHandle for None (or 0) >> and throw a readable error that says something like >> "No standard handle available, you must specify one" >> >> Roger >> >> >> >> >> == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet >> News== >> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ >> Newsgroups >> = East and West-Coast Server Farms - Total Privacy via Encryption = > > I gathered as much about why this happens in VS. A further question is > why does n't os.popen fall in the same trap? > > Cheers, > Uri > >From a quick glance at the source, it looks like it always creates new pipes. Roger == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Font management under win32
Here's an example of how to use EnumFontFamilies:
import win32gui
hdc=win32gui.CreateDC('DISPLAY','Display',None)
fonts=[]
def callback(font, tm, fonttype, fonts):
fonts.append(font)
print font.lfFaceName
return True
win32gui.EnumFontFamilies(hdc, None, callback, fonts)
The parameters to the callback need to be documented.
I had to look at the source to figure out what to expect.
hth
Roger
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python script to install network printers
You can use win32print.AddPrinterConnection(r'\\server\sharedprinter'). However, if the printer driver has to be copied to the client machine and installed, that's probably where most of the time is spent. hth Roger "Matt Chan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I am trying to create a python script to install a set of network printers. I have had success using an os.popen statement, using rundll32 and printui.dll. This takes way too long. Can someone point me in a quicker direction? thanks, Matt == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating internet shortcuts
Pythoncom doesn't directly support the necessary interfaces,
but you can use the Shell COM interfaces to create them.
import win32com.client
wsh=win32com.client.gencache.EnsureDispatch('wscript.shell')
s=wsh.CreateShortcut('c:\\python.url')
s.TargetPath='www.python.org'
s.Save()
hth
Roger
"Richard Townsend" wrote:
> I've seen the python.faqts page:
> http://www.faqts.com/knowledge_base/view.phtml/aid/4475/fid/538 on how to
> create windows shortcuts using Python.
>
> Does anyone know if this be adapted to create internet shortcuts on
> windows? (as used for Favorites).
>
> Thank you,
>
> --
> Richard
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: win32com, generating the cache programaticaly?
"Andrew Markebo" wrote: > > Hello! > > I am messing around with communicating between LabVIEW and Python, got > it to work by a small 'fix' (grabbing the generated file, and > importing it by hand) > > What I might want to do, is to automatically generate the data done by > executing makepy.py and run by it. > > What I select in makepy.py is a library "LabVIEW data 7.1", I would > like to do this from my program. Any hints? > > Then, is it possible making this on a minor mode, basically I have > only to dig out the CLSID of "LabVIEW data 7.1" and put it into the > generated file.. sort of?? > You can use win32com.client.gencache.EnsureDispatch to automatically generate the makepy file for an object's library when the object is created. Use the bForDemand option to only generate the code for objects as needed. Roger == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: odbc errors
[EMAIL PROTECTED] wrote:
> hi
>
> i have a piece of code:
> ...
>
> def connectdb(sql):
>import dbi
>import odbc
>import sys
>try:
>s = odbc.odbc('DSN=CONN;UID=user;PWD=pass')
>cur = s.cursor()
> # cur.execute("set nocount on")
>cur.execute(sql)
>while 1:
>rec = cur.fetchone()
>if not rec: break
>return rec
>except:
>print 'error while processing ', sys.exc_type,sys.exc_value
>s.close()
>cur.close()
>s = None
>cur = None
>
> ...
> sql = r'update table set col = 'A' where user = "user1"'
> connectdb(sql)
>
>
> when i execute it from CGI, i encounter the following :
> error while processing dbi.internal-error [MERANT][ODBC Sybase ASE
> driver]Invalid cursor state. in FETCH None
>
> but when i did check the table, the value of col is updated to 'A',
> how can i suppress the above error message? or is there some other
> things
> that are wrong with the code.
> thanks
>
The update is performed as soon as you execute the cursor.
No recordset is returned from the update, so you can remove
the fetch altogether.
hth
Roger
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: pushing python to multiple windows machines
<[EMAIL PROTECTED]> wrote:
>I am working on a project that requires python to be installed on a
> large number of windows servers and was wondering if anyone has found a
> method to do this. I found the article from 2003, but nobody ever
> stated that they have found an option for this.
>
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/f42f0813bc271995?tvc=1&q=%22Pushing+Python+to+Windows+workstations%22
>
> -shawn
>
You can use WMI to install an Msi installer on a remote machine.
The Win32_Product class has an Install method:
import win32com.client
wmi=win32com.client.gencache.EnsureDispatch('wbemscripting.swbemlocator',0)
s=wmi.ConnectServer('servername')
p=s.Get('win32_product')
inparams=p.Methods_('Install').InParameters
inparams.Properties_('PackageLocation').Value=r'\\someserver\someshare\python-2.4.2.msi'
inparams.Properties_('AllUsers').Value=True
outparams=p.ExecMethod_('Install',inparams)
print outparams.Properties_('ReturnValue') ## zero on success
Roger
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to add thumbnails to Explorer
As you guessed, the icon locations are stored in the registry.
There's a key under HKEY_CLASSES_ROOT for each
registered file type, with a default value holding the class name.
Under the class name, there's a DefaultIcon key that gives
the path to the icon. Using python files an an example, you
have HKCR\.py with Default=Python.File, and under
HKCR\Python.File\DefaultIcon, you should have the
path to py.ico. You can use the _winreg module to create
your own entries.
hth
Roger
"c d saunter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Greetings All,
> In Widows Explorer there is a thumbnail view, where you see images as
> thumbnails.
> Applications such as MS Office and OpenOffice, when installed, cause their
> respective filetypes
> to be previewed as thumbnails as well.
>
> Thumbnails are stored in the Thumbs.db hidden file.
>
> There my knowledge ends. I'm asuming that aplications install registry keys
> somewhere that
> register an invocation that returns a thumbnail for a given file bit this is
> just a guess.
>
> What I'd like to do is write some Python script that can be invoked to add
> thumbnails for
> certian file types (my own custom types and things like the .FITS array
> format.)
>
> Googling isn't going anywhere so I am hoping there are some wizards out there
> with poiters...
>
> Specifically any information on how the thumbnail system works would be great!
>
> Cheers,
> Chris
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: Small utility program for the windows
It works fine for me (XP, Python 2.4.2). Where exactly do you get the access denied ? When writing to the registry, or trying to start python, or within the python code ? Roger "Iyer, Prasad C" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I am trying to create a small utility program which would be configured in registry. Something like this Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\ShortCut\command] @="\"python C:\\workspace\\python\\Tut\\ShortCut.py\"" It gives me access denied exception when I try it. Can anyone help me out. Following is the code from Tkinter import * import sys class BaseClass(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid() self.createWidget() def createWidget(self): self.text=Text(self, width=20, height=3) self.text.grid(row=0,column=0) Button(self, text="ok", command=self.addText).grid(row=1, column=0) def addText(self): print "hello world" baseClass=BaseClass() print sys.argv[0] for i in range(0, len(sys.argv)): print sys.argv[i] baseClass.mainloop() I have to modify the code further so that it takes argument. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to add thumbnails to Explorer
Sorry, I didn't realize you meant per-file.
However, Pythoncom supports both the interfaces
(IExtractIcon and IPersistFile) specified on the page
you referenced, so you ought to be able to implement
an icon handler with the Pywin32 extensions.
Roger
"c d saunter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi Roger,
>Thanks for the info - I was actually interested in custom
> per file thumbnails rather than icons, but your message sentt me
> pouring through seemingly relevent parts of the registry - however
> what I need isn't there.
>
> Turns out I need to use a .dll shell extension as per
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
> shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/
> extensionhandlers/shell_ext.asp
>
> Not so simple, and not (directly) a job for Python.
>
> Thanks,
>Chris
> Roger Upole ([EMAIL PROTECTED]) wrote:
> : As you guessed, the icon locations are stored in the registry.
> : There's a key under HKEY_CLASSES_ROOT for each
> : registered file type, with a default value holding the class name.
> : Under the class name, there's a DefaultIcon key that gives
> : the path to the icon. Using python files an an example, you
> : have HKCR\.py with Default=Python.File, and under
> : HKCR\Python.File\DefaultIcon, you should have the
> : path to py.ico. You can use the _winreg module to create
> : your own entries.
>
> : hth
> : Roger
>
>
>
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to add thumbnails to Explorer
Not sure how ctypes works, but with Pywin32 Pythoncom24.dll is actually registered as the shell extension dll, and it passes calls to methods of a Python class you create that implements the interface methods. Roger "c d saunter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > John J. Lee ([EMAIL PROTECTED]) wrote: > > : "Roger Upole" <[EMAIL PROTECTED]> writes: > > : Or, if not, then you can do it with module ctypes. > > : http://starship.python.net/crew/theller/ctypes/ > > : There's an O'Reilly book called something like "win32 shell > : programming" that covers this stuff. > > : John > > Roger & John - thanks for the info. Unless I'm wrong (a distinct > posibility) this isn't an option, as all though COM is used as the > interface, it is used to talk to *in process* code loaded from a DLL - so > Python can only be used if the interpreter is invoked from within a custom > shell extension .dll, which is probably not the best idea for various > reasons. > > Thanks, > Chris == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: putting an Icon in "My Computer"
There's an example of how to add an item to the shell namespace in the Pywin32 demos: \win32comext\shell\demos\servers\shell_view.py hth Roger "yaipa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > All, > > I've been asked by my boss to put an Icon in WinXP's "My Computer" for > a utility we use around the shop. My tool of choice is of course > Python and therefore what I am using to attempt my given task. I have > no trouble putting Icons in the WinXP Toolbar using Python, but have > totally failed to get an Icon to appear in My Computer. Any Idea on > why and maybe how to get around this using Python? > > Thanks, > > Alan > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: NTFS reparse points
You should be able to use win32file.DeviceIoControl with winioctlcon.FSCTL_SET_REPARSE_POINT to do this. (winioctlcon was added in build 205) The hard part is going to be constructing the REPARSE_GUID_DATA_BUFFER struct to pass in as the buffer. hth Roger "Stanislaw Findeisen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to create a reparse point on NTFS (any). > > Here > (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/reparse_points.asp) > I read: "reparse points > are used to implement NTFS file system links". Here > (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/hard_links_and_junctions.asp) > I read: "Soft links > are implemented through reparse points". > > However I can't see FILE_ATTRIBUTE_REPARSE_POINT turned on in any file / > directory shortcuts I create. In fact the only > attribute set in shortcuts created using Windows Explorer is > FILE_ATTRIBUTE_ARCHIVE. (I am using GetFileAttributes() to > examine this.) > > The questions are: > > (1) Why is that so? > (2) Does anybody have any idea (sample code?) on how to create a reparse > point (the simpler, the better) using Python? > > I am using Windows 2000 Professional, Python 2.4 and Mark Hammond's Python > for Windows Extensions build 204. > > Thank you. > > +---+ > | When replying, please replace "my_initials" in the| > | From: address field with my initials - that is, "SF". | > +---+ > > -- > http://www.nglogic.com > Enter through the narrow gate! (Mt 7:13-14) == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: PyFLTK - an underrated gem for GUI projects
"aum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > To me, wxPython is like a 12-cylinder Hummer, with fuzzy dice hanging > from the mirror, fridge and microwave in the back, and DVD consoles on > every seat, towing a campervan - absolute power and luxury, giving 8mpg > if you're lucky. A word of support for wxPython: - It comes with a nice demo app that shows every single supported widget and editable code for playing with them so you can tweak to try new things. - It supports printing, drag and drop and various similar niceties on each platform. - Mac is a first class citizen (support isn't perfect but it is better than "good enough"). The FLTK docs mention Mac a few times but usually just Unix and Windows. - It fully supports Unicode. (It looks like the under development FLTK 2.0 uses UTF-8 in some places but doesn't look like this release is imminent.) - There is a half decent HTML widget. (The FLTK one is only a quarter decent :-) - You get the native look and feel on each platform and native widgets are used wherever possible. (I can't tell what FLTK does). - Various other corner things are covered as needed by more complex apps such as audio, ActiveX on Windows, stock icons, online help, calendar controls, directory and file selectors, a grid/table etc etc As is usually the case, each developer only uses 10% of the functionality of the toolkit available, but it is a different 10% for each! My 10% includes printing and drag and drop which are missing from most of the toolkits you listed. I also insist on native widgets wherever possible. It is possible to make the wxPython smaller by having more DLLs each with fewer widgets in it. That way you will only suck in the ones you use. I do like that FLTK has the documentation style as PHP where users can add comments to each page. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Distributed Cache Server?
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does anyone know if a "distributed caching system" has been developed > for use with Python? BitTorrent :-) > Yes, "distributed caching system" is a bit of a general term, but am > really just talking about something as simple as key + value (arbitrary > class) which can be split over a number of machines in an efficient > manner. You'll need to define what the sweet spot is that you are aiming for. Are we talking tens of thousands of keys or billions? How big is the data (megabytes, gigabytes, terabytes?) Do you need transactional integrity (eg when are updates seen by other readers)? Do you want redundancy (data duplicated on multiple machines)? How many machines are we talking about? Should failure be automatically detected? Is there a need for security or treating the machines as untrusted? Roger -- http://mail.python.org/mailman/listinfo/python-list
AJAX => APAX? Or: is there support for python in browsers?
Hello, I remember that the first time I read about Python as a programming language was when reading the W3C's HTML 4.01 specification a few years ago. In the section on objects, images and applets (http://www.w3.org/TR/html401/struct/objects.html) an example was given like http://www.miamachina.it/analogclock.py";> This user agent cannot render Python applications. It's also in the XHTML2.0 specification. Now, is this just a theoretical example? Or is there a browser that _does_ support python scripts? Or do we have to place our bets on the Mozilla 1.9 milestone with hard work being done by Mark Hammond? I'm asking because of all the AJAX hype going on. I'd like rather not delve too deep into JavaScript and use Python instead. Any insights to be shared? Cheers, Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem printing in Win98
According to MSDN, err code 31 from ShellExecute is SE_ERR_NOASSOC,
meaning there's not an application registered for printing that file type.
Roger
"Maravilloso" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi
>
> I'm trying to automatically send a postscript file to be printed to the
> default printer in a Win98 PC, by means of using the instrucction:
>
> win32api.ShellExecute (0, "print", "file.ps", None, ".", 0)
>
> but it raises an exception with the message:
>
> error: (31, 'ShellExecute', 'A device attached to the system is not
> functioning.')
>
>
> Curiously, that instruction does works on Win2K/XP, but trying to use
> this shortcut for easy printing in Win98 provokes such error. I've
> tried in different machines (all of them running with Win98) and I
> obtain the same output.
>
> Does anybody knows what happens with Win98 printing automation?
> Any idea?
>
> Thanks in advance
>
== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: extract python install info from registry
"rbt" <[EMAIL PROTECTED]> wrote: > On windows xp, is there an easy way to extract the information that Python > added to the registry as it was installed? You should be able to find all the entries in msi.py that's used to build the installer. Roger == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Recent infoworld column
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dwarf Electrician wrote: >> from a long time listener... >> >> http://www.infoworld.com/article/04/12/30/01OPstrategic_1.html > > Kudos for Roger Binns! It is a very nice article :-) BitPim like many other projects is an effort by several people, but what John did was entirely my code. And of course that code wouldn't be possible without the various components I had available to me which including Python and wxPython as well as several others. http://bitpim.org/testhelp/credits.htm http://bitpim.org/testhelp/3rdparty.htm You may also find a talk I gave at baypiggies in July 2004 of interest. http://bitpim.org/papers/baypiggies/ It covers the various issues in doing a "real world" Python application, including packaging them up so they are indistinguishable from native applications, accessing serial ports, USB and SWIG, threading, the GUIs available and why I picked wxPython, Outlook and Evolution integration, dealing with an undocumented binary protocol, user and programmer documentation, secure remote access etc. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: PyChecker messages
> runner.py:878: Function (main) has too many lines (201) > > What does this mean? Cannot functions be large? Or is it simply an advice that > functions should be small and simple? It is advice. > runner.py:200: Function (detectMimeType) has too many returns (11) > > The function is simply a long "else-if" clause, branching out to different > return statements. What's wrong? It's simply a "probably ugly code" advice? That is also advice. Generally you use a dict of functions, or some other structure to lookup what you want to do. > _must_ take two arguments; is there any way that I can make 'frame' go away? Yes, you can name it just _ (underscore). There are a few other names like that that are ignored. (Check the doc). > Also, another newbie question: How does one make a string stretch over several > lines in the source code? Is this the proper way? > > print "asda asda asda asda asda asda " \ > "asda asda asda asda asda asda " \ > "asda asda asda asda asda asda" Depends what you are trying to achieve. Look at triple quoting as well. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: there's a socket.sendall(), so why no socket.recvall()?
>>>> there's a socket.sendall(), so why no socket.recvall()? BTW socket.sendall() doesn't actually work for large amounts of data on Windows 2000 and probably other versions of Windows as well. Eg if you supply a 1MB buffer then you get an exception based on some internal Windows error code. I haven't experimented on Unix yet to see if it has the same issue. The workaround is to write a wrapper that really does send everything. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] iCalendar package 0.9
"Max M" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > http://www.mxm.dk/products/public/ical/ > > Any feedback would be welcome. How well do you cope with the crud that real programs generate? Does it work with the different dialects uses out there? Can it at least identify them? The reason why I ask is this would be useful for BitPim. When I wrote the code for doing vCards, I soon found that there wasn't actually a single program out there on Windows, Linux or Mac that actually generated 100% standards conformant vCards. They generally complied with the spirit, but screwed up character encoding, misspelled fields names, didn't do the right thing when commas and semi-colons were present in values etc. I assume the thing happens with ical. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Window capture using WM_PRINT and Python
Do you get any kind of traceback when you start a process that way?
There's not much info to go on.
Sys.argv parameters are passed as strings. You'll need to do an int() on
them
before you can use them as handles. Also, not all handles are portable
between processes. Your device context handle might not be valid
even if you make it an int.
hth
Roger
"arN" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi !
>
> I'm a Java developper and I wish to make a capture of an offscreen window
> (on WinXP). It's not possible in Java, so I use a python script and
> WM_PRINT, but it doesn't seem to work.
>
> Could someone have a look at my script and give me any advise ?
>
> TIA
>
> --
> Arnaud
> my python script : python snap.py GraphicalContext_handle image_handle
> --
> snap.py :
> "
> import win32api, win32con, sys
>
> win32api.SendMessage(sys.argv[2], win32con.WM_PAINT, sys.argv[3], 0)
> win32api.SendMessage(sys.argv[2], win32con.WM_PRINT, sys.argv[3],
> win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED)
> "
>
>
> snippet from Snapshot.java :
> "
> public static Image snapshot(Composite bean) {
> GC gc = new GC(bean);
> final Image image = new Image (null, bean.getBounds().width,
> bean.getBounds().height);
> String commmand = "python snap.py " + gc.handle + " " + image.handle;
>
> Runtime rt = Runtime.getRuntime();
> try {
> Process p = rt.exec(command);
> } catch (.)
>
> gc.dispose();
> return image;
> }
> "
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: makepy crashing
Looks like the makepy step creates the generated file successfully, but python is choking with an assertion failure on lines longer than 512 when it tries to import it. This is the line it was processing when it died: def GetSpellingSuggestions(self, Word=defaultNamedNotOptArg, CustomDictionary=defaultNamedOptArg, IgnoreUppercase=defaultNamedOptArg, MainDictionary=defaultNamedOptArg, SuggestionMode=defaultNamedOptArg, CustomDictionary2=defaultNamedOptArg, CustomDictionary3=defaultNamedOptArg, CustomDictionary4=defaultNamedOptArg, CustomDictionary5=defaultNamedOptArg, CustomDictionary6=defaultNamedOptArg, CustomDictionary7=defaultNamedOptArg, CustomDictionary8=defaultNamedOptArg, CustomDictionary9=defaultNamedOptArg, CustomDictionary10=defaultNamedOptArg): You might be able to do a workaround by hacking genpy.py and replacing the defaultArg names with something shorter. ...Nope, there are a few other lines that exceed 512. I think it's a problem with the encoding. If you remove the mbcs tag (# -*- coding: mbcs -*-) from the top of the generated file, the import succeeds. Roger <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Has anyone sucessfully run makepy and Microsoft Word Object Library > (9.0)? Mine crashes under XP Pro and Python 2.4. > > It only seems to be word that has the problem, though. > > I get a dialog that says that pythonwin.exe has crashed: > AppName: pythonwin.exe AppVer: 0.0.0.0 ModName: ntdll.dll > ModVer: 5.1.2600.1217 Offset: 96f9 > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic Windows printer creation?
You can probably do it through WMI. (class is Win32_Printer) WMI works well with win32com, and there's also a wrapper module http://tgolden.sc.sabren.com/python/wmi.html for simplified access. I imagine getting all the device parameters and port configuration right will be messy, though. Roger "GMane Python" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyone know if there's a module which will allow me to 'create' windows > printer definitions? Not from a Windows domain network, but just to add a > printer that sends to a jet-direct-attached printer. > > Thanks! > Dave > > > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: FTPLIB & FTPS or SFTP?
"Peter A. Schott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> have a handful of partners who use FTPS or SFTP and I need to pull/push files
> to/from them.
For SFTP, run don't walk, over to http://www.lag.net/paramiko/
Paramiko is a pure Python(*) implementation of SSH and all the
sub-protocols such as SFTP. Works on all platforms, very responsive
author, works reliably and LGPL license.
(*) It does require PyCrypto which is a native code package available
for all platforms.
Roger
--
http://mail.python.org/mailman/listinfo/python-list
Re: PyWin32 installation
Gdi32 needs to be added to the libraries for win32print in setup.py. (just checked it in) Roger "mg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I have reinstalled my Win32 computer last week and I did an update of the > project PyWin32 to complete my Python installation. > (I have to use sources from CVS for my project !) > > So, when I run 'python setup.py' in my PyWin32 directory, I have two > problem : the version indacated in windows.h and some symbols who are not > defined. See the trace : > >running install >running build >running build_py >running build_ext >Warning - can't find an installed platform SDK >Found WINDOWS.H version 0x501 in C:\Program Files\Microsoft > Visual Studio .NET 2003\Vc7\PlatformSDK\include >building 'win32print' extension >C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO > /LIBPATH:C:\ext_projects\python\dist\src\libs > /LIBPATH:C:\ext_projects\python\dist\src\PCBuild > /LIBPATH:build\temp.win32-2.5\Release winspool.lib user32.lib > /EXPORT:initwin32print > build\temp.win32-2.5\Release\win32\src\win32print\win32print.obj > /OUT:build\lib.win32-2.5\win32\win32print.pyd > /IMPLIB:build\temp.win32-2.5\Release\win32\src\win32print\win32print.lib > /MACHINE:ix86 >Creating library > build\temp.win32-2.5\Release\win32\src\win32print\win32print.lib and > object build\temp.win32-2.5\Release\win32\src\win32print\win32print.exp >win32print.obj : error LNK2019: unresolved external symbol > [EMAIL PROTECTED] referenced in function "struct _object * __cdecl > PyStartDoc(struct _object *,struct _object *)" > (?PyStartDoc@@YAPAU_object@@[EMAIL PROTECTED]@Z) >win32print.obj : error LNK2019: unresolved external symbol > [EMAIL PROTECTED] referenced in function "struct _object * __cdecl > PyEndDoc(struct _object *,struct _object *)" > (?PyEndDoc@@YAPAU_object@@[EMAIL PROTECTED]@Z) > > Then, I don't kwnow how to solve theses problem ! Is there someone tho > help me ? > Thank, > > Mathieu G. == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: threading and internet explorer com
You'll need to call pythoncom.CoInitialize() in each thread.
Roger
"James" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hi,
>
> i'm using python 2.4 with pywin32...
> I've tried to use internet explorer control with a class.
> it was fine until i decided to inherit thread for the class...
>
> class domain01(threading.Thread):
> def __init__(self):
> #blabla
> threading.Thread.__init__(self)
>
> def run(self):
> self.ie = win32com.client.Dispatch('InternetExplorer.Application.1') #this
> line gives error if i use .start(), but if i use .run.. no error...
> self.ie.Visibble = 1
> print "running"
>
>
>
> xyz = domain()
> xyz.start()
>
> ===
> this is what i get:
> Exception in thread Thread-23:
> Traceback (most recent call last):
> File "C:\Python24\lib\threading.py", line 442, in __bootstrap
> self.run()
> File "C:\python2exe\domain01.py", line 41, in run
> self.dologin()
> File "C:\python2exe\domain01.py", line 56, in dologin
> self.ie=win32com.client.Dispatch('InternetExplorer.Application.1')
> File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
> dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
> 91, in _GetGoodDispatchAndUserName
> return (_GetGoodDispatch(IDispatch, clsctx), userName)
> File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
> 79, in _GetGoodDispatch
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
>
>
>
> =
> but if i run:
> xyz = domain()
> xyz.run()
>
> ##no error! it's weird
>
> anyone know how to solve this problem?
>
> thank you :)
>
> best regards,
>
> James
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin (build 203) for Python 2.3 causes Windows 2000 to grind to a halt?
These look like symptoms of sf bug #1017504 http://sourceforge.net/tracker/index.php?func=detail&aid=1017504&group_id=78018&atid=551954 What version of Pywin32 are you running ? There's a (semi) fix for this in the latest build. hth Roger "Chris P." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've been having a problem with PythonWin that seemed to start > completely spontaneously and I don't even know where to START to find > the answer. The only thing I can think of that marks the point > between "PythonWin works fine" and "PythonWin hardly every works fine" > was that I changed the size of my Virtual Paging file, noticing that > it was too small (I currently have a P4 with 1G of RAM). I tried > returning it to its original (smaller) size, but it didn't fix the > problems. > > The first time I noticed it, I was using PythonWin and then > right-clicked on My Computer to use "Explore". Instead of the usual > full listing (approx 10 items), I got a mini-listing of 4 items. > Then, after clicking "Explore", I either don't get a new window at all > OR I get a strange file explorer that won't let me look at files, > won't let me copy files, etc. The "mini-lising" thing also happens if > I click the "Start" button while PythonWin is open. > > Another problem is trying to open another program while PythonWin is > running - generally, the program will not start, but I also don't get > any kind of error popping up on the screen. My request is just > ignored (although I sometimes get a "system beep".) If I already have > other programs open and then open PythonWin, my menu bar might refuse > to function. Is it significant that, when the menu bar IS working, > the drop-down menu fades in quite slowly, instead of popping up > immediately? > > At the end of this message, I've pasted a screen dump of a message I > get when I try to open a file and I've got other apps open (note that > I can have very few, non-memory intensive apps open and I still get > it). > > Thanks for any help you can give, > > - Chris > > [SCREEN DUMP AFTER I TRY TO OPEN A .PY FILE] > File "C:\Python23\Lib\site-packages\pythonwin\pywin\mfc\docview.py", > line 91, in CreateNewFrame >wnd.LoadFrame(self.GetResourceID(), -1, None, context) # triggers > OnCreateClient... > win32ui: LoadFrame failed > > win32ui: CreateNewFrame() virtual handler ( SyntEditTemplate.CreateNewFrame of > 0x01193F30>>) raised an exception > TypeError: PyCTemplate::CreateNewFrame must return a PyCFrameWnd > object. == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Description Field in WinXP Services
ChangeServiceConfig2 is the api functions that sets the description, but it's not in the win32service module (yet). Roger "rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How does one associate a "Description" with a Windows service written in > Python? I've just started experimenting with Python services. Here's my > code... copied straight from Mr. Hammond's "Python Programming on Win32": > > import win32serviceutil > import win32service > import win32event > > class test_py_service(win32serviceutil.ServiceFramework): > _svc_name_ = "test_py_service" > ## Tried the following to no avail. > _svc_description_ = "Test written by Brad" > _svc_display_name_ = "Test Python Service" > > def __init__(self, args): > win32serviceutil.ServiceFramework.__init__(self, args) > self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) > > def SvcStop(self): > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > win32event.SetEvent(self.hWaitStop) > > def SvcDoRun(self): > win32event.WaitForSingleObject(self.hWaitStop, > win32event.INFINITE) > > > if __name__ == '__main__': > win32serviceutil.HandleCommandLine(test_py_service) > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: COM on a network drive can't find pywintypes23.dll
This means the machine is finding an older verion of pywintypes23.dll first, rather than not finding it at all. You may have an old version hanging around in the \system32 directory on that machine. (or anywhere else that it would be found first). You might also want to verify that the dll's you're copying around both come from the same distribution. Roger "Marco Aschwanden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > I have installed Python (2.3.4) on a shared network drive. I use it to run > a bunch of application on the workstations (Win2K). > > Now I am running into the first problem ever. I try to use COM to generate > a word-file. It runs fine on my machine (Python installed locally). When I > deploy it and start the app on another workstation from the fileserver - > it runs but as soon as it comes to the COM part it exits saying: > > The procedure entry point > ?PyWinObject_AsDEVMODE@@YAHPAU_object@@PAPAU_devicemodeA@@[EMAIL PROTECTED] > could not be > located in the dynamic link library pywintypes23.dll > > > Heck... I copied the files: > > pythoncom23.dll > pywintypes23.dll > > to about "1000" locations to make it run (Application's dir, Workstation's > System Dirs, Fileserver's Python main and bin dir, ...). I tried setting > the path on the workstations. But nothing seems to solve the problem. > > Do you have any proposals how to solve this problem? > > Thanks in advance, > > Marco > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is WSAEnumNetworkEvents???
>From a quick look, it wouldn't be too difficult to wrap this function.
Both the input arguments can be already be handled by Swig,
and the outputs would just be an int and a fixed size tuple of ints.
Roger
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I was trying to write an asyncronous TCP server for win32 using
> WSAEventSelect (which lives if win32file). Such events require
> WaitForMultipleObjects (which lives if win32event) and
> WSAEnumNetworkEvents WHICH IS NOT EXPOSED. This makes WSAEventSelect
> useless. Does somebody know how to add the WSAEnumNetworkEvents and
> WSANetwotkEvents structure win32file?
>
> Maybe I'm missing something?
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: Running WMI within a Windows service
Build 204 of pywin32 has a change so that the working dir for a service is the folder where its executable is located instead of \system32, hopefully avoiding trying to import wmi.dll instead of wmi.pyd. Roger "Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] | [.. re problems running WMI in a service ...] | Changing the path didn't do anything, but changing the name of the | module to my_wmi did the trick. | | Thanks very much, | | Cam. | Thanks for the feedback; I'll try to find the time to experiment a bit but I know I've used the change-the-name trick in the past. It has been suggested that I permanently change the module name, but I'm a bit loth to do that. Mark (Hammond) was talking about a patch which would prevent imports from picking up the false .dll, but I don't know if it's gone anywhere. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: connecting to an exsisting COM server
Normally you get that if the application doesn't register itself with the Running Object Table. Do you know if the COM server in question registers itself ? Roger "jelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm using > win32com.client.GetObject(Class='Rhino3.Application') > to connect to an existing COM server. However when doing so: > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\lib\site-packages\win32com\client\__init__.py", > line 80, in GetActiveObject >dispatch = pythoncom.GetActiveObject(resultCLSID) > com_error: (-2147221021, 'Operation unavailable', None, None) > > A com_error is raised. This problem has come up a few times on this > list, however that didn't help me to find a way of connecting to it. > What else could I try? > > Cheers, > > Jelle > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: exec method WMI
You probably need to remove the SpawnInstance_() call.
An abstract WMI class as returned by WBEM.Get should work
for the DriverInfo parm, since the concrete Win32_PrinterDriver
instance is what the AddPrinterDriver call is trying to create.
hth
Roger
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi, I'm trying to use the AddPrinterDriver method of
> Win32_PrinterDriver to create a new. print driver. I can't get my
> head round how I need to do this. So far I have
>
> import win32com.client
> WBEM =
> win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\"
> + "." + r"\root\cimv2")
> WBEM.Security_.Privileges.AddAsString("SeLoadDriverPrivilege")
> drv = WBEM.Get("Win32_PrinterDriver").SpawnInstance_()
> drv.Properties_('Name').Value = "Marcs Printer 2550"
> drv.Properties_('SupportedPlatform').Value = "Windows NT x86"
> drv.Properties_('Version').Value = "3"
> drv.Properties_('DriverPath').Value = 'C:\\test\\HPZPP034.DLL'
> drv.Properties_('InfName').Value = 'C:\\test\\hpc2550d.inf'
> method = drv.Methods_('AddPrinterDriver')
> InParms = method.InParameters
> InParms.Properties_.Item('DriverInfo').Value = drv
> drv.ExecMethod_('AddPrinterDriver',InParms)
>
> I'm using spawninstance to create a new object and then editing the
> properties of it. I'm then setting the InParameters for the method to
> be the new object. When executing the method I get SWbemObjectEx
> object not found.
>
> I think I am not setting the DriverInfo correctly, should it be an
> object? The MSDN site doesn't say what DriverInfo should be.
>
> Any help would be grand.
>
> Thanks, MW.
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: 2.4 Recent File list not working
There was a bug in MFC 7 that prevented Pythonwin from closing
properly. Build 204 of Pywin32 has a workaround, but I'm not
sure if it's been incorporated into ActiveState's distribution yet.
Roger
"Larry Bates" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>I recently upgraded from 2.2 to 2.4 (ActiveState for Windows).
> I was accustomed to having the most recent 10 files that I had
> edited show up under File menu under Recent. After upgrading
> these don't seem to be saved after exiting. I tried changing
> the number in the Preferences, but nothing seems to do any
> good.
>
> Has anyone else had this problem? Any ideas how I might fix
> it?
>
> Thanks in advance for your assistance.
> Regards,
> Larry Bates
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using SHFileOperation
SHFILEOPSTRUCT is just a tuple, with the elements listed in docs. from win32com.shell import shell, shellcon shell.SHFileOperation((0, shellcon.FO_DELETE, 'somefilename', None, shellcon.FOF_ALLOWUNDO|shellcon.FOF_NOCONFIRMATION)) hth Roger "avishay" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi All, > I want to use SHFileOperation using Python and Win32 extentions, in > order to move a file to the trash can. The function itself can be > accessed by importing win32com.shell.shell. However, I cannot find > anywhere the SHFILEOPSTRUCT. This structure is mentioned in the > documentation of the Win32 extentions, but I can't find a way to access > it. > I would appreciate your help. If there's an alternative way to send a > file to the trash can, that can also help. > > Best Regards > Avishay > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ulrich Hobelmann <[EMAIL PROTECTED]> writes: > Keith Thompson wrote: >> "Xah Lee" <[EMAIL PROTECTED]> writes: >> [the usual] > At least he noticed that tar sucks. There's nothing better than tarring > your backup back to disk, only to notice that the pathnames were "too > long." Great! That's been fixed for quite some time, though. The current GNU tar (1.15.1) writes POSIX.1-2001 (PAX) archives, and has read them for quite a long time before. Regards, Roger - -- Roger Leigh Printing on GNU/Linux? http://gimp-print.sourceforge.net/ Debian GNU/Linuxhttp://www.debian.org/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/> iD8DBQFDC5T5VcFcaSW/uEgRAmJ6AKDsqFmvoBsOqsm/6zIfHQleMpI5KwCgsR6Q yO7hX52yq/iHIHC2yJ6hF2A= =MCYF -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: python script under windows
You can use the Task Scheduler to run a script persistently if you don't need the capabilities of the service framework. Roger "Jan Gregor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello > > I run python script on another computer and want to "survive" that > script after my logout. the script also uses drive mapping to network drive. > > Can you help me ? Or better is there some info for unix person how > to survive with python on windows ;-) > > thanks, > jan gregor == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!! Accessing other machines with an IIS CGI script
Without knowing what operation fails, it's kind of difficult to give any meaningful answers. At what point in the code do you get the error ? If IIS runs under a local account, it might not have permission to access the other machine, or to impersonate a domain user. You might want to set up auditing on the folder you're trying to list, and see exactly what user IIS is connecting as (or if it's connecting at all). hth Roger "paulp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings, > > I'm working on a CGI program that will run under MS IIS 5.0 and will > browse folders on three other machines, building HTML pages that will > provide links to these folders. > > Essentially, the CGI will connect to each machine in turn, doing the > FindFirst/FindNext process based on the current criteria. It will > select certain files/folders, and build an HTML page as it goes. > > The premise is fine. If I run the program from the command line, it > seems to work fine and I get my HTML code out. I can copy the code > into a separate file, open it in the browser, and all appears right > with the world. > > However, when I try to run the CGI from the browser itself, I get all > kinds of problems. The first one I got was a 1312, "A specified logon > session does not exist. It may have already been terminated." After > doing some searching, I began to investigate impersonation of a logged > on user. This produces a different error: 1314, "A required privilege > is not held by the client." > > I've been arguing with this now for several days and the frustration > level is beginning to get quite high. Has anyone else ever tried this? > I find it hard to believe that I'm the first to do this. > > Of course, one of my problems is that I'm neither an IIS guru nor an > Admin guru. And we have neither here in the office. > > I'm coding this in Python 2.4 and the Windows extensions. I have a > number of other CGI programs in Python running under IIS that work > correctly, but those only do database accesses. This one I'm trying to > put together is the first one to actually do file searches. > > I have set the privileges for the logged on account on my IIS box for > SE_TCB_NAME, SE_CHANGE_NOTIFY_NAME and SE_ASSIGNPRIMARYTOKEN_NAME and > rebooted. To no avail. I'm not sure if there are additional > alterations that need to be done to the security policies or not. > Again, I'm not a guru. > > If anyone can give me more information/guidance I would greatly > appreciate it. If you need more information from me, I will do my best > to provide it. > > TIA, > > Paul > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI Problem on MS IIS 5.0 - Trying to access files on other machines
You need to adjust your privileges before you call LogonUser.
hth
Roger
"paulp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Greetings,
>
> I'm working on a CGI program that will run under MS IIS 5.0 and will
> browse folders on three other machines, building HTML pages that will
> provide links to these folders.
>
> Essentially, the CGI will connect to each machine in turn, doing the
> FindFirst/FindNext process based on the current criteria. It will
> select certain files/folders, and build an HTML page as it goes.
>
> The premise is fine. If I run the program from the command line, it
> seems to work fine and I get my HTML code out. I can copy the code
> into a separate file, open it in the browser, and all appears right
> with the world.
>
> However, when I try to run the CGI from the browser itself, I get all
> kinds of problems. The first one I got was a 1312, "A specified logon
> session does not exist. It may have already been terminated." After
> doing some searching, I began to investigate impersonation of a logged
> on user. This produces a different error: 1314, "A required privilege
> is not held by the client."
>
> The code involved and the output I'm getting follows:
>
> -BEGIN--
> class Impersonate:
>def __init__(self, login, password ):
>self.domain = '4Q9ND21'
>self.login = login
>self.password = password
>self.handel = None
>def logon(self):
>tracelist.append("Impersonate logon step 0")
>win32security.RevertToSelf()# terminates impersonation
>tracelist.append("Impersonate logon step 1")
>self.handel = win32security.LogonUser( self.login, self.domain,
> self.password, win32con.LOGON32_LOGON_INTERACTIVE,
> win32con.LOGON32_PROVIDER_DEFAULT )
>tracelist.append("Impersonate logon step 2")
>win32security.ImpersonateLoggedOnUser(self.handel)
>tracelist.append("Impersonate logon step complete")
>def logoff(self):
>win32security.RevertToSelf()# terminates impersonation
>if self.handel != None:
>self.handel.Close() # guarantee cleanup
> --END---
>
> and I execute this code with the following
>
> -BEGIN--
>impersonate = Impersonate( 'PYTHONTEST', 'PYTHONTEST' )
>try:
>tracelist.append("about to attempt the IMPERSONATE")
>impersonate.logon()
>tracelist.append("impersonate did NOT throw exception")
>b=AdjustPrivilege(SE_SYSTEM_PROFILE_NAME)
>b=AdjustPrivilege(SE_TCB_NAME)
>try:
>tracelist.append("win32api.GetUserName = " +
> win32api.GetUserName() )
># print win32api.GetUserName() #show you're someone else
>finally:
>impersonate.logoff() #return to normal
>except:
>a = "Impersonate Logon Error: %s %s" % (sys.exc_type, sys.exc_value)
>tracelist.append(a)
># print sys.exc_type, sys.exc_value
> --END---
>
> When I run this code, my tracelist comes out with
>
> -BEGIN--
> 2005-09-15 16:43:37
> about to attempt the IMPERSONATE
> Impersonate logon step 0
> Impersonate logon step 1
> Impersonate Logon Error: pywintypes.error (1314, 'LogonUser', 'A required
> privilege is not held by the client.')
> --END---
>
>
> I'm coding this in Python 2.4 and the Windows extensions. I have a
> number of other CGI programs in Python running under IIS that work
> correctly, but those only do database accesses. This one I'm trying to
> put together is the first one to actually do file searches.
>
>
> I have set the privileges for the logged on account on my IIS box for
> SE_TCB_NAME, SE_CHANGE_NOTIFY_NAME and SE_ASSIGNPRIMARYTOKEN_NAME and
> rebooted. To no avail. I'm not sure if there are additional
> alterations that need to be done to the security policies or not.
> Again, I'm not a guru.
>
>
> If anyone can give me more information/guidance I would greatly
> appreciate it. If you need more information from me, I will do my best
> to provide it.
>
> TIA,
>
> Paul
>
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: win32com.client.GetActiveObject()
Basically, this means the application doesn't register itself
with the Running Object Table. There's not much you can
do about it, except maybe petition whoever makes ITunes.
Roger
"David Nicolson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi,
>
> I have been successfully using iTunes' COM interface with Python using
> either of the following lines successfully:
>
> iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")
> iTunes = win32com.client.Dispatch("iTunes.Application")
>
> The only problem is that it will launch iTunes if it is not running by
> instantiating the object here. There are some reasons
> why I have not attempted to use more COM to check if iTunes is an active
> process, I tried either of the following lines to
> only form a connection if iTunes is running.
>
> iTunes = win32com.client.GetActiveObject("iTunes.Application")
> iTunes = win32com.client.GetObject(Class = "iTunes.Application")
>
> Both lines result in a pythoncom.com_error with 'Operation unavailable' in
> the second element of the tuple. Has anyone been
> able to successfully do this with iTunes' COM server? I have seen other
> 'Operation unavailable' messages in a few other
> mailing lists but was unable to find any solutions to this problem.
>
> Regards,
> David
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python win32com com_error: (-2147418113
Usually this means the COM object has to run in a full ActiveX container.
You can host it in IE, or Pythonwin can act as a container with some effort.
See \pythonwin\pywin\Demos\ocx for some examples of using OCX objects
that require a container.
Roger
"g.franzkowiak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I'm trying to use a proprietary windows software with COM and win32com.
> The result is everytime the error message
>
> com_error: (-2147418113, 'Catastrophic failure', None, None)
>
> I've read this in some e-mails, but can't find the solution and I have
> not enough experience with Windows and COM.
>
> Can anybody help ?
>
> This ist the test script.
>
> #--
> import sys
> from win32com.client import gencache
> import win32com.client
>
> if __name__=='__main__':
>
>flag = None
> gencache.EnsureModule('{A5FE85B0-D562-11D3-A8E8-00609727A3F3}', 0, 1, 0)
> o =
> win32com.client.Dispatch('VISIONP400DATACONTROL.VisionP400DataControlCtrl.1')
>
> """
> Debug output:
> o ==>
>
> o.connectToVisionP400 ==>
>
> """
>
>try:
> flag = o.connectToVisionP400()
>
> """
> Error by function call ==>
> >>> Unhandled exception while debugging...
> Traceback (most recent call last):
> File "S:\Python\DCOM\test.py", line , in ?
> flag = o.connectToVisionP400()
> File
> "C:\Programme\Python\Python2.4\lib\site-packages\win32com\gen_py\A5FE85B0-D562-11D3-A8E8-00609727A3F3x0x1x0.py",
> line 60, in connectToVisionP400
> return self._oleobj_.InvokeTypes(12, LCID, 1, (11, 0), (),)
> com_error: (-2147418113, 'Catastrophic failure', None, None)
> """
>
>except:
> flag = "*** - The connection not possible !"
>
>print flag
>
>
>
> Regards
> gerd
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
--
http://mail.python.org/mailman/listinfo/python-list
Re: win32gui bug: where to report it?
Win32all is called Pywin32 now, and resides on SourceForge: http://sourceforge.net/projects/pywin32/ Roger "George van den Driessche" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's taken me ages to find out why my window, built out of win32all, > wasn't > receiving any messages. Eventually I found the answer here: > > http://mail.python.org/pipermail/python-list/2001-October/069451.html > > The important point being: >> IIRC you have to pass the return value of the RegisterClass() call (which >> is an atom) to the CreateWindowEx() function as the second parameter >> (lpClassName). > ... in other words, you can pass the name of your window class as the > second > parameter, but it will silently fail to work. (This holds for CreateWindow > too.) > > This is a bug for which it is pretty much impossible to work out the > workaround without being told it, so I'd like to put the workaround in a > more easily-found place. But where? win32all doesn't seem to have much > documentation, much less a bug database. > > In case anyone else needs to find this message by searching, some keywords > are: win32all, win32gui, WNDCLASS, RegisterClass, CreateWindow, > CreateWindowEx > > George > > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Convert a raw pointer to IDispatch
Hi, I am trying to use the function "CreateStreamOnHGlobal" from python code (I need to pass an IStream object to MSXML, like I do in C++ code). I was able to retrieve a pointer on the IStream object in this way: from ctypes import * stream = c_int() windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream)) print "%x"%stream.value The problem is that I would like to attach this pointer to a python IDispatch object (in Python only, not using a C++ DLL to do the stuff). Do you know a way to do it ? Thanks for your attention. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert a raw pointer to IDispatch
Le Thu, 17 Feb 2005 19:22:16 +0100, Thomas Heller a écrit :
>> I am trying to use the function "CreateStreamOnHGlobal" from python code
>> (I need to pass an IStream object to MSXML, like I do in C++ code).
>>
>> I was able to retrieve a pointer on the IStream object in this way:
>>
>> from ctypes import *
>>
>> stream = c_int()
>> windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
>> print "%x"%stream.value
>>
>> The problem is that I would like to attach this pointer to a python
>> IDispatch object (in Python only, not using a C++ DLL to do the stuff).
>> Do you know a way to do it ?
>
> What do you want to do with this pointer? Pass it to a function called via
> ctypes?
Once it is a IDispatch object (like the IDispatch object returned by
"win32com.client.Dispatch"), I will call the IStream methods on it and
pass it to a DOMDocument of MSXML. It should look like that:
stream = c_int()
windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
stream_obj = some_conversion(stream)
# IDispatch call
stream_obj.Write("some data", 9)
doc = win32com.client.Dispatch("MSXML2.DOMDocument.4.0")
doc.load(stream_obj)
--
http://mail.python.org/mailman/listinfo/python-list
Re: Need some Python help
There's a bug in python's tokenizer that's triggered when
the generated wrapper code for a COM object has
lines longer than 512. See below link for a workaround:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1085454&group_id=78018
Roger
"Matt Upton" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> Hello, I am new to Python and am trying to produce script to run batch
> processes for ArcGIS 9.0 (ArcView). I have upgraded to Phython 2.4 from
> 2.1
> and am using the Pythonwin to try to code but am running into a problem.
> Whenever I try to debug my program or run any code past the following code
> it gets hung up and crashes, quits, no warning, and no messages. HELP,
> what
> is the problem, it is getting very frustrating.
>
>>> import win32com.client
>>> gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")
>>> gp.workspace = "c:/Program Files/ArcGIS/NASA"
>
>
> It ALWAYS crashes and quits 30 sec or so after line 2 or 3 of the code
> above I can't get Python to do anything in ArcGIS so far, none of the
> tools can be called or used?
>
> I am assuming there is some sort of path or link that is not working
> properly between ArcGIS and Python?
>
> Using the same coding in the IDLE Python environment results in the same
> crashing results.
>
> Oh yea, I am running everything on Windows XP.
>
> Thank you.
>
> Matthew Upton
>
>
>
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: winnt win32process.createProcess with stdout to file ?
You'll need to pass security attributes with inherit=True
to CreateProcess also, and the file has to be opened with sharing.
(win32file.FILE_SHARE_READ|win32file.FILE_SHARE_WRITE)
Also, you shouldn't have FILE_FLAG_OVERLAPPED set if you're
not passing an overlapped object into CreateFile.
hth
Roger
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> os:winnt
> python2.3.2
>
> I have a exe that dumps info to the command line. I want to run this
> process and capture the stdout into a file. I think i'm close... any
> help appreciated.
>
> dh
> --
> import win32process, win32file, win32security, win32con, win32api,
> thread, win32event, win32pipe
>
> cmd = "c:/myexe.exe"
> sa = win32security.SECURITY_ATTRIBUTES()
> sa.bInheritHandle = 1
>
> startInfo = win32process.STARTUPINFO()
> startInfo.dwFlags = win32process.STARTF_USESTDHANDLES
>
> fh = win32file.CreateFile("c:/mylog.log", win32file.GENERIC_WRITE, 0,
> sa, win32file.OPEN_EXISTING, win32file.FILE_FLAG_SEQUENTIAL_SCAN |
> win32file.FILE_FLAG_OVERLAPPED , 0)
> startInfo.hStdOutput = fh
> startInfo.hStdError = win32api.GetStdHandle(win32api.STD_ERROR_HANDLE)
> startInfo.hStdInput = win32api.GetStdHandle(win32api.STD_INPUT_HANDLE)
>
> hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess
> \
> ( None, cmd, None, None, 1, win32con.NORMAL_PRIORITY_CLASS, None, None,
> startInfo)
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: winnt win32process.createProcess with stdout to file ?
If it got past the CreateFile call, the problem's not with the log file.
This error from CreateProcess means it can't find your executable.
Roger
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger, I updated the script (below).. but now I get errors...
> many thanks for your help.
>
> import win32process, win32file, win32security, win32con, win32api,
> thread, win32event, win32pipe
>
> cmd = "c:/myexe.exe"
> sa = win32security.SECURITY_ATTRIBUTES()
> sa.bInheritHandle = 1
>
> startInfo = win32process.STARTUPINFO()
> startInfo.dwFlags = win32process.STARTF_USESTDHANDLES
>
> fh = win32file.CreateFile("c:/mylog.log", win32file.GENERIC_WRITE,
> win32file.FILE_SHARE_READ|win32file.FILE_SHARE_WRITE, sa,
> win32file.OPEN_ALWAYS, win32file.FILE_FLAG_SEQUENTIAL_SCAN , 0)
> startInfo.hStdOutput = fh
> startInfo.hStdError = win32api.GetStdHandle(win32api.STD_ERROR_HANDLE)
> startInfo.hStdInput = win32api.GetStdHandle(win32api.STD_INPUT_HANDLE)
>
> hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess
> \
> ( None, cmd, sa, sa, 1, win32con.NORMAL_PRIORITY_CLASS, None, None,
> startInfo)
>
>
> ERROR:
> pywintypes.error:(2, 'createProcess', ' the system cannot find the file
> specified.;)
>
> it's strange that it gets this error even though i have the
> win32file.OPEN_ALWAYS flag set..
>
> any suggestions... (soo... close!! )
> thanks, thanks!
> david
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: winnt win32process.createProcess with stdout to file ?
TerminateProcess doesn't give it a chance to exit normally and do any cleanup that would happen if it exited itself. It may not have been able to flush its file buffers, etc. Does the executable have any way to signal it to exit ? Roger <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Aweseome! Many many thanks Roger ! You've made my day. > > The last thing that you may be able to help with... > I'm using > win32api.TerminateProcess(hProcess,3) > to kill this process if it gets outta hand... > but when i do so.. it seems that the stdout/stderr don't capture the > output. > > here's my last chunk of code. > again.. thank you so much. > > hProcess, hThread, dwProcessId, dwThreadId = > win32process.CreateProcess \ > ( None, self.RENDER_STRING, sa, sa, 1, > win32con.NORMAL_PRIORITY_CLASS, None, None, startInfo) > > while self.exitCode == 259: > if self.stop: > print "kill da process" > win32api.TerminateProcess(hProcess,3) > > self.exitCode = win32process.GetExitCodeProcess(hProcess) > time.sleep(2) > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32 drive mapping... aka "net use"
You could use win32api.GetLogicalDriveStrings to list
the drive letters currently in use, and find the next free
letter. net use * probably does something like that under
the covers.
hth
Roger
"Lucas Machado" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Alex Martelli wrote:
>
>> import win32net
>> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:'})
>>
>> is an example (not all that easy to fathom from the docs, but I
>> found it out with a little help from the docs, a little from MSDN,
>> and a little experimentation).
>
> I looked through the MSDN and was not able to find much information on
> how to properly use the NetUseAdd function. I searched for the
> function and looked through the results but all it showed was some data
> structure, but i was actually looking for a list of all possible
> arguments and which arguments were/were not required.
>
> my problem with the above NetUseAdd example is that I would rather not
> have to specify a device. In the script I am writing the user may
> choose to map multiple shares so I need to be able to map to the next
> available device:
>
> net use * \\some_server\share_name
>
> instead of:
>
> net use k: \\server\share
>
> Thanks for the help in advance. Also, if anyone could provide a link
> to good windows api docs for python that would be great.
>
> Cheers,
> --Lucas Machado
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: handling pywintypes.error exceptions
You can capture the extra exception data like this.
try:
...win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X
except pywintypes.error,details:
...err_code=details[0]
...
Roger
"Lucas Machado" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm using the win32 api to map samba shares, and I'm having trouble
> handling some exceptions. In my script there are 2 possible exceptions
> when the script attempts to map a share:
>
>>>> win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X
> Traceback (most recent call last):
> File "", line 1, in ?
> pywintypes.error: (53, 'NetUseAdd', 'The network path was not found.')
>
> This exception occurs when '\\foo\bar' is not an existing share. Also,
> when a drive letter is already in use the following occurs:
>
>>>> win32net.NetUseAdd(None, 1,
> {'remote':r'\\some_server\share','local':'Y:'})
> Traceback (most recent call last):
> File "", line 1, in ?
> pywintypes.error: (85, 'NetUseAdd', 'The local device name is already
> in use.')
>
> I know the exception raised in these cases is "pywintypes.error", but
> how can i differentiate between the two exceptions? Being able to do
> this is critical for my script
>
> Thanks in advance,
> --Lucas Machado
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: Win32 drive mapping... aka "net use"
The split should work fine if you remove the r
(raw string) prefix.
>>> win32api.GetLogicalDriveStrings().split('\\\x00')
['A:', 'C:', 'D:', 'E:', 'F:', 'G:', 'H:', 'J:', 'K:', 'Y:', 'Z:', '']
Roger
"Lucas Machado" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger Upole wrote:
>> You could use win32api.GetLogicalDriveStrings to list
>> the drive letters currently in use, and find the next free
>> letter. net use * probably does something like that under
>> the covers.
>
> I went and took your advice and this is where I am now:
>
>>>> import win32api
>>>> a = win32api.GetLogicalDriveStrings()
>>>> a
> 'A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00'
>>>> print a
> A:\ C:\ D:\ E:\ Z:\
>
> So I think this function will work great since it gives me a string
> that i can simply strip away what i don't need and then split it into a
> list and traverse the list. However, when I try to split it, the
> following occurs:
>
>>>> b = a.strip(r'\\\x00')
>>>> b
> 'A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00'
>>>> b = a.split(r'\\\x00')
>>>> b
> ['A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00']
>
> I'm a bit of a novice at python (even more so of the win32 api), but
> I've used the split and strip functions before (for example to get rid
> of '\n' from strings) so it is unclear to me why this does not work.
>
> Thanks
> --LM
>
== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: win32com and Python2.4: Interpreter crashing!
There's a bug in the tokenizer that's triggered by the long lines generated by makepy. See http://sourceforge.net/tracker/index.php?func=detail&aid=1085454&group_id=78018&atid=551954 and www.python.org/sf/1089395 Roger "Tim N. van der Leeuw" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > When trying to use win32com functionality with Python2.4, the > interpreter often crashes! > > I don't know if it's a known problem already that will be fixed in an > upcoming Python2.4.1 version. > > Basically, the problem is: > makepy.py generates a (large, nearly 2mb) Python file for use with COM > interfaces of an MS Excel. Generating the file seems to work fine. > However, when trying to import this file, the interpreter crashes > trying to compile it into a .pyc file. > > The same file gives no such problems with Python 2.3.5. > > I first just used makepy.py with Python2.4, but it crashed after > generating a large Python file. > > Then I created the file using python2.3.5, and copied it to my > python2.4 installation, and that crashes python2.4 when importing it. > > > So as I said before: is this a known problem already fixed for the next > release, or should I collect crash-information for this problem? > > > cheers, > > --Tim > == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =--- -- http://mail.python.org/mailman/listinfo/python-list
Re: PyAsm
"Stefan Behnel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Meaning: Put the assembler into the doc-string of a function. That has several issues. One is that you can't do string operations with it. Say you wanted some %d, %s etc in the string. If you use a documentation generator (eg epydoc) then the code becomes the API documentation for the function. Finally it bloats binary distributions. For example BitPim is 7-10MB binary distribution, full compressed with all doc strings removed. Including doc strings adds another 3MB to the compressed binary size! Instead I would suggest looking at the compile/eval/exec builtins in Python for inspiration. You can give a string to compile and it gives you something you can execute later in varying contexts. Roger -- http://mail.python.org/mailman/listinfo/python-list
