Skip to content

Commit faa1710

Browse files
committed
fixing bugs with commands
1 parent 0c8d69b commit faa1710

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
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+
- fixing bugs with import, export, image commands (0.0.31)
2021
- adding tests for client (0.0.30)
2122
- bug in Dockerfile fromHeader variable fix (0.0.29)
2223
- Dockerfile from "as level" removed (0.0.28)

spython/main/base/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def init_level(self, quiet=False):
3636

3737

3838

39-
def println(self,output,quiet=False):
39+
def println(self, output, quiet=False):
4040
'''print will print the output, given that quiet is not True. This
4141
function also serves to convert output in bytes to utf-8
4242

spython/main/image/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def generate_image_commands():
3131
class ImageClient:
3232
group = "image"
3333

34+
from spython.main.base.logger import println
35+
from spython.main.base.command import ( init_command, run_command )
36+
3437
from .utils import ( compress, decompress )
3538
from .create import create
3639
from .importcmd import importcmd
@@ -41,6 +44,10 @@ class ImageClient:
4144
ImageClient.export = export
4245
ImageClient.decompress = decompress
4346
ImageClient.compress = compress
47+
48+
ImageClient.println = println
49+
ImageClient.init_command = init_command
50+
ImageClient.run_command = run_command
4451

4552
cli = ImageClient()
4653
return cli

spython/main/image/create.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def create(self,image_path, size=1024, sudo=False):
2929
filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3
3030
3131
'''
32-
self.check_install()
32+
from spython.utils import check_install
33+
check_install()
34+
35+
3336
cmd = self.init_command('image.create')
3437
cmd = cmd + ['--size', str(size), image_path ]
3538

@@ -40,5 +43,3 @@ def create(self,image_path, size=1024, sudo=False):
4043
bot.exit("Could not create image %s" %image_path)
4144

4245
return image_path
43-
44-

spython/main/image/export.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from spython.logger import bot
2121

22-
def export(self,image_path, tmptar=None):
22+
def export(self, image_path, tmptar=None):
2323
'''export will export an image, sudo must be used.
2424
2525
Parameters
@@ -29,10 +29,12 @@ def export(self,image_path, tmptar=None):
2929
tmptar: if defined, use custom temporary path for tar export
3030
3131
'''
32-
self.check_install()
32+
from spython.utils import check_install
33+
check_install()
3334

3435
if tmptar is None:
3536
tmptar = "/%s/tmptar.tar" %(tempfile.mkdtemp())
36-
cmd = ['singularity', 'image.export', '-f',tmptar, image_path]
37-
output = self.run_command(cmd,sudo=False)
37+
cmd = ['singularity', 'image.export', '-f', tmptar, image_path]
38+
39+
output = self.run_command(cmd, sudo=False)
3840
return tmptar

spython/main/image/importcmd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ def importcmd(self, image_path, input_source):
2929
import_type: if not specified, imports whatever function is given
3030
3131
'''
32-
self.check_install()
32+
from spython.utils import check_install
33+
check_install()
3334

34-
cmd = ['singularity','image.import',image_path,input_source]
35-
output = self.run_command(cmd,sudo=False)
35+
cmd = ['singularity', 'image.import', image_path, input_source]
36+
output = self.run_command(cmd, sudo=False)
3637
self.println(output)
3738
return image_path
3839

spython/main/image/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
from spython.logger import bot
2121

22-
23-
24-
def compress(self,image_path):
22+
def compress(self, image_path):
2523
'''compress will (properly) compress an image'''
2624
if os.path.exists(image_path):
2725
compressed_image = "%s.gz" %image_path
@@ -31,7 +29,7 @@ def compress(self,image_path):
3129
bot.exit("Cannot find image %s" %image_path)
3230

3331

34-
def decompress(self,image_path,quiet=True):
32+
def decompress(self, image_path, quiet=True):
3533
'''decompress will (properly) decompress an image'''
3634

3735
if not os.path.exists(image_path):

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.30"
21+
__version__ = "0.0.31"
2222
AUTHOR = 'Vanessa Sochat'
2323
AUTHOR_EMAIL = '[email protected]'
2424
NAME = 'spython'

0 commit comments

Comments
 (0)