@@ -102,6 +102,34 @@ def _complete(self, text, line, begidx, endidx):
102
102
def _configure (self , parser ):
103
103
sub = parser .sub ()
104
104
self ._add_diagnostics (parser , sub )
105
+ self .add_error (
106
+ "NOT_WINDOWS" , 123 ,
107
+ "Not Windows" )
108
+ self .add_error (
109
+ "SETUP" , 200 ,
110
+ "Error during service user set up: (%s) %s" )
111
+ self .add_error (
112
+ "RUNNING" , 201 ,
113
+ "%s is already running. Use stop first" )
114
+ self .add_error (
115
+ "NO_SERVICE" , 202 ,
116
+ "%s service deleted." )
117
+ self .add_error (
118
+ "BAD_CONFIG" , 300 ,
119
+ "Bad configuration: No IceGrid.Node.Data property" )
120
+ self .add_error (
121
+ "WIN_CONFIG" , 400 , """
122
+
123
+ %s is not in this directory. Aborting...
124
+
125
+ Please see the installation instructions on modifying
126
+ the files for your installation (%s)
127
+ with bin\winconfig.bat
128
+
129
+ """ )
130
+ self .add_error (
131
+ "NO_WIN32" , 666 ,
132
+ "Could not import win32service and/or win32evtlogutil" )
105
133
self .actions = {}
106
134
107
135
class Action (object ):
@@ -551,8 +579,7 @@ def _start_service(self, config, descript, svc_name, pasw, user):
551
579
policy_handle , sid_obj , ('SeServiceLogonRight' ,))
552
580
win32security .LsaClose (policy_handle )
553
581
except pywintypes .error , details :
554
- self .ctx .die (200 , "Error during service user set up:"
555
- " (%s) %s" % (details [0 ], details [2 ]))
582
+ self .raise_error ("SETUP" , details [0 ], details [2 ])
556
583
if not pasw :
557
584
try :
558
585
pasw = config .as_map ()["omero.windows.pass" ]
@@ -581,8 +608,7 @@ def _start_service(self, config, descript, svc_name, pasw, user):
581
608
582
609
# Then check if the server is already running
583
610
if 0 <= output .find ("RUNNING" ):
584
- self .ctx .die (201 , "%s is already running. Use stop first"
585
- % svc_name )
611
+ self .raise_error ("RUNNING" , svc_name )
586
612
587
613
# Finally, try to start the service - delete if startup fails
588
614
hscm = win32service .OpenSCManager (
@@ -597,7 +623,7 @@ def _start_service(self, config, descript, svc_name, pasw, user):
597
623
self .ctx .out ("%s service startup failed: (%s) %s"
598
624
% (svc_name , details [0 ], details [2 ]))
599
625
win32service .DeleteService (hs )
600
- self .ctx . die ( 202 , "%s service deleted." % svc_name )
626
+ self .raise_error ( "NO_SERVICE" , svc_name )
601
627
finally :
602
628
win32service .CloseServiceHandle (hs )
603
629
win32service .CloseServiceHandle (hscm )
@@ -615,20 +641,17 @@ def DumpRecord(record):
615
641
else :
616
642
617
643
def events (self , svc_name ):
618
- self .ctx .die (
619
- 666 , "Could not import win32service and/or win32evtlogutil" )
644
+ self .raise_error ("NO_WIN32" )
620
645
621
646
def _query_service (self , svc_name ):
622
- self .ctx .die (
623
- 666 , "Could not import win32service and/or win32evtlogutil" )
647
+ self .raise_error ("NO_WIN32" )
624
648
625
649
def _start_service (self , config , descript , svc_name , pasw , user ):
626
- self .ctx .die (
627
- 666 , "Could not import win32service and/or win32evtlogutil" )
650
+ self .raise_error ("NO_WIN32" )
628
651
629
652
def _stop_service (self , svc_name ):
630
- self .ctx . die (
631
- 666 , "Could not import win32service and/or win32evtlogutil" )
653
+ self .raise_error ( "NO_WIN32" )
654
+
632
655
#
633
656
# End Windows Methods
634
657
#
@@ -693,15 +716,14 @@ def checkwindows(self, args):
693
716
"""
694
717
self .check_access (os .R_OK )
695
718
if not self ._isWindows ():
696
- self .ctx . die ( 123 , "Not Windows " )
719
+ self .raise_error ( "NOT_WINDOWS " )
697
720
698
721
import Ice
699
722
key = "IceGrid.Node.Data"
700
723
properties = Ice .createProperties ([self ._icecfg ()])
701
724
nodedata = properties .getProperty (key )
702
725
if not nodedata :
703
- self .ctx .die (300 ,
704
- "Bad configuration: No IceGrid.Node.Data property" )
726
+ self .raise_error ("BAD_CONFIG" )
705
727
nodepath = path (nodedata )
706
728
pp = nodepath .parpath (self .ctx .dir )
707
729
if pp :
@@ -713,15 +735,7 @@ def checkwindows(self, args):
713
735
count = win_set_path (dir = self .ctx .dir )
714
736
if count :
715
737
return
716
- self .ctx .die (400 , """
717
-
718
- %s is not in this directory. Aborting...
719
-
720
- Please see the installation instructions on modifying
721
- the files for your installation (%s)
722
- with bin\winconfig.bat
723
-
724
- """ % (nodedata , self .ctx .dir ))
738
+ self .raise_error ("WIN_CONFIG" , nodedata , self .ctx .dir )
725
739
726
740
##############################################
727
741
#
0 commit comments