[python-win32] Forcing win32com.client.dispatch to start up a fresh Excel

2005-06-21 Thread Tom_RobbinsMilne

Hi,

I'm trying to use Python's win32com
interface to drive an excel spreadsheet.

I've managed to have it open the sheet,
call a VBA function with arguments, and close it down cleanly.

However, if Excel is already running,
it closes the open instance. Which is not good.

Is there a way I can do the equivalent
of VBA's CreateObject() with win32com? I have purchased "Python Programming
on Win32", and can't find anything.

Soon I'll be reduced to running a short
Perl script to do it, where I'd have Python kick off the Perl to get the
job done, but I'd like to avoid that if possible.

Thanks very much in advance.

Regards,
Tom
This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Forcing win32com.client.dispatch to start up a freshExcel

2005-06-21 Thread Tom_RobbinsMilne

Tim,

That worked perfectly.

Much obliged.

Thanks very much,
Tom





"Tim Golden" <[EMAIL PROTECTED]>


Sent by: [EMAIL PROTECTED]
06/21/2005 11:52 AM








To



cc



Subject
Re: [python-win32] Forcing win32com.client.dispatch
to start up a        freshExcel








[EMAIL PROTECTED]

| I'm trying to use Python's win32com interface to drive an excel spreadsheet.


| I've managed to have it open the sheet, call a VBA function with arguments,
and close it down cleanly. 

| However, if Excel is already running, it closes the open instance. Which
is not good. 

| Is there a way I can do the equivalent of VBA's CreateObject() with win32com?
I have purchased 
| "Python Programming on | Win32", and can't find anything. 

I'm not sure about the CreateObject bit, not being a
VBA person, but I suspect you may want to use the
DispatchEx method rather than simply Dispatch. eg,

[some spreadsheet already open]


import win32com.client

xl = win32com.client.DispatchEx ("Excel.Application")
wb = xl.Workbooks.Add ()
ws = xl.ActiveSheet

ws.Cells (1, 1).Value = "Hello"

wb.SaveAs ("c:/temp/temp.xls")
wb.Close ()
xl.Quit ()

xl = None


[original spreadsheet still open]

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

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel

2005-06-21 Thread Tom_RobbinsMilne

John,

>> If this means "Can I create a totally
different independant instance of 
>> Excel so that I don't run the risk of stuffing
up what the user is doing 
>> with their existing instance", then
I'd like to know too.

That's exactly what it is.

Actually a bit more complicated than
that for me.

I'm building a farm of XP boxes to run
Excel spreadsheet based models.

I have a bit of python to act as a server,
reading a message over a socket, calling out to Excel, and returning the
result.

I expect to be running more than one
server on a machine, and hence more than one "instance" of Excel.

What Tim proposed worked for me in the
simple test I ran (meaning it didn't kill the already-running-instance
of excel when I ran it a few times).

Soon I'll be doing the more involved
thing, with a farm of one. I'll certainly let y'all know if it doesn't
work!

Thanks,
Tom





John Machin <[EMAIL PROTECTED]>


Sent by: [EMAIL PROTECTED]
06/21/2005 04:15 PM








To



cc
python-win32@python.org


Subject
Re: [python-win32] Forcing win32com.client.dispatch
to start up a fresh        Excel








[EMAIL PROTECTED] wrote:

>
> Hi,
>
> I'm trying to use Python's win32com interface to drive an excel 
> spreadsheet.
>
> I've managed to have it open the sheet, call a VBA function with 
> arguments, and close it down cleanly.
>
> However, if Excel is already running, it closes the open instance.

> Which is not good.
>
> Is there a way I can do the equivalent of VBA's CreateObject() with

> win32com? 


If this means "Can I create a totally different independant instance
of 
Excel so that I don't run the risk of stuffing up what the user is doing

with their existing instance", then I'd like to know too.

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Application exception in Python.dll

2005-11-23 Thread Tom_RobbinsMilne

Hi,

I have a series of python programs that
communicate over sockets. 
The server is using asyncore, the clients
just the bare socket library.
The system is just storing strings of
XML associated with a particular name, kinda like a poor man's file system.

The trouble is that it mostly runs fine,
but every once in a while (lots of activity each day, but trouble once
every week or so) one of the applications dies mysteriously. Is there anyway
to track down the trouble? Would a different version of python be better?
These processes are launched and then run until they die. I'm thinking
of bouncing them nightly, but would prefer to find the trouble and fix
it.  Advice very much appreciated.

The error I'm getting is:
 Event viewer:

Faulting application python.exe,
version 0.0.0.0, faulting module python24.dll, version 2.4.150.1012, fault
address 0x000t2f60
Doctor Watson:
         
      The application, C:\Python24\python.exe, generated
an application error.
         
      
         
      The exception generated was c005 at address
1E07EF60 (python24!PyObject_GetAttr).


BTW, I did post a query awhile ago about
launching excel as part of this system, which would respond to a remote
query. I have that working, but we're not in production yet so I thought
I'd hold off on letting y'all know that it worked until it actually got
used in anger.
 
Thanks,
Tom




This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Application exception in Python.dll

2005-11-23 Thread Tom_RobbinsMilne

John,

Thanks very much. I'll try there. I
thought it may be something specific to windows, as running it on Linux
seems to work fine.

My apologies for the typo, the
correct hex number is : fault address 0x0007ef60

Thanks,
Tom





John Machin <[EMAIL PROTECTED]>


Sent by: [EMAIL PROTECTED]
11/23/2005 02:21 PM








To
[EMAIL PROTECTED]


cc
python-win32@python.org


Subject
Re: [python-win32] Application exception
in Python.dll








