ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> zope-checkins
zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Fix zopectl status on Windows by borrowing from:
by Chris Withers other posts by this author
Oct 30 2009 11:27AM messages near this date
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Don't whine and barf when someone hits Ctrl-C during zopectl fg on Windows. | [Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Fix for LP #61446: running zopectl in interactive mode on Windows exited after start/stop/install/remove commands were issued.
Log message for revision 105394:
  Fix zopectl status on Windows by borrowing from:
  http://svn.plone.org/svn/collective/buildout/plone.recipe.zope2instance/trunk/src/plone/re
cipe/zope2instance/ctl.py

Changed:
  U   Zope/branches/2.12/src/Zope2/Startup/zopectl.py

-=-
Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/zopectl.py	2009-10-30 17:30:18 UTC (rev 105393)
+++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py	2009-10-30 18:26:59 UTC (rev 105394)
@@ -51,15 +51,16 @@
 WIN = False
 if sys.platform[:3].lower() == "win":
     WIN = True
+    import pywintypes
+    import win32service
     import win32serviceutil
     from nt_svcutils import service
     
     def do_windows(command):
         def inner(self,arg):
 
-            INSTANCE_HOME = self.options.directory
-            name = 'Zope'+str(hash(INSTANCE_HOME.lower()))
-            display_name = 'Zope instance at '+INSTANCE_HOME
+            name = self.get_service_name()
+            display_name = 'Zope instance at '+self.options.directory
 
             # This class exists only so we can take advantage of
             # win32serviceutil.HandleCommandLine, it is never
@@ -222,16 +223,26 @@
     ## START OF WINDOWS ONLY STUFF
     
     if WIN:
+
+        def get_service_name(self):
+            return 'Zope'+str(hash(self.options.directory.lower()))
+            
         def get_status(self):
-            # get_status from zdaemon relies on *nix specific socket handling.
-            # We just don't support getting the status and sending actions to
-            # the control server on Windows. This could be extended to ask for
-            # the status of the Windows service though
-            self.zd_up = 0
-            self.zd_pid = 0
-            self.zd_status = None
-            return
+            sn = self.get_service_name()
+            try:
+                stat = win32serviceutil.QueryServiceStatus(sn)[1]
+                self.zd_up = 1
+            except pywintypes.error, err:
+                if err[0] == 1060:
+                    # Service not installed
+                    stat = win32service.SERVICE_STOPPED
+                    self.zd_up = 0
+                else:
+                    raise
 
+            self.zd_pid = (stat == win32service.SERVICE_RUNNING) and -1 or 0
+            self.zd_status = "args=%s" % self.options.program
+            
         do_start = do_windows('start')
         do_stop = do_windows('stop')
         do_restart = do_windows('restart')

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@[...].org
https://mail.zope.org/mailman/listinfo/zope-checkins

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved