how to serialize a COM object ?

2007-04-24 Thread vml
I have a problem :

I have a COM object.

I would like to pass this com object from a server to a client through
a socket.

I tried to put the com object into a stringIO with the pickle module
but :

"can't pickle PyIDispatch objects"


Is there other possibilities to pass a COM object through a network ?
(pyro)

thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to serialize a COM object ?

2007-04-28 Thread vml
On 24 avr, 23:53, Neil Hodgson <[EMAIL PROTECTED]> wrote:
> vmlwrote:
> > I have a COM object.
>
> > I would like to pass this com object from a server to a client through
> > a socket.
>
> As Diez mentioned, this may be possible through Distributed COM
> (DCOM). Its not very popular any more with techniques such as SOAP being
> more widely implemented. DCOM is fiddly to set up particularly the
> security aspects. IIRC I did get it to work with Python but that was
> maybe 8 years ago. Here's an overview of DCOM:
>
> http://msdn2.microsoft.com/en-us/library/ms809311.aspx
>
> Neil

Thank you for your answers, I think that a DCOM application ...

-- 
http://mail.python.org/mailman/listinfo/python-list


python and activeX control

2007-04-28 Thread vml
I have an application that I want to automatised trough a COM layer or
(DCOM)...

I can access to all the method of the COM objects with python and
win32com when this application is running

If the application is not running, I can not access to all the method
of the object.

Usually to overcome this problem , One can use an activeX control
which is just a bitmap in a form in VB(6)... and then the code is :

Dim module As Automation.IModule

Dim myBlock as Automation.IBlock2

Dim myDatabase As Automation.IDatabase

Set module = ActiveXModuleLoader1.module

myDatabase = module.Database("C:/Data/myproj")

I can have active X  ModuleLoader._DActiveXModuleLoader running under
python without a GUI but when you call the .module method of this
object it crashes :

Traceback (most recent call last):

  File "", line 1, in 

  File "D:\soft\python25\lib\site-packages\win32com\client
\__init__.py", line 458, in __getattr__

return self._ApplyTypes_(*args)

  File "D:\soft\python25\lib\site-packages\win32com\client
\__init__.py", line 451, in _ApplyTypes_

dispid, 0, wFlags, retType, argTypes, *args),

com_error: (-2147418113, 'Catastrophic failure', None, None)


my questions :

- Do you have ideas to do translate the vb code into python ?


-In a module genrated by makepy : what can I call as object : coclass
or Dipatch base class ?\


-Do you know how to integrate an activeX control in a python GUI
( wxpython ) ? WOuld it solve my problems ?


- Why I can not access all the method of an object when the
application is not running ? Is there a way to do it ?

-  can I create a Ghost of such an application to be able to have all
the method on all the objects ?

- Can I create a vb code which contains all the code for the com
objects and then try to use python with scipy to do some mathematical
operations on the data?

I would like to do every thing in python but I am a newbie 

Thanks in advance !

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and activeX control

2007-04-28 Thread vml
On 28 avr, 23:09, "Méta-MCI" <[EMAIL PROTECTED]> wrote:
> Bonsoir !
>
> Flagrant délit de manque de confiance dans les newsgroups français en vue...
>
> Ha ! Ha ! Ha !   Bonne chance avec les US...

c'est vrai j'avoue ;)

-- 
http://mail.python.org/mailman/listinfo/python-list


python,win32com,scipy and vb 6 : no module named scipy

2007-05-02 Thread vml
Hello,

I am really new in python scipy win32com and scipy I tried to setup a
COM server to interact with vb 6 the pythom COM server is :

from win32com.server import exception, register
import pythoncom, win32pdhutil, winerror
import math
import numpy
import sys


sys.path.append('D:\\soft\python25\\Lib\\site-packages\\')

#from scipy import linalg


