[python-win32] (no subject)
Tim Golden
tim.golden at viacom-outdoor.co.uk
Fri Nov 12 15:44:23 CET 2004
[walou]
| Hello,
| In order to automatically update our NT service, we need to transfert
| some files or a zipped file from the server to the clients.
| My idea is to create a function that launches an other program which
| would stop the service, update it and start it.
| Have somebody already done that sort of update ? What's the
| best way to
| transfert files ?
I haven't done this myself, but it looks like a case for WMI.
Maybe something like the following (completely untested):
<code>
import wmi
import win32file
clients = ["W001", "W002", "W003"]
for client in clients:
c = wmi.WMI (client)
for s in c.Win32_Service (Name='MyService'):
s.StopService () # or PauseService etc.
# Use whatever method to copy the file, eg
win32file.CopyFile ("info.dat", r"\\%s\share\info.dat" % client)
s.StartService () # or ResumeService etc.
print client, "updated successfully"
</code>
Obviously, this is the barebones framework; you need exception
checking, possibly threads depending on how many clients you
have etc.
As to what file transfer is best, I'd use a straight Win32 copy
unless you had some performance or security-related reason not
to. Then you could look in to ssh-based methods (scp, sftp, whatever)
but there tend to be fewer implementations of these in Win32.
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
________________________________________________________________________
More information about the Python-win32
mailing list