win32com problem: more than one instance


,

I start my script convert.py simultaneously in any dos-shells several
times. But I get every time the same solidworks instance.
I see in the proccess (task) manager only one solidworks.exe
Therefore I get for all simultaneous conversions the same output file.

I tested the same code with excel (test_excel.py) and her I get many
instances of excel in proccess (task) manager.
How can I get many instances of solidworks

Is it a problem of python
Or is it a problem of the Solidworks-COM-Implemention and I get the
same problem with an C++ client implementation

Posted On: Monday 5th of November 2012 02:10:05 AM Total Views:  235
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Reading/Writing Word Documents in Python (with win32com.client?)

I have a MS Word document that I am using as a template. After a test is run, certain parts of the Word document need to be replaced with the test results. For example, there is a section in the Word document that looks similar to: (Toggle Plain Text) Test Name Test Case # Description of Test Test Procedure # ... Test Name Test Case # Description of Test Test Procedure # ...
VIEWS ON THIS POST

83

Posted on:

Sunday 21st October 2012
View Replies!

????�: How to use win32com to convert a MS WORD doc to HTML ?

HUH! It's solved. Thank you all! You saved my life! Thank you very much. I love you! I love Python! 2008/8/20, Simon Brunning : > 2008/8/19 Lave : >> all ! >> >> I'm a totally newbie huh >> >> I want to convert MS WORD docs to HTML, I found python windows >> extension win32com can make this. But I can't find the method, and I >> can't find any document helpful. > > This should be a useful starting point: > . > > -- > Cheers, > Simon B. > simon@brunningonline.net > http://www.brunningonline.net/simon/blog/ > GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues | Twitter: > brunns > -- > http://mail.python.org/mailman/listinfo/python-list >
VIEWS ON THIS POST

52

Posted on:

Saturday 3rd November 2012
View Replies!

Dummy explanation to win32com needed

Hi. I need a dummy's explanation to utilizing the win32com component to access Microsoft Excel. So far, I have this code. import win32com.client xl = win32com.client.Dispatch("Excel.Application") xl.Visible = 1 workbook = xl.Workbooks.Open("C:\test.xls") Now, my question is, where do I find the snytax I can use to access such functions like workbook.ActiveSheet.Cells(1,1).Value etc... I need a reference to the API I can utilize. Where can I find this
VIEWS ON THIS POST

161

Posted on:

Saturday 3rd November 2012
View Replies!

Error with win32com client on windows 2003 server

Sorry, forgot to mention Subject in my earlier post, hence reposting. ------------ I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: excel = win32com.client.Dispatch("Excel.Application","Quit") workbook = excel.Workbooks.Open(xlsfile) workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS workbook.Close(False) excel.Quit() I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: excel = win32com.client.Dispatch("Excel.Application","Quit") File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) I verified that installation is same. Any idea's as to what might be the problem One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. I would appreciate if anyone can guide me as to why this is happening and how to resolve this.
VIEWS ON THIS POST

83

Posted on:

Saturday 3rd November 2012
View Replies!

RE: How to use win32com to convert a MS WORD doc to HTML ?

> -----Original Message----- > From: python-list-bounces+jr9445=att.com@python.org [mailtoython- > list-bounces+jr9445=att.com@python.org] On Behalf Of Lave > Sent: Tuesday, August 19, 2008 10:06 AM > To: python-list@python.org > Subject: How to use win32com to convert a MS WORD doc to HTML > > all ! > > I'm a totally newbie huh > > I want to convert MS WORD docs to HTML, I found python windows > extension win32com can make this. But I can't find the method, and I > can't find any document helpful. > Word Object Model: http://msdn.microsoft.com/en-us/library/bb244515.aspx Specifically look at Document's SaveAs method. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621
VIEWS ON THIS POST

86

Posted on:

Sunday 4th November 2012
View Replies!

how to recognize IE window already opened using win32com extension

How do I use the win32com API to manipulate IE windows ALREADY open ie = Dispatch("InternetExplorer.Application") opens a new window. But I'd like to be able to find, of windows already open, a specific window (with a specified property, matching url, etc.)
VIEWS ON THIS POST

99

Posted on:

Sunday 4th November 2012
View Replies!