class Fop:
_public_methods_ = [ 'SqVal' ]
def SqVal(self,*val):
import sys
sys.path.append('D:\\soft\python25\\Lib\\site-packages\\')
import scipy
#print sys.path
#mat=numpy.bmat(val)
#linalg.inv(mat)
return sys.path

_reg_verprogid_ = "Python.Fop.3"
_reg_progid_ = "Python.Fop"
_reg_desc_ = "Python Fop"
_reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"


def Register():
import win32com.server.register
return win32com.server.register.UseCommandLine(Fop)



if __name__=='__main__':
print "Registering COM server..."
Register()


the vb 6 code is

Private Sub Form_Load()

Set obj = CreateObject("Python.Fop")

Dim ty(1, 1) As Variant

ty(0, 0) = 1
ty(1, 1) = 2
ty(1, 0) = 3
ty(0, 1) = 4

toto = obj.SqVal(ty)


End Sub


I have a problem when I launch the vb 6 code : no module named
scipy  it is quite strange and I do not understand that Do you
have any ideas ?

thank you very much !

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python,win32com,scipy and vb 6 : no module named scipy

2007-05-02 Thread vml
On 2 mai, 23:37, vml <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am really new in python scipy win32com and scipy I tried to setup a
> COM server to interact with vb 6 the pythom COM server is :
>
> from win32com.server import exception, register
> import pythoncom, win32pdhutil, winerror
> import math
> import numpy
> import sys
>
> sys.path.append('D:\\soft\python25\\Lib\\site-packages\\')
>
> #from scipy import linalg
>
> class Fop:
> _public_methods_ = [ 'SqVal' ]
> def SqVal(self,*val):
> import sys
> sys.path.append('D:\\soft\python25\\Lib\\site-packages\\')
> import scipy
> #print sys.path
> #mat=numpy.bmat(val)
> #linalg.inv(mat)
> return sys.path
>
> _reg_verprogid_ = "Python.Fop.3"
> _reg_progid_ = "Python.Fop"
> _reg_desc_ = "Python Fop"
> _reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"
>
> def Register():
> import win32com.server.register
> return win32com.server.register.UseCommandLine(Fop)
>
> if __name__=='__main__':
> print "Registering COM server..."
> Register()
>
> the vb 6 code is
>
> Private Sub Form_Load()
>
> Set obj = CreateObject("Python.Fop")
>
> Dim ty(1, 1) As Variant
>
> ty(0, 0) = 1
> ty(1, 1) = 2
> ty(1, 0) = 3
> ty(0, 1) = 4
>
> toto = obj.SqVal(ty)
>
> End Sub
>
> I have a problem when I launch the vb 6 code : no module named
> scipy  it is quite strange and I do not understand that Do you
> have any ideas ?
>
> thank you very much !

solved ... problem in the installation

-- 
http://mail.python.org/mailman/listinfo/python-list


passing an array of variant in vb to a python COM object = win32com bug ?

2007-05-03 Thread vml
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :

class Fop:
_public_methods_ = [ 'SqVal' ]
def SqVal(self,*val):
#vol=(val[0][0],val[0][1])
#mat1=mat((vol))
#up=linalg.inv(mat1)
return str(val)#up
_reg_verprogid_ = "Python.Fop.3"
_reg_progid_ = "Python.Fop"
_reg_desc_ = "Python Fop"
_reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"

I pass to this method an array of variant which is the matrix to
invert like that:
vb6 code :


   Set obj = CreateObject("Python.Fop")
Dim ty(1, 1) As Variant

ty(0, 0) = 1
ty(1, 0) = 2
ty(0, 1) = 3
ty(1, 1) = 4

toto = obj.SqVal(ty)


when I dispaly toto as str(val) I obtain the following tuple "(((1,
3), (2, 4)),)" which is not usable 

Do you have an idea to explain this strange behaviour ?

thank you !

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python,win32com,scipy and vb 6 : no module named scipy

2007-05-03 Thread vml
On 3 mai, 03:30, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> scipy is a 3rd party package which I believe you get from the same place,
> more or less, as numpy.

the bug was between the chair and the keyboard;)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing an array of variant in vb to a python COM object = win32com bug ?

2007-05-03 Thread vml
On 3 mai, 14:20, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Thu, 03 May 2007 04:54:43 -0300, vml <[EMAIL PROTECTED]> escribió:
>
>
>
> > I have a python com object which contains a method to inverse an array
> > in vb 6 the definition of the class is :
>
> > class Fop:
> > _public_methods_ = [ 'SqVal' ]
> > def SqVal(self,*val):
> > #vol=(val[0][0],val[0][1])
> > #mat1=mat((vol))
> > #up=linalg.inv(mat1)
> > return str(val)#up
> > _reg_verprogid_ = "Python.Fop.3"
> > _reg_progid_ = "Python.Fop"
> > _reg_desc_ = "Python Fop"
> > _reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"
>
> > I pass to this method an array of variant which is the matrix to
> > invert like that:
> > vb6 code :
>
> >Set obj = CreateObject("Python.Fop")
> > Dim ty(1, 1) As Variant
>
> > ty(0, 0) = 1
> > ty(1, 0) = 2
> > ty(0, 1) = 3
> > ty(1, 1) = 4
>
> > toto = obj.SqVal(ty)
>
> > when I dispaly toto as str(val) I obtain the following tuple "(((1,
> > 3), (2, 4)),)" which is not usable 
>
> > Do you have an idea to explain this strange behaviour ?
>
> This is the expected behaviour. Writing it completely in Python:
>
> py> def SqVal(*val):
> ...   return str(val)
> ...
> py> ty=((1,3),(2,4))
> py> SqVal(ty)
> '(((1, 3), (2, 4)),)'
>
> The *val parameter receives a tuple, whose elements are the positional
> arguments used when calling the function. As you call the function with a
> single argument, val receives a tuple with a single element.
> Perhaps you want to write it as:
>
> py> def SqVal(val):
> ...   print val[0][0]
> ...   print val[0][1]
> ...   print val[1][0]
> ...   print val[1][1]
> ...
> py> SqVal(ty)
> 1
> 3
> 2
> 4
>
> (Of course, if used as a Fop method, dont forget the "self" parameter)
>
> --
> Gabriel Genellina

I just tried to replace the *val by SqVal(self,val) and call the
method in vb but it crashes down :

"when refilling safe array the sequence must have the same number of
dimension as the existing array"

my python code is now :

 def SqVal(self,val):
##volr=[val[0][0][i] for i in range(size(val,2))]
##voli=[val[0][1][i] for i in range(size(val,2))]
##mat1=mat(volr)+1j*mat(voli)
##up=linalg.pinv(mat1)
##out=up.real.tolist()
##out.extend(up.imag.tolist())
return val

By the way Do you have any idea to debug the com server script ? ( I
would like to know if a can access the value in the function while
calling it from vb 6)




tahnks a lot !


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing an array of variant in vb to a python COM object = win32com bug ?

2007-05-04 Thread vml
On 4 mai, 06:56, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Thu, 03 May 2007 09:41:57 -0300,vml<[EMAIL PROTECTED]> escribió:
>
> > On 3 mai, 14:20, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> >> En Thu, 03 May 2007 04:54:43 -0300,vml<[EMAIL PROTECTED]>
> >> escribió:
>
> >> > I have a python com object which contains a method to inverse an array
> >> > in vb 6 the definition of the class is :
>
> > I just tried to replace the *val by SqVal(self,val) and call the
> > method in vb but it crashes down :
>
> > "when refilling safe array the sequence must have the same number of
> > dimension as the existing array"
>
> That can't happen with your Python code below, so it must be on the
> caller. Maybe you wrote something like: xx=something.SqVal(yy) and xx,yy
> are declared of different sizes.
>

