Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bug in Fido to allow download to path="./" #4058

Merged
merged 5 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4058.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes a bug in fido_factory to allow path="./" in fido.fetch().
3 changes: 2 additions & 1 deletion sunpy/net/fido_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def fetch(self, *query_results, path=None, max_conn=5, progress=True,

"""
if path is not None:
exists = list(filter(lambda p: p.exists(), Path(path).parents))
exists = list(filter(lambda p: p.exists(), Path(path).resolve().parents))

if not os.access(exists[0], os.W_OK):
raise PermissionError('You do not have permission to write'
f' to the directory {exists[0]}.')
Expand Down
10 changes: 10 additions & 0 deletions sunpy/net/tests/test_fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ def test_save_path_pathlib(tmpdir):
assert f"eve{os.path.sep}0" in f


@pytest.mark.remote_data
def test_save_path_cwd(tmpdir):
qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

# Test when path is ./ for current working directory
os.chdir(tmpdir) # move into temp directory
nabobalis marked this conversation as resolved.
Show resolved Hide resolved
files = Fido.fetch(qr, path="./")
dstansby marked this conversation as resolved.
Show resolved Hide resolved
for f in files:
assert pathlib.Path.cwd().joinpath(f).exists()

"""
Factory Tests
"""
Expand Down