コード例 #1
0
ファイル: downloader.py プロジェクト: zhaotao1987/bioconvert
def download_singularity_image(outfile,
                               container_path,
                               md5value=None,
                               force=False):

    assert outfile.endswith(".simg"), "output filename must be .simg"

    # download singularity
    from bioconvert import configuration as config
    # note that in singularity v2.4, whatever extension you put, it is
    # replaced by simg
    singfile = "{}/{}".format(config.user_config_dir, outfile)

    if exists(singfile) and md5value and md5(
            singfile) == md5value and force is False:
        print("Found singularity (graphviz) image")
    elif exists(singfile) and md5value is None and force is False:
        print("Found singularity (graphviz) image but md5 not checked")
    else:
        print("Downloading singularity. Please wait")
        cmd = "singularity pull --name {}  {}"
        if force is True:
            cmd += " -F "
        cmd = cmd.format(singfile, container_path)
        print(cmd)
        try:
            from bioconvert.core.shell import shell
            shell(cmd)
        except:
            import os
            os.system(cmd)
    return singfile
コード例 #2
0
    def shell(self, cmd):
        from bioconvert.core.shell import shell
        t1 = time.time()
        _log.info("{}> ".format(self.name))
        _log.info("CMD: {}".format(cmd))

        shell(cmd)

        t2 = time.time()
        self.last_duration = t2 - t1
        _log.info("Took {} seconds ".format(t2 - t1))
        self._last_time = t2 - t1
コード例 #3
0
ファイル: base.py プロジェクト: zhaotao1987/bioconvert
 def shell(self, cmd):
     from bioconvert.core.shell import shell
     _log.info("CMD: {}".format(cmd))
     shell(cmd)
コード例 #4
0
ファイル: test_shell.py プロジェクト: zhaotao1987/bioconvert
def test_shell():
    shell("ls")