How to use the dax.errors.AutoSpiderError function in dax

To help you get started, we’ve selected a few dax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VUIIS / dax / dax / spiders.py View on Github external
def download_xnat_file(self, src, dst):
        """Download XNAT specific file."""
        results = None
        with XnatUtils.get_interface(host=self.host, user=self.user,
                                     pwd=self.pwd) as xnat:
            try:
                _res, _file = src.split('/files/')
                res = xnat.select(_res)
                if not res.exists():
                    msg = 'resources specified by %s not found on XNAT.'
                    raise AutoSpiderError(msg % src)
            except Exception:
                msg = 'resources can not be checked because the path given is \
wrong for XNAT. Please check https://wiki.xnat.org/display/XNAT16/\
XNAT+REST+API+Directory for the path.'
                raise AutoSpiderError(msg % src)
            try:
                results = res.file(_file).get(dst)
            except Exception:
                raise AutoSpiderError('downloading files from XNAT failed.')

        return results
github VUIIS / dax / dax / spiders.py View on Github external
pwd=self.pwd) as xnat:
            try:
                _res, _file = src.split('/files/')
                res = xnat.select(_res)
                if not res.exists():
                    msg = 'resources specified by %s not found on XNAT.'
                    raise AutoSpiderError(msg % src)
            except Exception:
                msg = 'resources can not be checked because the path given is \
wrong for XNAT. Please check https://wiki.xnat.org/display/XNAT16/\
XNAT+REST+API+Directory for the path.'
                raise AutoSpiderError(msg % src)
            try:
                results = res.file(_file).get(dst)
            except Exception:
                raise AutoSpiderError('downloading files from XNAT failed.')

        return results
github VUIIS / dax / dax / spiders.py View on Github external
except Exception:
                msg = 'resources can not be checked because the path given is \
wrong for XNAT: %s. Please check https://wiki.xnat.org/display/XNAT16/\
XNAT+REST+API+Directory for the path.'
                raise AutoSpiderError(msg % src)

            try:
                # res.get(dst, extract=True)
                results = XnatUtils.download_files_from_obj(dst, res)
                if len(results) == 1:
                    return results[0]
                else:
                    return results
            except Exception as err:
                print(err)
                raise AutoSpiderError('downloading resource from XNAT failed.')

        return results
github VUIIS / dax / dax / spiders.py View on Github external
def download_xnat_resource(self, src, dst):
        """Download XNAT complete resource."""
        results = None
        with XnatUtils.get_interface(host=self.host, user=self.user,
                                     pwd=self.pwd) as xnat:
            try:
                res = xnat.select(src)
                if not res.exists():
                    msg = 'resources specified by %s not found on XNAT.'
                    raise AutoSpiderError(msg % src)
            except Exception:
                msg = 'resources can not be checked because the path given is \
wrong for XNAT: %s. Please check https://wiki.xnat.org/display/XNAT16/\
XNAT+REST+API+Directory for the path.'
                raise AutoSpiderError(msg % src)

            try:
                # res.get(dst, extract=True)
                results = XnatUtils.download_files_from_obj(dst, res)
                if len(results) == 1:
                    return results[0]
                else:
                    return results
            except Exception as err:
                print(err)
                raise AutoSpiderError('downloading resource from XNAT failed.')

        return results
github VUIIS / dax / dax / spiders.py View on Github external
# Write the script
        with open(filepath, 'w') as f:
            f.write(template.substitute(self.run_inputs))

        if not self.exe_lang:
            if self.template.startswith('#PYTHON'):
                self.exe_lang = 'python'
            elif self.template.startswith('%MATLAB'):
                self.exe_lang = 'matlab'
            elif self.template.startswith('#RUBY'):
                self.exe_lang = 'ruby'
            elif self.template.startswith('#BASH'):
                self.exe_lang = 'bash'
            else:
                raise AutoSpiderError('Template Unknown. Please add #BASH/\
#PYTHON/#RUBY/#MATLAB at the beginning of the call file and rerun \
GeneratorAutoSpider.')

        self.succeeded = run_cmd(self.exe_lang, filepath,
                                 time_writer=self.time_writer,
                                 matlab_bin=self.matlab_bin)