Re: [python-win32] can't import dde module after importing win32ui

2011-06-07 Thread nekolyanich
Michel Claveau  mclaveau.com> writes:

> 
> Hi!
> 
> I have also/another problem with  win32ui  in 216 version:  on several COM's 
> servers, if the line
>   import win32ui
> is present, servers can not be contacted.
> If I comment the line, no more problem. Uncomment, problem is coming back.
> 
> Waiting a solution, I come back to 214.
> 
> @-salutations

Saw this bug, and 214 version helped me with my 32-bit xp. But in production 
i'd 
have 64-bit mashine, and downgrading to 214 version don't helps. Any ideas, how 
to make it work?


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


[python-win32] How to create a windows service and set the service name through command line option

2011-06-07 Thread emmanuel CAZENAVE
Hi,

I want to have a script which creates a windows service, and that the name
of the service could be fed by user input.
Example: *createservice --servicename=whatevernameichoose*
*
*
I came out with a solution which is below:


class WindowsService(win32serviceutil.ServiceFramework):
_svc_name_ = "dummyname"
_svc_display_name_ = "dummydisplayname"

def __init__(self, args):
self.__class__._svc_name_ = args[0]
win32serviceutil.ServiceFramework.__init__(self, args)

# My question is not about starting and stopping service
def SvcStop(self):
stop_service()

def SvcDoRun(self):
 start_service()


def main():

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('action', type=str, nargs='?')
parser.add_argument('-s', type=str, nargs='?', action='store',
dest='servicename',
help="Name of the service to handle")
cmdargs = parser.parse_args()

if cmdargs.servicename:
WindowsService._svc_name_ = cmdargs.servicename

win32serviceutil.HandleCommandLine(WindowsService,
customInstallOptions='s')


if __name__=='__main__':
main()

As you might notice, my solution is pretty dirty. But it works, I can
install and remove services with a custom name not hard coded in the script.

My question is 'does someone knows a cleaner solution to achieve this ?'

Cleaner would be: not override _svc_name_  dynamically, and not call another
commandline parser before the one called by win32serviceutil

As far as I understand, you can handle your customInstallOptions with a
customInstallOptionsHandler, but that one is called after the creation of
the service, so by that time the name of the service is already set. That's
why I came out with that solution...

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