Skip to content

Commit 0b1dc75

Browse files
authored
Merge pull request #34 from vsoch/run_command/quiet
removing unecessary printing for inspect
2 parents d6d0c04 + 83ac912 commit 0b1dc75

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
1717
singularity on pypi), and the versions here will coincide with these releases.
1818

1919
## [master](https://github.com/singularityhub/singularity-cli/tree/master)
20+
- respecting Client "quiet" attribute in run_command (0.0.34)
2021
- adding missing import of tempfile in image.export (0.0.33)
2122
- bug with Client.version() (0.0.32)
2223
- fixing bugs with import, export, image commands (0.0.31)

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,

spython/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020

21-
__version__ = "0.0.33"
21+
__version__ = "0.0.34"
2222
AUTHOR = 'Vanessa Sochat'
2323
AUTHOR_EMAIL = '[email protected]'
2424
NAME = 'spython'

0 commit comments

Comments
 (0)