It is true that I call the python routine like that in vb :


 toto = obj.SqVal(ty)

If I am understanding well I need to pass an array of 2x2 and I should
retireve an array of variant of 2x2 

I tried to do that :
vb6 :

Dim obj As Object
Dim toto(1, 1, 2) As Variant

Set obj = CreateObject("Python.Fop")
Dim ty(1, 1, 2) As Variant

ty(0, 0, 0) = 1
ty(0, 1, 0) = 2
ty(0, 0, 1) = 3
ty(0, 0, 2) = 7
ty(0, 1, 1) = 4
ty(0, 1, 2) = 45

ty(1, 0, 0) = 1
ty(1, 1, 0) = 2
ty(1, 0, 1) = 3
ty(1, 0, 2) = 7
ty(1, 1, 1) = 4
ty(1, 1, 2) = 45



toto = obj.SqVal(ty)



but it is saying that the compiler can not assign the array toto at
the line toto=obj.SqVal() hum strange .



any ideas ?


Thank you for your help !






> >  def SqVal(self,val):
> > ## ...
> > return val
>
> > By the way Do you have any idea to debug the com server script ? ( I
> > would like to know if a can access the value in the function while
> > calling it from vb 6)
>
> Write a log file as suggested, or use OutputDebugString with the DebugView
> program fromwww.sysinternals.com
>
> --
> Gabriel Genellina


-- 
http://mail.python.org/mailman/listinfo/python-list


python 3.0, pywin32 and scipy

2007-08-02 Thread vml
Hello,


I am trying to promote python in my job, my collegue only see matlab
and microsoft scripting language.
I understood that there willl be no backward compatibility between
python 2.x and 3.0, does it means that:

- my script using pywin32 for the COM layer and scipy for the maths
won't work under 3.0
- will we have the equivalent of pywin32 and scipy in python ?

I will be incharge of designing a python module which will be a
'matrix calculator' in our current software. Will it be compatible
with python 3.0 ? I guess no.

What can I answer to my collegue who will say 'Python is changing and
the stuff you are doing now is useless'?

how can I argue against matlab and c# ?

thanks very much

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3.0, pywin32 and scipy

2007-08-02 Thread vml
On 2 août, 22:30, sturlamolden <[EMAIL PROTECTED]> wrote:
> On Aug 2, 6:01 pm, vml <[EMAIL PROTECTED]> wrote:
>
> > - my script using pywin32 for the COM layer and scipy for the maths
> > won't work under 3.0
>
> Why not?
>
> > - will we have the equivalent of pywin32 and scipy in python ?
>
> Say what? I've always thought pywin32 and scipy were Python packages.

The problem is quite complex in my case.

My company has a some softwares to do some test measurement which can
be automated with vb 6 via OLE automation.
One could use matlab and vb 6 or vb.net or even C# but I succeed to
show the advantages of python due to its simplicity and its
efficiency  but I am a newbee and not a computer scientist at all. Now
they want to use Python as the swissknife of the engineer.

So it is going from vb 6 to Python which is not really straight
forward ... If we want to do simple things like matlab script it is
possible in python, but it is also possible to do some OO programming
and even more.

So with python I need absolutly a COM level and also scipy and
matplotlib, I am confident that both will be ported to python 3.x.

I try still to convince people to switch for, vb 6 to python by
writting a python module which will handle the come layer of our
software.

I thank you very much for your answers.

I hope it will be possible to switch easily to python 3. But I need to
produce something as cheap as possible and I have no means ...

And I try to argue to give up vb 6 and use python. C# is for our
developpers the best solution to do this except the mathematic
stuff... python is so easy to use and easy to read I believe it can be
our best solution ...

Any ideas to convience people (except my scripts ;) )?


-- 
http://mail.python.org/mailman/listinfo/python-list

ActiveX control in python vs ActiveX control in vb 6 (piece of code)

2007-08-22 Thread vml
Hello,

