[python-win32] Python-win32 Digest, Vol 53, Issue 6

Huang Guan crown.hg at gmail.com
Tue Aug 7 02:23:41 CEST 2007


Dear Sirs,

Thanks for the detail comments from Tim Roberts,Roger and Michel Claveau,
question 1, 2, 4 have been finished.

I am doing a anti pornography and violence software, which face to the
youngers.

Convenience to distribute the software and restrictc some mischievous
youngsters to shut down this program, that's why I need to settel the
problem 1.

Regarding to the problem 2, I found it and major in reserching technic, not
mean others.
Now we could reolve the problem 1 and 2, it's unneccessary to discut it any
more.

Thanks for the Michel Claveau's suggestion help me settled problem 4.

question 1, 2, 4 have been finished.


I need your help on question 3 still:

import pythoncom
from win32com.server import util
f=open('somepage.html','r')
fs=util.FileStream(f)
istream=util.wrap(fs, pythoncom.IID_IStream )
p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit)
p.Load(istream)

p.Load(istream)tested and excuted successful, thank you.

f=open('somepage.html','w+')
fs=util.FileStream (f)
istream=util.wrap(fs, pythoncom.IID_IStream)
p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit)
p.Save(istream,True)

Why p.Save(istream,True) can excuted, but error massage as below:
pythoncom error: Unexpected gateway error
<type 'exceptions.TypeError'>: an integer is required
check somepage.html file current dir,is exists,size:5kb,
but the file is not complete html source.
How to resolve the p.Save() problem?

v_StringIO=StringIO.StringIO()
v_f_object=open(' somepage.html','r')
v_StringIO.write(v_f_object.read())
v_f_object.close()
fs=util.FileStream(StringIO)
istream=util.wrap(fs, pythoncom.IID_IStream)
p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit)
p.Load(istream)

p.Load(istream) excuted successfully, but do not get values from v_StringIO,
why?


Thanks & best regards!
Crown.hg





> Message: 4
> Date: Fri, 03 Aug 2007 09:48:33 -0700
> From: Tim Roberts < timr at probo.com>
> Subject: Re: [python-win32] pywin32 bugs feedback from learner
> To: python-win32 at python.org
> Message-ID: < 46B35C61.9020204 at probo.com>
> Content-Type: text/plain; charset=GB2312
>
> Huang Guan wrote:
> > Dear Tim Roberts,
> >
> > Do you mean Task Manager? I don't want you to hide your service from me.
> > It's my computer, and I want to know exactly what's running.
> > {Yes, I am writting a similar module. An general user of windows user
> > group could shut pythonservice.exe in the task manager, and my python
> > service would be shutdown in the same time.Is there any good ways
> > except hide pythonservice.exe process?}
>
> No legitimate process should be able to hide from me. It's MY computer,
> and I have every right to know exactly what is running on it. And if I
> decide I don't want your process to run, it's not up to you to stop me.
>
> Don't do this. If you do, pythonservice.exe will get a reputation as
> being "malware", and all Python users will suffer.
>
>
> > {I use ResHacker tool to change the Version info of vmnetdhcp.exe
> > file, change 'VALUE "CompanyName", "VMware, inc."' to be 'VALUE
> > "CompanyName", "VMware,Crop."',then??show "VMware.Inc" in Msconfig
> > successfully, as" Vmware.Crop."??But I use the same method on
> > pythonservice.exe??it doesn't work? How can I do for it?}
>
> PythonService.exe does not seem to have a version resource at all. I
> don't know if ResHacker has the ability to insert a version resource
> into a file that does not have one.
>
> And even if it could, I'm not convinced that it is ethical.
> PythonService.exe was not created by you. Why should you have the right
> to claim it?
>
>
> > {without using makepy, according to below suggestion by Mr.Roger:
> > ie.Navigate('about:blank')
> > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit )
> > p.Load(<PyIStream that contains content>)
> > in existence p.Load() method confirmed??but how to do could use
> > P.Save() save PyISteram to a string variable(include Html header
> > info????How to do could load to ie.document via p.Load() from HTML
> > SOURCE string variable? This is my greatest concern problem.I re-sent
> > this question to Roger and pywin32 mail list, pls do me the favor on
> > these problem. Thank you. }
>
> To do this, you will somehow have to create a PyIStream object that
> saves to a string. I Googled for "using istream python" and did find one
> or two examples of people doing this.
>
>
> > 4). While using pywin32 to control IE,
> > It's certain that using win32com.client.Dispatch return IE object.
> > It can execute the JavaScript method of current transfer page,
> > the following code has been execute and come through:
> > v_iexplore=win32com.client.Dispatch('InternetExplorer.Application')
> > v_iexplore.Navigate('
> > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm'
> > < http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm%27
> >)
> > v_id=v_iexplore.Document
> > .Script._oleobj_.GetIDsOfNames('Welcome')
> > v_iexplore.Document.Script._oleobj_.Invoke(\
> > v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\
> > 'HuanGuan')
> > But: It can't execute the above code exactly In the
> > win32com.client.DispatchWithEvents return IE object.
> > How to solve this problem ? Would you pls kindly to show me some
> examples?
>
> It's interesting that you showed us the code that worked, but not the
> code that didn't work. That's what you need to fix, right?
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 3 Aug 2007 19:09:48 -0400
> From: "Roger Upole" < rwupole at msn.com >
> Subject: [python-win32]  Re: Python-win32 Digest, Vol 53, Issue 3
> To: <python-win32 at python.org >
> Message-ID: <000201c7d623$665f4eb0$0100a8c0 at rupole>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>         reply-type=original
>
> Huang Guan wrote:
> > Thanks for your comments, according the code suggestion you gave:
> >         ie.Navigate('about:blank')
> > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit)
> >    p.Load(<PyIStream that contains content>),
> > confirm Load() metchod in existence.
> >
> > Could you give some examples on how to use PyISteream for my
> > reference? It's very difficult to find use paradigm in pywin32.chm.
> >
> > 1.) How can we use p.Save(<PyIStream that contains con tent>) method,
> > save html source and html header into a string variant?
> > 2.) same as part 1,how to use a string variant ??string=html
> > source??,load into ie.Document control?
> > 3) If execute p.Save (), and p.Load () successfully, as initialize
> > ie.Document control with ie.Navigate ( 'about : blank') before, will
> > the IE original URL address bar become "about : blank"? I want to keep
> > the original IE address bar URL unchanged. Is it possible?
>
>
> There are a couple of IStream implementations included in the Pywin32
> distribution.  Take a look at win32com.server.util.FileStream for file
> operations, and \win32com\test\testStreams.py for a string based
> approach.
>
> Here's an example of creating an IStream suitable for loading content from
> a file:
> import pythoncom
> from win32com.server import util
> f=open('somepage.html','r')
> fs=util.FileStream (f)
> istream=util.wrap(fs, pythoncom.IID_IStream)
>
> If you already have a document loaded, you can omit the Navigate
> part, and the URL remains as it was.
>
>         Roger
>
>
>
> ------------------------------
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of Python-win32 Digest, Vol 53, Issue 6
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070807/0212e19d/attachment.htm 


More information about the python-win32 mailing list