help with a com object
Scott Hathaway
slhath at home.com
Wed Aug 30 19:14:48 EDT 2000
Everyone,
Thanks for your help! I now have the COM object working, but PHP it seems
cannot handle the string. I will post into the PHP group and see if anyone
knows why.
It seems that I am doomed to knowing just enough about many languages to be
extremely dangerous and not knowing enough to be good in any of them. the
only language I am really good at is VB and I am frankly ashamed to admit
this.
:)
Scott
"Kiss, Arpad" <AKiss at GEOMETRIA.hu> wrote in message
news:D148AB3A9D8FD311A99A008048C79D11289849 at MAIL...
> Hi,
> Next time please attach the traceback too.
> Otherwise try to convert the thePath to string before any usage of it. COM
> communication uses unicode, but in Python it can cause errors. In your
code
> os.listdir and "thePath + x" expression generate error messages. Use for
> example "os.listdir(str(thePath))" and "os.path.isfile('%s%s' %
> (thePath,x))".
> Arpad
>
> Scott Hathaway <slhath at home.com.nospam> wrote in message
> news:<8G9r5.1195$qO1.72033 at news.flash.net>...
> > After trying the following (per the suggestions I have gotten) I get the
> > same error.
> >
> > class PythonDir:
> > _public_methods_ = [ 'GetListing' ]
> > _reg_progid_ = "PythonDir.Utils"
> > _reg_clsid_ = "{95CBD1B0-7E6F-11D4-AB71-0000929181BF}"
> >
> > def GetListing(self, thePath, theType):
> > import os
> > myFiles = os.listdir(thePath)
> > for x in myFiles :
> > if theType == "f":
> > if os.path.isfile(thePath + x):
> > print x + '|',
> > else:
> > if os.path.isdir(thePath + x):
> > print x + '|',
> >
> > if __name__=='__main__':
> > print "Registering COM Server..."
> > import win32com.server.register
> > win32com.server.register.UseCommandLine(PythonDir)
> >
> > Please help!
> >
> > Scott
> >
> > "Arpad Kiss" <sekter at matavnet.hu> wrote in message
> > news:004a01c0128b$1b8d67e0$3404a8c0 at geometria.hu...
> > > Hi,
> > > The methods first parameter is always an instance variable(usually
named
> > > self).
> > > Arpad
> > >
> > > Scott Hathaway <slhath at home.com.nospam> wrote in message
> > > news:E_7r5.914$qO1.64948 at news.flash.net...
> > > > Hello All,
> > > >
> > > > I am trying to create a COM object in python to use with PHP 4. I
> have
> > > > listed the entire code below. All I want it to do is have one
method
> > that
> > > > is passed a directory to scan and a flag that tells to return
> subfolders
> > > or
> > > > files. From PHP, I can instantiate the COM object without errors,
but
> > it
> > > > fails with an exception on the call to GetListing.
> > > >
> > > > class PythonDir:
> > > > _public_methods_ = [ 'GetListing' ]
> > > > _reg_progid_ = "PythonDir.Utils"
> > > > _reg_clsid_ = "{95CBD1B0-7E6F-11D4-AB71-0000929181BF}"
> > > >
> > > > def GetListing(str(thePath), str(theType)):
> > > > import os
> > > > myFiles = os.listdir(thePath)
> > > > for x in myFiles :
> > > > if theType == "f":
> > > > if os.path.isfile(thePath + x):
> > > > print x + '|',
> > > > else:
> > > > if os.path.isdir(thePath + x):
> > > > print x + '|',
> > > >
> > > > if __name__=='__main__':
> > > > print "Registering COM Server..."
> > > > import win32com.server.register
> > > > win32com.server.register.UseCommandLine(PythonDir)
> > > >
> > > > Here is the php code:
> > > >
> > > > $pyCOM = new COM("PythonDir.Utils");
> > > > $pyCOM->GetListing("c:\\", "f");
> > > >
> > > > Please help!
> > > >
> > > > Thanks,
> > > > Scott
> > > >
> > > >
> > > > --
> > > > http://www.python.org/mailman/listinfo/python-list
> > > >
> > >
> > >
> >
> >
> > --
> > http://www.python.org/mailman/listinfo/python-list
> >
>
More information about the Python-list
mailing list