0bc1db58d82c2482bfac1e32a3a43cfd5a533da2,utils/google_utils.py,,gdrive_download,#Any#Any#,50

Before Change


    // Attempt file download
    out = "NUL" if platform.system() == "Windows" else "/dev/null"
    os.system("curl -c ./cookie -s -L "drive.google.com/uc?export=download&id=%s" > %s " % (id, out))
    if os.path.exists("cookie"):  // large file
        s = "curl -Lb ./cookie "drive.google.com/uc?export=download&confirm=%s&id=%s" -o %s" % (get_token(), id, name)
    else:  // small file
        s = "curl -s -L -o %s "drive.google.com/uc?export=download&id=%s"" % (name, id)
    r = os.system(s)  // execute, capture return
    os.remove("cookie") if os.path.exists("cookie") else None

    // Error check

After Change


def gdrive_download(id="16TiPfZj7htmTyhntwcZyEEAejOUxuT6m", file="tmp.zip"):
    // Downloads a file from Google Drive. from yolov3.utils.google_utils import *; gdrive_download()
    t = time.time()
    file = Path(file)
    cookie = Path("cookie")  // gdrive cookie
    print(f"Downloading https://drive.google.com/uc?export=download&id={id} as {file}... ", end="")
    file.unlink(missing_ok=True)  // remove existing file
    cookie.unlink(missing_ok=True)  // remove existing cookie

    // Attempt file download
    out = "NUL" if platform.system() == "Windows" else "/dev/null"
    os.system(f"curl -c ./cookie -s -L "drive.google.com/uc?export=download&id={id}" > {out}")
    if os.path.exists("cookie"):  // large file
        s = f"curl -Lb ./cookie "drive.google.com/uc?export=download&confirm={get_token()}&id={id}" -o {file}"
    else:  // small file
        s = f"curl -s -L -o {file} "drive.google.com/uc?export=download&id={id}""
    r = os.system(s)  // execute, capture return
    cookie.unlink(missing_ok=True)  // remove existing cookie

    // Error check
    if r != 0:
        file.unlink(missing_ok=True)  // remove partial
        print("Download error ")  // raise Exception("Download error")
        return r

    // Unzip if archive
    if file.suffix == ".zip":
        print("unzipping... ", end="")
        os.system(f"unzip -q {file}")  // unzip
        file.unlink()  // remove zip to free space

    print(f"Done ({time.time() - t:.1f}s)")
    return r
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: ultralytics/yolov3
Commit Name: 0bc1db58d82c2482bfac1e32a3a43cfd5a533da2
Time: 2021-01-10
Author: glenn.jocher@ultralytics.com
File Name: utils/google_utils.py
Class Name:
Method Name: gdrive_download


Project Name: explosion/thinc
Commit Name: 7ee43f4346812c46b8df43c8cdf7a3016958949c
Time: 2020-01-15
Author: ines@ines.io
File Name: setup.py
Class Name:
Method Name: clean


Project Name: deepmipt/DeepPavlov
Commit Name: 7d7c9cfcb200722f256f67337a6a6a827e7b4540
Time: 2019-08-08
Author: ignatov.fedor@gmail.com
File Name: deeppavlov/utils/socket/socket.py
Class Name: SocketServer
Method Name: __init__