Date type in win32com?

Hi. I'm migrating a VBScript into python. How should I convert Date type parameter in VBScript's COM interface with win32com I couldn't find any answer yet... Thank you in advance.
VIEWS ON THIS POST

77

Posted on:

Sunday 4th November 2012
View Replies!

How to use win32com to convert a MS WORD doc to HTML ?

all ! I'm a totally newbie huh I want to convert MS WORD docs to HTML, I found python windows extension win32com can make this. But I can't find the method, and I can't find any document helpful. Can anyone help me Thank in advance.
VIEWS ON THIS POST

87

Posted on:

Sunday 4th November 2012
View Replies!

pywin32/win32com float/double coercion

I'm an old hand at python, but totally new to win32com -- I've run into a snag that seems to be related to python's (usually handy) lack of distinction between floats and doubles. Can anyone explain to me (or point me towards the right docs) how the win32com module handles an ActiveX component that returns or expects an array of SINGLE precision floats (ie, 32-bit floats) I'm using a vendor-supplied ActiveX component with two related API calls that use variant arrays: vector = ReadDataV(...) WriteDataV(vector) ReadData() correctly returns a tuple of floats when called from python via win32com. However, WriteDataV() expects a vector of single precision floats, but it seems like the win32com coercion mechanism is passing in doubles (or at least after a few days of banging my head against this, I'm convinced that's what's going on). Basically the following results in garbage getting sent to the component: x = ReadDataV() WriteData(x) Can anyone point me in the right direction for fixing this problem Is there a way to force win32com to use single precision when passing in floating point arrays
VIEWS ON THIS POST

119

Posted on:

Monday 5th November 2012
View Replies!

RE: win32com problem: more than one instance

Thomas, excel registers its COM objects with REGCLS_SINGLEUSE that means one COM object is created per process. In Solidworks it seems that that they register with REGCLS_MULTIPLEUSE, which means on process can serve more than one COM object. Hence you have no chance to get multiple instances running in any COM client. Stefan > -----Original Message----- > From: python-list-bounces+sschukat=dspace.de@python.org > [mailtoython-list-bounces+sschukat=dspace.de@python.org] On > Behalf Of Tim Golden > Sent: Friday, August 31, 2007 1:36 PM > To: Thomas Rademacher > Cc: python-list@python.org > Subject: Re: win32com problem: more than one instance > > Thomas Rademacher wrote: > > , > > > > I start my script convert.py simultaneously in any > dos-shells several > > times. But I get every time the same solidworks instance. > > I see in the proccess (task) manager only one > solidworks.exe Therefore > > I get for all simultaneous conversions the same output file. > > I *think* -- and I'm really hoping someone more knowledgeable > can chip in here -- that it's down to the particular COM > object implementation. ie Excel may choose to offer you > separate instances (or whatever they're called) while > SolidWorks may not. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list >
VIEWS ON THIS POST

134

Posted on:

Monday 5th November 2012
View Replies!

Re: Regular Expressions: Can't quite figure this problem out

Robert Dailey wrote: > > > On 9/24/07, *Gabriel Genellina* > wrote: > > Yes: forget about regular expressions. ElementTree does that for free: > > > That's not an option. > Even though it's built into Python 2.5 That's a strange requirement. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline
VIEWS ON THIS POST

135

Posted on:

Monday 5th November 2012
View Replies!

Threading problem when many sockets open

In message , Philip Zigoris wrote: > ... and the server > would go into a state where the master thread repeatedly polled the > socket and printed an error. Is that because it cannot create a new socket to accept the connection on
VIEWS ON THIS POST

139

Posted on:

Monday 5th November 2012
View Replies!

python 2.5 problems

Finally deleted 2.2 and loaded 2.5 (see below), using the msi, on my XP partition. Having intermittent system crashes. Assumed a corrupt download, so deleted and did another download/install. Same problems. The associated DLLs when XP says that it must shut down the idle shell are not consistent. So is there something not stable about ver 2.5 on XP Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
VIEWS ON THIS POST

185

Posted on:

Monday 5th November 2012
View Replies!

Mac OSX sqlite problem. Missing?

I've installed Mac Python 2.5. I'm running Mac OS X 10.4.10 on a Macbook 1.83GHz. I though that the python sqlite library was installed by default as part of Mac Python 2.5, however, I still have a problem. Sqlite does not appear to be my system: >>> import sqlite Traceback (most recent call last): File "", line 1, in ImportError: No module named sqlite I ran 'sudo easy_install pysqlite' which gave me the file 'pysqlite-2.3.5-py2.5-macosx-10.3-fat.egg', but no working pysqlite. I then downloaded the source files and ran 'python ez_setup.py pysqlite==2.3.5', which told me 'Using /Library/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/site-packages/ pysqlite-2.3.5-py2.5-macosx-10.3-fat.egg' Still no working version of pysqlite. Tried installing from source. No problems appeared, but I still can't use pysqlite. The reason I am trying to install pysqlite, is to use turbogears, which initially failed when I ran 'tg-admin sql create', it failed with 'import sqlite. ImportError: No module named sqlite'. Any ideas gratefully received.
VIEWS ON THIS POST

95

Posted on:

Monday 5th November 2012
View Replies!

Re: StringIO MySQL data blob Image problem

ah, sorry a+=1 should be after 'Do stuff here' of course... On 9/5/07, dimitri pater wrote: > > the following code works when inserting images in reportlab tables: > > (result4 is a query result) > a=0 > for i in result4: > cfoto = StringIO() > cfoto.write(result4[a][9].tostring()) > dfoto = cfoto.getvalue() > fileFoto = open(str(a)+'temp.jpg','wb') > fileFoto.write(dfoto) > fileFoto.close() > foto = Image(str(a)+'temp.jpg') > a+=1 > > Do stuff here (insert the Image) > > The problem with this code is that I need to create a unique file > (str(a)+'temp.jpg'), I tried to use a single temp.jpg but it kept > using the data from the first record. Tried flush(), truncate(0), but > it didn't work. (My mistake probably ;-) > But the images show in the PDF so that's fine for now. > > On 9/5/07, dimitri pater wrote: > > ---------- Forwarded message ---------- > > From: dimitri pater > > Date: Sep 5, 2007 9:13 PM > > Subject: Re: StringIO MySQL data blob Image problem > > To: Tim Golden > > > > > > > Well, I'm mystified. Not by your results: that exactly what I > > > expected to get, but because you're doing everything *except* > > > manipulating an image and putting it into a PDF via ReportLab. > > > > > Dear Tim, > > you are right of course, I have been trying to put the StringIO in a temp file: > > cfoto=StringIO > > cfoto.write(result[0][1].tostring()) > > dfoto=cfoto.getvalue() > > fileFoto=open('temp.jpg','wb') > > fileFoto.write(dfoto) > > > > and indeed, the blob from MySQL is saved as an image! > > however, > > foto= Image('temp.jpg') > > and inserting foto into a table results in: > > x = struct.unpack('B', image.read(1)) > > error: unpack str size does not match format > > oh, well... still needs some work > > BTW: I used 'local' images before (I mean they did not originate from > > a DB), that worked well in Reportlab's tables. > >
VIEWS ON THIS POST

87

Posted on:

Monday 5th November 2012
View Replies!

[win32] spawn background process and detach it w/o problems

! How to write portable (win32, unix) script that launches another program and continues its execution I've looked at spawn*() but it doesn't look in PATH dirs on windows so it's totally unusable when you don't know where exactly program is. I've looked at fork() way but there's no fork for windows. My current solution is thread.start_new(os.system, (
VIEWS ON THIS POST

206

Posted on:

Monday 5th November 2012
View Replies!

Pylons, SQLAlchemy, too many connections problem.

. I have pylons 0.96 (SVN) and current SQLAlchemy (0.3.10), and I have bug that doesn't exist earlier. My connection code: import sqlalchemy.mods.threadlocal from sqlalchemy import DynamicMetaData, objectstore metadata = DynamicMetaData( case_sensitive = False ) def db_connect( dsn ): engine = create_engine( dsn, echo=False, echo_pool=False, encoding='latin2', convert_unicode=True ) metadata.connect( engine ) command "netstat -an|grep 5432|grep ESTABLISHED|wc -l" displays one more connection after each refresh of page until I have exceptions such as: sqlalchemy.exceptions.DBAPIError: (Connection failed) (OperationalError) FATAL: sorry, too many clients already What is wrong
VIEWS ON THIS POST

114

Posted on:

Monday 5th November 2012
View Replies!

some problems with mod_python

Johan a crit : > Hi > > I have installed and tested this on centos, fedora and freebsd all > give the same problem so I guess I missed some steps. > > I have compiled bot apache (2.2.4) and mod_python (3.3.1) according to > the docs and no problem with this. > But when I have made everything about testing mod_python an browse to > http://server/test and there expecting to see " world" I instead > get an index of contents in this directory. If I go to http://server/test/mptest.py > it works. No errors in any log either. > > What Have I missed The difference between AddHandler and SetHandler in apache's conf. > This I added to httpd.conf > > owOverride > AddHandler mod_python .py > PythonHandler mptest > PythonDebug On > Your problem is with Apache configuration, not with mod_python. The AddHandler directive maps /*.py to your handler. So you have to call .py to trigger the deed behaviour. If you want *any* url under to be handled by mptest, you need to use SetHandler, not AddHandler.
VIEWS ON THIS POST

200

Posted on:

Monday 5th November 2012
View Replies!

Eclipse3.3 with Pydev 1.3.10 Mylar problem, have Mylyn

Right now I am trying to install pydev 1.3.10 on Eclipse 3.3. I am getting an Mylar error org.eclipse.mylar (2.0.0.v20070403-1300) or something needed. Mylyn is mylar, now. How do you disable the mylar dependency, so that Mylyn is used by PyDev
VIEWS ON THIS POST

153

Posted on:

Monday 5th November 2012
View Replies!

Re: StringIO MySQL data blob Image problem

dimitri pater wrote: > > the following code works when inserting images in reportlab tables: > > (result4 is a query result) > a=0 > for i in result4: > cfoto = StringIO() > cfoto.write(result4[a][9].tostring()) > dfoto = cfoto.getvalue() > fileFoto = open(str(a)+'temp.jpg','wb') > fileFoto.write(dfoto) > fileFoto.close() > foto = Image(str(a)+'temp.jpg') > a+=1 > > Do stuff here (insert the Image) > > The problem with this code is that I need to create a unique file > (str(a)+'temp.jpg'), I tried to use a single temp.jpg but it kept > using the data from the first record. Tried flush(), truncate(0), but > it didn't work. (My mistake probably ;-) > But the images show in the PDF so that's fine for now. You've obviously already worked this one out, which is great. But if I might just comment on the code a little bit, in a spirit of helpful criticism: * It's not clear (to me) why you're using a StringIO at all. I'm not familiar with MySQL in particular, but in general, database interface modules will return a Python string or possibly a buffer object from a Blob field. In other words, is there anything to stop you simply writing "result4[a][9]" directly into a file # ... stuff leading up to: blob = result4[a][9] ofile = open ("temp.jpg", "wb") ofile.write (blob) # (or, possibly, str (blob) if it's a buffer) ofile.close () * Assuming you're using any recent version of Python, you can save the extra counter by iterating over enumerate (result4) which return a 0-based index and the indexed item as a tuple. In fact, now I look at it, you're doing the work twice. You're iterating over result4 but doing nothing with the "i" which is the result of the iteration. You might do better with something like this: # # I've used "a", "i" to match your code, # but more descriptive names are good, such # as n_result, result or whatever fits your mind. # for a, i in enumerate (result4): blob = i[9] ofile = open ("%d-temp.jpg" % a, "wb") ofile.write (blob) ofile.close () * Finally, the tempfile module is a good one to use for temporary files. (Although the xx-temp.jpg solution you used may be perfectly acceptable for your needs). In the above, I've avoided quite a few good-practice issues, such as try-except blocks when writing a file, or with-blocks in Python 2.5+. The code I've sketched out is merely a rough-and-ready illustration of a particular point, not a manual of best practice. I suspect you may be newish to Python, if not to programming in general. My comments above aren't intended to be nitpicks to show up your ignorance, but hopefully hints which might help you look at alternatives or consider alternative idioms within Python itself. Good luck with the PDFs! TJG
VIEWS ON THIS POST

143

Posted on:

Monday 5th November 2012
View Replies!