Skip to content

Commit b8fe11f

Browse files
authored
JIRA WDT-638 - Should never exit with uncaught exceptions (#1157)
1 parent 11b3973 commit b8fe11f

File tree

13 files changed

+122
-13
lines changed

13 files changed

+122
-13
lines changed

core/src/main/python/compare_model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
# If the flag is not provided then all output is written to the standard out.
1313
#
14+
import exceptions
1415
import os
1516
import sets
1617
import sys
@@ -348,4 +349,9 @@ def format_message(key, *args):
348349

349350

350351
if __name__ == "__main__":
351-
main()
352+
try:
353+
main()
354+
except exceptions.SystemExit, ex:
355+
raise ex
356+
except (exceptions.Exception, java.lang.Exception), ex:
357+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, _logger)

core/src/main/python/create.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
55
The main module for the WLSDeploy tool to create empty domains.
66
"""
7+
import exceptions
78
import os
89
import sys
10+
911
from java.io import IOException
1012
from java.lang import IllegalArgumentException
1113
from java.lang import String
@@ -376,4 +378,9 @@ def main(args):
376378

377379
if __name__ == '__main__' or __name__ == 'main':
378380
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
379-
main(sys.argv)
381+
try:
382+
main(sys.argv)
383+
except exceptions.SystemExit, ex:
384+
raise ex
385+
except (exceptions.Exception, java.lang.Exception), ex:
386+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/deploy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
The entry point for the deployApps tool.
66
"""
7+
import exceptions
78
import os
89
import sys
910

@@ -17,6 +18,7 @@
1718
# imports from local packages start here
1819
from wlsdeploy.aliases.aliases import Aliases
1920
from wlsdeploy.aliases.wlst_modes import WlstModes
21+
from wlsdeploy.exception import exception_helper
2022
from wlsdeploy.exception.expection_types import ExceptionType
2123
from wlsdeploy.logging.platform_logger import PlatformLogger
2224
from wlsdeploy.tool.deploy import deployer_utils
@@ -258,4 +260,9 @@ def main(args):
258260

259261
if __name__ == '__main__' or __name__ == 'main':
260262
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
261-
main(sys.argv)
263+
try:
264+
main(sys.argv)
265+
except exceptions.SystemExit, ex:
266+
raise ex
267+
except (exceptions.Exception, java.lang.Exception), ex:
268+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/discover.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
The entry point for the discoverDomain tool.
66
"""
7+
import exceptions
78
import os
89
import sys
910

@@ -234,6 +235,7 @@ def __discover(model_context, aliases, credential_injector, helper):
234235
model = Model()
235236
base_location = LocationContext()
236237
__connect_to_domain(model_context, helper)
238+
237239
try:
238240
_add_domain_name(base_location, aliases, helper)
239241
DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode,
@@ -367,6 +369,7 @@ def __disconnect_domain(helper):
367369
_method_name = '__disconnect_domain'
368370

369371
__logger.entering(class_name=_class_name, method_name=_method_name)
372+
370373
if __wlst_mode == WlstModes.ONLINE:
371374
try:
372375
helper.disconnect()
@@ -571,7 +574,6 @@ def main(args):
571574
:return:
572575
"""
573576
_method_name = 'main'
574-
575577
__logger.entering(class_name=_class_name, method_name=_method_name)
576578
for index, arg in enumerate(args):
577579
__logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=_class_name, method_name=_method_name)
@@ -638,4 +640,9 @@ def main(args):
638640

639641
if __name__ == '__main__' or __name__ == 'main':
640642
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
641-
main(sys.argv)
643+
try:
644+
main(sys.argv)
645+
except exceptions.SystemExit, ex:
646+
raise ex
647+
except (exceptions.Exception, java.lang.Exception), ex:
648+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/encrypt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
The main module for the WLSDeploy tool to encrypt passwords.
66
"""
7+
import exceptions
78
import sys
89

910
from java.io import IOException
@@ -253,4 +254,9 @@ def main(args):
253254

254255
if __name__ == '__main__' or __name__ == 'main':
255256
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
256-
main(sys.argv)
257+
try:
258+
main(sys.argv)
259+
except exceptions.SystemExit, ex:
260+
raise ex
261+
except (exceptions.Exception, java.lang.Exception), ex:
262+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/extract_resource.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
The entry point for the extractDomainResource tool.
66
"""
7+
import exceptions
78
import sys
89

910
from oracle.weblogic.deploy.deploy import DeployException
@@ -158,4 +159,9 @@ def main(args):
158159

159160
if __name__ == '__main__' or __name__ == 'main':
160161
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
161-
main(sys.argv)
162+
try:
163+
main(sys.argv)
164+
except exceptions.SystemExit, ex:
165+
raise ex
166+
except (exceptions.Exception, java.lang.Exception), ex:
167+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/model_help.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
55
The entry point for the modelHelp tool.
66
"""
7+
import exceptions
78
import os
89
import sys
10+
911
from oracle.weblogic.deploy.util import CLAException
1012
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
1113

@@ -133,4 +135,9 @@ def main(args):
133135

134136
if __name__ == '__main__' or __name__ == 'main':
135137
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
136-
main(sys.argv)
138+
try:
139+
main(sys.argv)
140+
except exceptions.SystemExit, ex:
141+
raise ex
142+
except (exceptions.Exception, java.lang.Exception), ex:
143+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/prepare_model.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
#
88
# This code prepare a list of models for deploying to WebLogic Kubernetes Operator Environment.
99

10+
import exceptions
11+
import sys
1012
import traceback
1113

12-
import sys
1314
from oracle.weblogic.deploy.util import CLAException
1415
from oracle.weblogic.deploy.util import PyWLSTException
1516
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
1617

1718
from oracle.weblogic.deploy.prepare import PrepareException
19+
from wlsdeploy.exception import exception_helper
1820
from wlsdeploy.logging.platform_logger import PlatformLogger
1921
from wlsdeploy.tool.prepare.model_preparer import ModelPreparer
2022
from wlsdeploy.tool.util import model_context_helper
@@ -109,4 +111,9 @@ def main():
109111

110112
if __name__ == "__main__" or __name__ == 'main':
111113
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
112-
main()
114+
try:
115+
main()
116+
except exceptions.SystemExit, ex:
117+
raise ex
118+
except (exceptions.Exception, java.lang.Exception), ex:
119+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/update.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
The entry point for the updateDomain tool.
66
"""
7+
import exceptions
78
import os
89
import sys
910

@@ -309,4 +310,9 @@ def main(args):
309310

310311
if __name__ == '__main__' or __name__ == 'main':
311312
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
312-
main(sys.argv)
313+
try:
314+
main(sys.argv)
315+
except exceptions.SystemExit, ex:
316+
raise ex
317+
except (exceptions.Exception, java.lang.Exception), ex:
318+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

core/src/main/python/validate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
55
The WLS Deploy tooling entry point for the validateModel tool.
66
"""
7+
78
import copy
9+
import exceptions
810
import sys
11+
912
from java.util.logging import Level
1013

1114
from oracle.weblogic.deploy.logging import WLSDeployLogEndHandler
@@ -196,4 +199,9 @@ def main(args):
196199

197200
if __name__ == '__main__' or __name__ == 'main':
198201
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
199-
main(sys.argv)
202+
try:
203+
main(sys.argv)
204+
except exceptions.SystemExit, ex:
205+
raise ex
206+
except (exceptions.Exception, java.lang.Exception), ex:
207+
exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger)

0 commit comments

Comments
 (0)