[EMAIL PROTECTED] wrote:
> 
[snip]
> The error I'm getting is:
>  Event viewer:
> 
> Faulting application python.exe, version 0.0.0.0, faulting module

> python24.dll, version 2.4.150.1012, fault address 0x000t2f60

What is that "t" in the middle of a hexadecimal number?

> 
> Doctor Watson:
>                 The application,
C:\Python24\python.exe, generated an 
> application error.
>                 
>                 The exception
generated was c005 at address 1E07EF60 
> (python24!PyObject_GetAttr).

Tom, this points squarely at a bug in core Python. Report the problem 
using the SourceForge bug tracker. This mailing list is for Mark 
Hammond's win32all aka pywin32 package.
Cheers,
John
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32






This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32process open-terminate loop cripples OS

2006-03-20 Thread Tom_RobbinsMilne

David,

Maybe I'm missing something, but doesn't
XP take awhile to launch and kill Notepad?

Does it work a bit better if you launch
a process every 10 seconds?

Thanks,
Tom





"David S." <[EMAIL PROTECTED]>


Sent by: [EMAIL PROTECTED]
03/20/2006 09:42 AM








To
python-win32@python.org


cc



Subject
[python-win32] win32process open-terminate
loop cripples OS








Hello,

I decided to attempt to use python's win32 extensions as a method to
monitor and control process for my python application.  It's working
well in the short term, but, as this app is intended to be very
low-maintenance, and probably high-uptimes without restarting, I want to
put it to the test.  I set a loop similar to below to run every second
for the weekend.  It wasn't very pretty.  I didn't get any process
information (couldn't - system was /almost/ unresponsive) - the most i
could do was alt-tab around, though it wouldn't paint the window, move
the mouse pointer and turn the num lock light on and off.  Can anyone
provide some guidance or perhaps point out a problem in my code?

For what it's worth, I think I can poll process /ad infinitum/ without
any lockups.

Thank you,

-David S.

---

def weekendprocesstest():
    print 1
    Processes.StartProcess("notepad")
    print 2
    Processes.KillName("notepad")
    print 3


---and the functions


def StartProcess(self, RunCmd):
        #not going to bother with win32 for this
        #output=os.System(RunCmd).read()
        StartupInfo = win32process.STARTUPINFO()
        win32process.CreateProcess(
                None,   #
program
                RunCmd, # command
line
                None,   #
process security attributes
                None,   #
thread attributes
                1,    
 # inherit handles, or USESTDHANDLES won't work.
                    
   # creation flags. Don't access the console.
                0,    
 # Don't need anything here.
                    
   # If you're in a GUI app, you should use
                    
   # CREATE_NEW_CONSOLE here, or any subprocesses
                    
   # might fall victim to the problem described in:
                    
   # KB article: Q156755, cmd.exe requires
                    
   # an NT console in order to perform redirection..
                None,   #
new environment
                None,    
     # new directory
                StartupInfo)
        self.ProcessTableRefresh()


def KillName(self, matchstring):
        #get PIDS that have the supplied substring
        self.ProcessTableRefresh()
        ProcessList=self.GetProcessList()
        for process in ProcessList:
            if process[2].lower().find(matchstring.lower())!=-1:
                win32process.TerminateProcess(process[0],0)
        self.ProcessTableRefresh()

def ProcessTableRefresh(self):
        processes = win32process.EnumProcesses()
        pnamepidlist=list()
        for pid in processes:
            try:
                handle =
win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid)
                exe = win32process.GetModuleFileNameEx(handle,
0)
                pnamepidlist.append((handle,
pid, exe))
            except:
                pass

        self.lProcessTable.acquire()
        self.ProcessList=pnamepidlist
        self.ProcessTableAge=0
        self.lProcessTable.release()


___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32






This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to know the native file path of computer A on computer B

2006-03-21 Thread Tom_RobbinsMilne

Michael,

If you just need to deal with the path
to the executable, perhaps os.path.normpath() is what you're looking for.

Regards,
Tom





Michael Li <[EMAIL PROTECTED]>


Sent by: [EMAIL PROTECTED]
03/21/2006 12:33 PM








To
python-win32@python.org


cc



Subject
[python-win32] how to know the native
file path of computer A on        computer
B








Hi, all

I want to run a command remotely, but I have to know
the native file path on the remote computer from client
computer. Here is the details:

  --  ---
  |                  
         |  |        
                |
  |       computer A          
|  |    computer B           |
  |                  
         |  |        
                |
  | C:\shared\database\test.DB |  |  W:\database\test.DB
   |
  |                  
         |  |        
                |
  |   python server            |
 |    client              
|
  |                  
         |  |        
                |
  |                  
         |  |        
                |
  -   ---
               /|\      
                    /|\
                |    
                     
  |
                |-|

 From computer B, I send a command to computer A.
On computer A, python.exe is running 24X7 as a service.
When the pyhton server receives the command, it will go into
folder C:\shared\database and lunch another program.
Now I have to input native path on computer B, and pass
the native file path as an argument with the command and send together
to computer A. Then the python server knows where to go.
I am wondering that is it possible to know the native file path of
computer A on computer B ?
If possible, is there anyone point me a direction how to do it?
This may not be a python question, anyway I asked here, any C/C++/C#
programs are ok.
Thank you very much.

Best regards.
Michael Li

==
This email message and any attachments are for the sole use of the intended
recipients and may contain proprietary and/or confidential information
which may be privileged or otherwise protected from disclosure. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the
intended recipients, please contact the sender by reply email and destroy
the original message and any copies of the message as well as any attachments
to the original message.

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32






This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32