Repository: iterative/dvc

Issue:
Problems when downloading file from s3
DVC version 0.66.1, pip, windows
```
C:\Users\Павел\PycharmProjects\musket_core>dvc get-url  s3://mybucket/data.txt ./data.txt
ERROR: unexpected error - 'NoneType' object has no attribute 'wdir'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
```

Regards,
Pavel

Discussion:

Patch:
diff --git a/dvc/output/local.py b/dvc/output/local.py
index 777ac3756..cbd9c9503 100644
--- a/dvc/output/local.py
+++ b/dvc/output/local.py
@@ -26,7 +26,7 @@ class OutputLOCAL(OutputBase):
             # so we should expect both posix and windows style paths.
             # PathInfo accepts both, i.e. / works everywhere, \ only on win.
             #
-            # FIXME: if we have Windows path containig / or posix one with \
+            # FIXME: if we have Windows path containing / or posix one with \
             # then we have #2059 bug and can't really handle that.
             p = self.REMOTE.path_cls(path)
             if not p.is_absolute():
diff --git a/dvc/repo/get_url.py b/dvc/repo/get_url.py
index ff191e149..8ba187865 100644
--- a/dvc/repo/get_url.py
+++ b/dvc/repo/get_url.py
@@ -12,7 +12,8 @@ def get_url(url, out=None):
 
     if os.path.exists(url):
         url = os.path.abspath(url)
-        out = os.path.abspath(out)
+
+    out = os.path.abspath(out)
 
     dep, = dependency.loads_from(None, [url])
     out, = output.loads_from(None, [out], use_cache=False)


Test patch:
diff --git a/tests/func/test_get_url.py b/tests/func/test_get_url.py
index eae2b556e..fab7a4db6 100644
--- a/tests/func/test_get_url.py
+++ b/tests/func/test_get_url.py
@@ -1,13 +1,19 @@
 from __future__ import unicode_literals
 
 import os
+import boto3
 import filecmp
 
 import pytest
 
+from moto import mock_s3
+
+from dvc.remote import RemoteS3
 from dvc.repo import Repo
 from dvc.utils import makedirs
 
+from tests.func.test_data_cloud import get_aws_url
+
 
 def test_get_file(repo_dir):
     src = repo_dir.FOO
@@ -32,3 +38,27 @@ def test_get_url_to_dir(dname, repo_dir):
 
     assert os.path.isdir(dname)
     assert filecmp.cmp(repo_dir.DATA, dst, shallow=False)
+
+
+@mock_s3
+@pytest.mark.parametrize("dst", [".", "./from"])
+def test_get_url_from_non_local_path_to_dir_and_file(repo_dir, dst):
+    file_name = "from"
+    file_content = "data"
+    base_info = RemoteS3.path_cls(get_aws_url())
+    from_info = base_info / file_name
+
+    s3 = boto3.client("s3")
+    s3.create_bucket(Bucket=from_info.bucket)
+    s3.put_object(
+        Bucket=from_info.bucket, Key=from_info.path, Body=file_content
+    )
+
+    Repo.get_url(from_info.url, dst)
+
+    result_path = os.path.join(dst, file_name) if os.path.isdir(dst) else dst
+
+    assert os.path.exists(result_path)
+    assert os.path.isfile(result_path)
+    with open(result_path, "r") as fd:
+        assert fd.read() == file_content