Skip to content

Commit 2d5d136

Browse files
committed
dsqa for non-interactive, fixes #8
1 parent 261cc02 commit 2d5d136

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dSQ.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111
import re
1212

13-
__version__ = 0.95
13+
__version__ = 0.96
1414

1515
def safe_fill(text, wrap_width):
1616
if sys.__stdin__.isatty():

dSQAutopsy.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,31 @@
55
from textwrap import fill
66
from subprocess import check_output
77

8-
__version__ = 0.95
8+
__version__ = 0.96
9+
10+
11+
def safe_fill(text, wrap_width):
12+
if sys.__stdin__.isatty():
13+
return fill(text, wrap_width)
14+
else:
15+
return text
916

1017
# get terminal columns for wrapping
11-
term_rows, term_columns = [int(x) for x in check_output(["stty", "size"]).split()]
12-
if term_columns < 25:
18+
# Check if dSQ is being run interactively
19+
if sys.__stdin__.isatty():
20+
# get terminal columns for wrapping
21+
term_rows, term_columns = [int(x) for x in check_output(["stty", "size"]).split()]
22+
if term_columns < 25:
1323
term_columns = 25
24+
else:
25+
term_columns = 25
1426

1527
desc = """Dead Simple Queue Autopsy v{}
1628
https://github.com/ycrc/dSQ
1729
A helper script for analyzing the success state of your jobs after a dSQ run has completed. Specify the job file and the job_jobid_status.tsv file generated by the dSQ job and dSQAutopsy will print the jobs that didn't run or completed with non-zero exit codes. It will also report count of each to stderr.
1830
1931
""".format(__version__)
20-
"\n".join([fill(x, term_columns-1) for x in str.splitlines(desc)])
32+
"\n".join([safe_fill(x, term_columns-1) for x in str.splitlines(desc)])
2133

2234
# argument parsing
2335
parser = argparse.ArgumentParser(description=desc,

0 commit comments

Comments
 (0)