def __init__(self, task_id, credentials, download_dir, listener): self.task_id = task_id self.credentials = credentials self.dir = download_dir self.listener = listener self.earth_engine_status = EarthEngineStatus(task_id=task_id, listener=self) self.drive_download = None self.current_step = None
def __init__(self, task_id, file_name, file_id, credentials, download_dir, listener): self.task_id = task_id self.file_id = file_id self.credentials = credentials self.dir = download_dir self.listener = listener self.earth_engine_status = EarthEngineStatus(task_id=task_id, listener=self) self.drive_download = DriveDownload(credentials=self.credentials, file_name=file_name, file_id=self.file_id, download_dir=self.dir, listener=self) self.post_process = PostProcess(file_name=file_name, download_dir=download_dir, listener=self) self.current_step = None
class Download(object): def __init__(self, task_id, file_name, file_id, credentials, download_dir, listener): self.task_id = task_id self.file_id = file_id self.credentials = credentials self.dir = download_dir self.listener = listener self.earth_engine_status = EarthEngineStatus(task_id=task_id, listener=self) self.drive_download = DriveDownload(credentials=self.credentials, file_name=file_name, file_id=self.file_id, download_dir=self.dir, listener=self) self.post_process = PostProcess(file_name=file_name, download_dir=download_dir, listener=self) self.current_step = None def update_status(self, status): self.listener.update_status(self.task_id, status) step = status['step'] if 'step' in status else None step_taken = step and self.current_step != step self.current_step = step if step_taken: if step == 'EXPORTED': self.earth_engine_status.stop() self.drive_download.start() elif step == 'DOWNLOADED': self.drive_download.stop() self.post_process.start() if status['state'] != 'ACTIVE': self.stop() def cancel(self): if self.earth_engine_status: self.earth_engine_status.cancel() if self.drive_download: self.drive_download.cancel() if self.post_process: self.post_process.cancel() self.stop() def stop(self): logging.debug('Stopping download of task ' + self.task_id) if self.earth_engine_status: self.earth_engine_status.stop() self.earth_engine_status = None if self.drive_download: self.drive_download.stop() self.drive_download = None if self.post_process: self.post_process.stop() self.post_process = None
class Download(object): def __init__(self, task_id, credentials, download_dir, listener): self.task_id = task_id self.credentials = credentials self.dir = download_dir self.listener = listener self.earth_engine_status = EarthEngineStatus(task_id=task_id, listener=self) self.drive_download = None self.current_step = None def update_status(self, status): step = status['step'] if 'step' in status else None completed_export = step and step == 'EXPORTED' and self.current_step != step self.current_step = step if completed_export: self.earth_engine_status.stop() self._begin_download(status['path']) self.listener.update_status(self.task_id, status) if status['state'] != 'ACTIVE': self.stop() def cancel(self): if self.earth_engine_status: self.earth_engine_status.cancel() if self.drive_download: self.drive_download.cancel() self.stop() def stop(self): logging.debug('Stopping download of task ' + self.task_id) if self.earth_engine_status: self.earth_engine_status.stop() self.earth_engine_status = None if self.drive_download: self.drive_download.stop() self.drive_download = None def _begin_download(self, path): self.drive_download = DriveDownload( credentials=self.credentials, path=path, download_dir=self.dir, listener=self)