Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_download():
url = "https://raw.githubusercontent.com/wkentaro/gdown/3.1.0/gdown/__init__.py" # NOQA
output = "/tmp/gdown_r"
# Usage before https://github.com/wkentaro/gdown/pull/32
assert download(url, output, quiet=False) == output
os.remove(output)
)
args = parser.parse_args()
if args.output == "-":
if six.PY3:
args.output = sys.stdout.buffer
else:
args.output = sys.stdout
if args.id:
url = "https://drive.google.com/uc?id={id}".format(id=args.url_or_id)
else:
url = args.url_or_id
download(
url=url,
output=args.output,
quiet=args.quiet,
proxy=args.proxy,
speed=args.speed,
use_cookies=not args.no_cookies,
)
os.makedirs(osp.dirname(path))
except OSError:
pass
temp_root = tempfile.mkdtemp(dir=cache_root)
try:
temp_path = osp.join(temp_root, "dl")
if not quiet:
msg = "Cached Downloading"
if path:
msg = "{}: {}".format(msg, path)
else:
msg = "{}...".format(msg)
print(msg, file=sys.stderr)
download(url, temp_path, quiet=quiet, proxy=proxy, speed=speed)
with filelock.FileLock(lock_path):
shutil.move(temp_path, path)
except Exception:
shutil.rmtree(temp_root)
raise
if md5:
assert_md5sum(path, md5, quiet=quiet)
# postprocess
if postprocess is not None:
postprocess(path)
return path