date = $date; $this->download = $download; } /** * Execute the job. */ public function handle(): void { $command = [ sprintf('%srunpython.sh', base_path('../')), sprintf('--date=%s', $this->date->format('Y-m-d')), sprintf('--days=%d', $this->days), sprintf('--project_dir=%s', $this->download->project->download_path), ]; $process = new Process($command); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { logger('error', $process->getErrorOutput()); } logger($process->getOutput()); $this->download->setStatusSuccess(); } public static function handleForDate(Project $project, Carbon $date) { $filename = $date->format('Y-m-d') . '.tif'; if ($project->downloads()->statusSuccess()->where(['name' => $filename])->exists()) { return new NullJob(); } $path = $project->download_path . '/merged_final_tif/' . $filename; return new self( $project->downloads()->create([ 'name' => $filename, 'path' => $path, ]), $date ); } }