Skip to content

Commit f3eba4b

Browse files
authored
Move all except clauses to the run_and_combine_outputs function
1 parent 663780d commit f3eba4b

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

jgo/jgo.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,38 @@ def launch_java(
197197
return subprocess.run((java, '-cp', cp) + jvm_args + (main_class,) + app_args, stdout=stdout, stderr=stderr, **subprocess_run_kwargs)
198198

199199
def run_and_combine_outputs(command, *args):
200-
try:
201-
return subprocess.check_output((command,) + args, stderr=subprocess.STDOUT)
202-
except subprocess.CalledProcessError as e:
203-
_logger.error("Error in `%s': %d", ' '.join(e.cmd), e.returncode)
204-
_logger.debug("Exception: %s", e)
205-
_logger.debug("Debug Trace:", exc_info=True)
206-
if e.stdout:
207-
_logger.debug("\tstd out:")
208-
for l in str(e.stdout).split('\\n'):
209-
_logger.debug('\t\t%s', l)
210-
if e.stderr:
211-
_logger.debug("\tstd err:")
212-
for l in str(e.stderr).split('\\n'):
213-
_logger.debug('\t\t%s', l)
214-
# parser.print_help(file=sys.stderr)
215-
sys.exit(e.returncode)
200+
try:
201+
return subprocess.check_output((command,) + args, stderr=subprocess.STDOUT)
202+
except subprocess.CalledProcessError as e:
203+
_logger.error("Error in `%s': %d", ' '.join(e.cmd), e.returncode)
204+
_logger.debug("Exception: %s", e)
205+
_logger.debug("Debug Trace:", exc_info=True)
206+
if e.stdout:
207+
_logger.debug("\tstd out:")
208+
for l in str(e.stdout).split('\\n'):
209+
_logger.debug('\t\t%s', l)
210+
if e.stderr:
211+
_logger.debug("\tstd err:")
212+
for l in str(e.stderr).split('\\n'):
213+
_logger.debug('\t\t%s', l)
214+
# parser.print_help(file=sys.stderr)
215+
sys.exit(e.returncode)
216+
217+
except NoMainClassInManifest as e:
218+
_logger.error(e)
219+
_logger.error("No main class given, and none found.")
220+
# parser.print_help(file=sys.stderr)
221+
sys.exit(1)
222+
223+
except HelpRequested as e:
224+
pass
225+
#parser.parse_known_args(e.argv)
226+
227+
except Exception as e:
228+
_logger.error(e)
229+
traceback.print_tb(e.__traceback__)
230+
parser.print_help(file=sys.stderr)
231+
sys.exit(1)
216232

217233
def find_endpoint(argv, shortcuts={}):
218234
# endpoint is first positional argument
@@ -271,21 +287,6 @@ def jgo_main(argv=sys.argv[1:], stdout=None, stderr=None):
271287
completed_process = run(parser, argv=argv, stdout=stdout, stderr=stderr)
272288
completed_process.check_returncode()
273289

274-
except NoMainClassInManifest as e:
275-
_logger.error(e)
276-
_logger.error("No main class given, and none found.")
277-
parser.print_help(file=sys.stderr)
278-
sys.exit(1)
279-
280-
except HelpRequested as e:
281-
parser.parse_known_args(e.argv)
282-
283-
except Exception as e:
284-
_logger.error(e)
285-
traceback.print_tb(e.__traceback__)
286-
parser.print_help(file=sys.stderr)
287-
sys.exit(1)
288-
289290

290291
def jgo_cache_dir_environment_variable():
291292
return 'JGO_CACHE_DIR'

0 commit comments

Comments
 (0)