コード例 #1
0
ファイル: helioviewer.py プロジェクト: tsarjak/sunpy
    def _get_file(self, params, directory=None, overwrite=False):
        """Downloads a file and return the filepath to that file"""
        # Query Helioviewer.org
        if directory is None:
            directory = sunpy.config.get('downloads', 'download_dir')
        else:
            directory = os.path.abspath(os.path.expanduser(directory))

        response = self._request(params)
        try:
            filepath = download_fileobj(response, directory, overwrite=overwrite)
        finally:
            response.close()

        return filepath
コード例 #2
0
ファイル: helioviewer.py プロジェクト: drewleonard42/sunpy
    def _get_file(self, params, directory=None, overwrite=False):
        """Downloads a file and return the filepath to that file."""
        if directory is None:
            directory = sunpy.config.get('downloads', 'download_dir')
        else:
            directory = os.path.abspath(os.path.expanduser(directory))

        try:
            os.makedirs(directory)
        except OSError as e:
            # TODO: Check this
            if e.errno != errno.EEXIST:
                raise OSError('Tried to create a directory and it failed.')

        response = self._request(params)
        try:
            filepath = download_fileobj(response, directory, overwrite=overwrite)
        finally:
            response.close()

        return filepath
コード例 #3
0
    def _get_file(self, params, directory=None, overwrite=False):
        """Downloads a file and return the filepath to that file."""
        if directory is None:
            directory = sunpy.config.get('downloads', 'download_dir')
        else:
            directory = os.path.abspath(os.path.expanduser(directory))

        try:
            os.makedirs(directory)
        except OSError as e:
            # TODO: Check this
            if e.errno != errno.EEXIST:
                raise OSError('Tried to create a directory and it failed.')

        response = self._request(params)
        try:
            filepath = download_fileobj(response,
                                        directory,
                                        overwrite=overwrite)
        finally:
            response.close()

        return filepath