Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
Release 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ShixiangWang committed Dec 17, 2019
1 parent 0d6e49e commit f6c7241
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 0.3.4
=============

- Fix a bug in `batch` command

Version 0.3.2-0.3.3
=============

Expand Down
2 changes: 1 addition & 1 deletion src/loon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import os

__version__ = "0.3.3"
__version__ = "0.3.4"
__author__ = "ShixiangWang"
__copyright__ = "ShixiangWang"
__license__ = "mit"
Expand Down
8 changes: 8 additions & 0 deletions src/loon/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ def parse_args(args):
type=argparse.FileType('r'),
default=sys.stdin,
nargs='?')
# parser_batch.add_argument(
# '-o',
# '--output',
# help=
# r'default is stdout, can be a file',
# type=argparse.FileType('w'),
# default=sys.stdout,
# nargs='?')
parser_batch.add_argument(
'-s',
'--sep',
Expand Down
47 changes: 34 additions & 13 deletions src/loon/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def prun(x):
y = run(x, shell=True)
y = run(x, shell=True, stdout=sys.stdout, stderr=sys.stderr)
return y


Expand Down Expand Up @@ -50,21 +50,42 @@ def batch(input,
_ = [print("=> Running %s" % cmd) for cmd in cmd_list]
sys.exit(0)

# There is a bug when input from stdin I cannot figure out for now
if thread > 1:
_logger.info("Using %s threads" % str(thread))
with Pool(thread) as p:
run_res = p.map(prun, cmd_list)
for index, res in enumerate(run_res):
_logger.info("Status code: " + str(res.returncode))
if res.returncode != 0:
print("Error: job %s failed, please check the info!." %
str(index))
with Pool(processes=thread) as p:
if isinstance(input, io.TextIOWrapper):
p.map(prun, cmd_list)
sys.exit(0)
else:
run_res = p.map(prun, cmd_list)
for _, res in enumerate(run_res):
if res.returncode != 0:
print("Error: some jobs failed, please take a check!.",
file=sys.stderr)
sys.exit(res.returncode)
else:
_logger.info("Using %s threads" % str(thread))
for cmd in cmd_list:
run_res = run(cmd, shell=True)
_logger.info("Status code: " + str(run_res.returncode))
if run_res.returncode != 0:
print("Error: some error occurred, please check the info!")
sys.exit(run_res.returncode)
if isinstance(input, io.TextIOWrapper):
run(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
else:
run_res = run(cmd,
shell=True,
stdout=sys.stdout,
stderr=sys.stderr)
_logger.info("Status code: " + str(run_res.returncode))
if run_res.returncode != 0:
print(
"Error: an error detected when running the following command, please take a check!",
file=sys.stderr)
print("\t", cmd, file=sys.stderr)
print("Status code: %s" % str(run_res.returncode),
file=sys.stderr)
print(
"Please don't run with --verbose, there is a known issue with it.",
file=sys.stderr)
sys.exit(run_res.returncode)
sys.exit(0)

return

0 comments on commit f6c7241

Please sign in to comment.