function handle_get_output($r, $batch) { global $log; $timestamp = date("Y-m-d H:i", time()); $wus = BoincWorkUnit::enum("batch={$batch->id}"); $outdir = "/tmp/treeThreader_result_" . $batch->id; @mkdir($outdir); foreach ($wus as $wu) { if (!$wu->canonical_resultid) { continue; } $result = BoincResult::lookup_id($wu->canonical_resultid); if (!$result) { continue; } $paths = get_outfile_paths($result); if (sizeof($paths) < 1) { continue; } // there's only one output file // $path = $paths[0]; // unzip it into a directory in /tmp // $dir = "/tmp/{$wu->name}"; @mkdir($dir); $cmd = "cd {$dir}; unzip -q {$path}"; system($cmd, $ret); if ($ret != 0) { error("can't unzip output file"); } $cmd = "cp {$dir}/Aln/* {$outdir}"; system($cmd, $ret); if ($ret != 0) { error("can't copy output files"); } system("rm -rf {$dir}"); } $cmd = "zip -r -q {$outdir} {$outdir}"; system($cmd, $ret); if ($ret != $ret) { error("can't zip output files"); } $fname = "treeThreader_result_" . $batch->id . ".zip"; $treeThreader_dir = "treeThreaderResult"; if (!is_dir("../../download/{$treeThreader_dir}")) { mkdir("../../download/{$treeThreader_dir}"); } @symlink("/tmp/{$fname}", "../../download/{$treeThreader_dir}/{$fname}"); system("rm -fr {$outdir}"); $config = simplexml_load_string(file_get_contents("../../config.xml")); $download_url = trim((string) $config->config->download_url); echo "<tt_reply>\n<url>{$download_url}/{$treeThreader_dir}/{$fname}</url>\n</tt_reply>\n"; $log_msg = "{$timestamp}\tuser {$batch->user_id} downloads results for batch {$batch->id} : {$download_url}/{$treeThreader_dir}/{$fname}\n"; fwrite($log, $log_msg); }
function handle_get_output($r, $batch) { $wus = BoincWorkUnit::enum("batch={$batch->id}"); $outdir = "/tmp/tree_threader_output_" . $batch->id; @mkdir($outdir); foreach ($wus as $wu) { if (!$wu->canonical_resultid) { continue; } $result = BoincResult::lookup_id($wu->canonical_resultid); if (!$result) { continue; } $paths = get_outfile_paths($result); if (sizeof($paths) < 1) { continue; } // there's only one output file // $path = $paths[0]; // unzip it into a directory in /tmp // $dir = "/tmp/{$wu->name}"; @mkdir($dir); $cmd = "cd {$dir}; unzip -q {$path}"; $ret = system($cmd); if ($ret === false) { error("can't unzip output file"); } $cmd = "cp {$dir}/ali/* {$outdir}"; $ret = system($cmd); if ($ret === false) { error("can't copy output files"); } //system("rm -rf $dir"); } $cmd = "zip -r -q {$outdir} {$outdir}"; $ret = system($cmd); if ($ret === false) { error("can't zip output files"); } $fname = "tree_threader_output_" . $batch->id . ".zip"; @symlink($outdir, "../../download/{$fname}"); $config = simplexml_load_string(file_get_contents("../../config.xml")); $download_url = trim((string) $config->config->download_url); echo "<tt_reply>\n<url>{$download_url}/{$fname}</url>\n</tt_reply>\n"; }