Skip to content

Commit 94375a8

Browse files
committed
removing unecessary printing for inspect
1 parent d6d0c04 commit 94375a8

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

spython/main/base/command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ def run_command(self, cmd, sudo=False, quiet=False, capture=True):
109109
cmd: the command to run
110110
sudo: does the command require sudo?
111111
On success, returns result. Otherwise, exists on error
112-
113-
'''
112+
quiet: suppress printing to the console
114113
115-
result = run_cmd(cmd, sudo=sudo, capture=capture)
114+
'''
115+
result = run_cmd(cmd, sudo=sudo, capture=capture, quiet=quiet)
116116
message = result['message']
117117
return_code = result['return_code']
118118

spython/main/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ def inspect(self,image=None, json=True, app=None):
4747
cmd.append('--json')
4848

4949
cmd.append(image)
50-
output = self._run_command(cmd)
50+
output = self._run_command(cmd, quiet=self.quiet)
5151
#self.println(output,quiet=self.quiet)
5252
return output

spython/utils/terminal.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def check_install(software='singularity', quiet=True):
4343
found = False
4444

4545
try:
46-
version = run_command(cmd)
46+
version = run_command(cmd, quiet=True)
4747
except: # FileNotFoundError
4848
return found
4949

@@ -95,7 +95,7 @@ def stream_command(cmd, no_newline_regexp="Progess", sudo=False):
9595
raise subprocess.CalledProcessError(return_code, cmd)
9696

9797

98-
def run_command(cmd, sudo=False, capture=True, no_newline_regexp="Progess"):
98+
def run_command(cmd, sudo=False, capture=True, no_newline_regexp="Progess", quiet=False):
9999
'''run_command uses subprocess to send a command to the terminal. If
100100
capture is True, we use the parent stdout, so the progress bar (and
101101
other commands of interest) are piped to the user. This means we
@@ -132,10 +132,13 @@ def run_command(cmd, sudo=False, capture=True, no_newline_regexp="Progess"):
132132
line = line.decode('utf-8')
133133
lines = lines + (line,)
134134
if re.search(no_newline_regexp, line) and found_match is True:
135-
sys.stdout.write(line)
135+
if quiet is False:
136+
sys.stdout.write(line)
136137
found_match = True
137138
else:
138-
print(line.rstrip())
139+
if quiet is False:
140+
sys.stdout.write(line)
141+
print(line.rstrip())
139142
found_match = False
140143

141144
output = {'message': lines,

0 commit comments

Comments
 (0)