Windows service and pyc files

kyosohma at gmail.com kyosohma at gmail.com
Wed Apr 4 13:51:34 EDT 2007


On Apr 4, 10:48 am, Laszlo Nagy <gand... at designaproduct.biz> wrote:
>  Hello,
>
> I have a win32 service written in Python that starts a plain
> application, written in Python.
>
> The win32 service tries to launch the application in a while loop and
> logs the return value of the os.system call. That's all.
>
> The application is a simple Python program that connects to an https
> xml/rpc server, and works with the data retrieved from that server. It
> is written as an application because it must be able to download updates
> for itself. Here is how it works:
>
> a.) connect to server
> b.) compare current version with the latest
> c.) if there is a difference, then download all sources from the server,
> delete all pyc files and exit; otherwise start processing
>
> I could not write a self-restarting server, and I did not want to
> write/install two services for one problem. The win32 service is very
> small and primitive so probably I will not need to update it. I think
> the basic idea is good, but...
>
> When there is a client update available, my application updates itself
> cleanly and exists. Then the service tries to restart the application,
> but it cannot. os.system returns with OS error code -1. The pyc files
> are NOT generated for the application. However, if I start the
> application from the command line, then pyc files are created, and then
> the service will also start the application immediatelly. The win32
> service is running as "Localsystem" so it is sure that it has write
> permission on all files.
>
> I cannot log out the error from the application since it is not started.
> The only error message I have is OSError -1, but it tells me nothing
> about the nature of the error.
>
> Thanks,
>
>    Laszlo

Have you tried the subprocess module for this rather than os.system?
You might be able to pipe errors to a file with it. You might be able
to use the traceback module for more verbose error catching too.

Mike




More information about the Python-list mailing list