Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
singularity on pypi), and the versions here will coincide with these releases.

## [master](https://github.com/singularityhub/singularity-cli/tree/master)
- adding more verbosity to running commands (0.1.11)
- log error paths are optional (0.1.1)
- instance list doesn't always include container_image (0.1.0)
- add sudo_options option to Instance.start/stop and Client.execute (0.0.85)
Expand Down
4 changes: 4 additions & 0 deletions spython/main/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def build(

cmd = cmd + options + [image, recipe]

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

if not stream:
self._run_command(
cmd,
Expand Down
11 changes: 11 additions & 0 deletions spython/main/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def execute(
nv: if True, load Nvidia Drivers in runtime (default False)
return_result: if True, return entire json object with return code
and message result not (default)
quiet: Do not print verbose output.
environ: extra environment to add.
"""
from spython.utils import check_install

Expand Down Expand Up @@ -99,6 +101,10 @@ def execute(

cmd = cmd + [image] + command

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

if not stream:
return self._run_command(
cmd,
Expand All @@ -124,6 +130,7 @@ def shell(
options=None,
singularity_options=None,
sudo=False,
quiet=True,
):
"""shell into a container. A user is advised to use singularity to do
this directly, however this function is useful for supporting tools.
Expand Down Expand Up @@ -172,6 +179,10 @@ def shell(
cmd.append(image)
singularity = which("singularity")

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

if writable or sudo:
os.execvp("sudo", ["sudo"] + cmd)

Expand Down
5 changes: 5 additions & 0 deletions spython/main/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def inspect(
cmd.append("--json")

cmd.append(image)

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

result = run_command(cmd, quiet=quiet)

if result["return_code"] == 0:
Expand Down
9 changes: 9 additions & 0 deletions spython/main/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def list_instances(
if name is not None:
cmd.append(name)

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

output = run_command(cmd, quiet=True, sudo=sudo, sudo_options=sudo_options)
instances = []

Expand Down Expand Up @@ -126,6 +130,11 @@ def stopall(self, sudo=False, quiet=True, singularity_options=None):

cmd = self._init_command(subgroup, singularity_options)
cmd = cmd + ["--all"]

# Does the user want to see the command printed?
if not (quiet or self.quiet):
bot.info(" ".join(cmd))

output = run_command(cmd, sudo=sudo, quiet=quiet)

if output["return_code"] != 0:
Expand Down
9 changes: 8 additions & 1 deletion spython/main/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def run(
options=None,
singularity_options=None,
return_result=False,
quiet=False,
):
"""
run will run the container, with or withour arguments (which
Expand All @@ -46,14 +47,17 @@ def run(
nv: if True, load Nvidia Drivers in runtime (default False)
return_result: if True, return entire json object with return code
and message result (default is False)

quiet: print the command to the user
"""
from spython.utils import check_install

check_install()

cmd = self._init_command("run", singularity_options)

# Does the user want to see the command printed?
quiet = quiet or self.quiet

# nv option leverages any GPU cards
if nv:
cmd += ["--nv"]
Expand Down Expand Up @@ -93,6 +97,9 @@ def run(
args = args.split(" ")
cmd = cmd + args

if not quiet:
bot.info(" ".join(cmd))

if not stream:
result = self._run_command(cmd, sudo=sudo, return_result=return_result)
else:
Expand Down
4 changes: 2 additions & 2 deletions spython/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.


__version__ = "0.1.1"
__version__ = "0.1.11"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsochat@stanford.edu"
NAME = "spython"
PACKAGE_URL = "http://www.github.com/singularityhub/singularity-cli"
PACKAGE_URL = "https://github.com/singularityhub/singularity-cli"
KEYWORDS = "singularity python client (spython)"
DESCRIPTION = "Command line python tool for working with singularity."
LICENSE = "LICENSE"
Expand Down