Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 19th, 2004, 03:28 AM
ah new ah new is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 40 ah new User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 1 m 21 sec
Reputation Power: 5
need help in win service (code) ....

i have worte some code in py which wish to serve as window service....
here is the code:

#testservice.py
import win32serviceutil
import win32service
import win32event
import os
import print_time

class testservice(win32serviceutil.ServiceFramework):
_svc_name_ = "service"
_svc_display_name_ = "Pythonservice"

def __init__(self,args):
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def svcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)

def svcDoRun(self):
while not self.events.empty():
os.system("print_time.exe")
time.sleep(2)
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

if __name__=='__main__':
win32serviceutil.HandleCommandLine(FDFservice)

---------------------------------------------------
#setup.py
from distutils.core import setup
import py2exe
import sys
sys.argv.append("py2exe")
setup(console=[{"script":'testservice.py'}])

---------------------------------------------------

after i installed it & start it, i found that it not "actually" started when i key in "testservice.py stop" in command prompt

i dont know which part i been done it wrong & i had look for many resources, but i cant find the answer..

i'm using win xp + pythonwin 2.3

so, may you all guys help me??

ps: the "print_time.exe" is just a simple script to print current date & time in a txt file. it have been tested & can run correctlly..

thanks

ah new

Last edited by ah new : November 19th, 2004 at 03:32 AM. Reason: missing info

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > need help in win service (code) ....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT