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
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
def shell(self, cmd): from bioconvert.core.shell import shell _log.info("CMD: {}".format(cmd)) shell(cmd)
def test_shell(): shell("ls")