I am trying to mograte from vb 6 to python.

I have a very usefull AX control. It can be :
-just a bitmap
-an active picture where you can plot data and put cursors
-a data explorer

Those 3 behavior are driven by one property in visual studio when you
insert the AX control in a form: the property ModuleName:
   -'default' for bitmap
   -'Picture' for a picture



I try to insert this AX control in a wxpython based application (I
used one of the example delivered with wx) but when I try to change
the property to get an active picture it does not work and display me
the default bitmap :(


Here is the pice of code




import wx

if wx.Platform == '__WXMSW__':
from wx.lib.activexwrapper import MakeActiveXClass
import win32com.client
try:
ocx = win32com.client.gencache.EnsureModule('{33924602-
C29E-4915-91B1-767CA3D675C2}',0x0,1,0)

except:
raise ImportError("Can't load ocx")



#--


class TestPanel(wx.Panel):
def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1)
self.pdf = None

sizer = wx.BoxSizer(wx.VERTICAL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)

# this function creates a new class that can be used as
# a wxWindow, but contains the given ActiveX control.


coclass=ocx.ActiveXModuleLoader

print coclass

coclass.ModuleName='picture'

ActiveXWrapper = MakeActiveXClass(coclass)

# create an instance of the new class
self.pdf = ActiveXWrapper(self)
#self.pdf.ModuleName='PictureManager'



sizer.Add(self.pdf, 1, wx.EXPAND)

btn = wx.Button(self, wx.NewId(), "Open PDF File")
wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5)

btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
wx.EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5)

btn = wx.Button(self, wx.NewId(), "Next Page -->")
wx.EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5)


btnSizer.Add((50, -1), 2, wx.EXPAND)
sizer.Add(btnSizer, 0, wx.EXPAND)

self.SetSizer(sizer)
self.SetAutoLayout(True)

wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)


def OnDestroy(self, evt):
if self.pdf:
self.pdf.Cleanup()
self.pdf = None



def OnOpenButton(self, event):
print 'open'


def OnPrevPageButton(self, event):
print 'button'

def OnNextPageButton(self, event):
print self.pdf.ModuleName

#--

def runTest(frame, nb, log):
if wxPlatform == '__WXMSW__':
win = TestPanel(nb, log)
return win
else:
dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
  'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()


overview = __doc__

#--


if __name__ == '__main__':
import sys
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "ActiveX test",
size=(640, 480),
 style=wx.DEFAULT_FRAME_STYLE|
wx.NO_FULL_REPAINT_ON_RESIZE)
self.tp = TestPanel(self, sys.stdout)


app = wx.PySimpleApp()
frame = TestFrame()
frame.Show(True)
app.MainLoop()



#

I suspect that the activex control is bugged  but how to know that
since it is working perfectly under visual studio vb 6 but not with
python ?:(

please help me !

-- 
http://mail.python.org/mailman/listinfo/python-list


in design time activeX properties

2007-08-28 Thread vml
Hello,


Does anybody know how to modify the property of a design-time activeX
property ? using win32com



thank you for your help,



regards,

Victor

-- 
http://mail.python.org/mailman/listinfo/python-list


python win32com and dispatchbaseclass

2007-03-30 Thread vml
I am a newbie in python and com. I am trying to use python and com to
access to a software.

I had a look in the file .py describing the interface (generated by
makepy) and I found some dispatch base class...

My fisrt question is : is it possible to invoke a com object dispatch
base class?


other question in vb 6 I do something like that :


Public Function GetMyXAxis(idata As foo.idata) As Double()
Dim Block As foo.IBlock

Set Block = idata

GetMyXAxis = Block.XValues
Set Block = Nothing

End Function


is it possible to do the set Block = idata  in python ?


foo.Iblock is a dispatchbaseclass
foo.idata is a dispatchbaseclass

-- 
http://mail.python.org/mailman/listinfo/python-list