Source code for schrodinger.job.download

"""
Manage downloading jobs.
"""
from schrodinger.infra import jobhub
from schrodinger.Qt import QtCore
from schrodinger.utils import qt_utils


[docs]def download_job(job_id: str) -> str: """ Use Qt evented code to download job if this is running itself from a QThread. Returns a error string if the download fails. """ error = "" job_downloader = jobhub.JobDownloader(job_id) event_loop = qt_utils.EventLoop() def download_finished(output): nonlocal error error = output _download_finished_slot_noop() event_loop.quit() assert job_downloader.downloadFinished.connect(download_finished) QtCore.QTimer.singleShot(0, job_downloader.download) event_loop.exec() return error
def _download_finished_slot_noop(): # This does nothing but is called in the download_finished slot. # We define this to make unit testing easier. pass