diff --git a/clientgui/DlgItemProperties.cpp b/clientgui/DlgItemProperties.cpp index 74ad3a3546..c8c536bf51 100644 --- a/clientgui/DlgItemProperties.cpp +++ b/clientgui/DlgItemProperties.cpp @@ -198,7 +198,7 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { // CachedDiskUsageUpdate() may have invalidated our project // pointer, so get an updated pointer to this project PROJECT* project = pDoc->project(project_in->master_url); - if(!project) return; // TODO: display some sort of error alert? + if (!project) return; // TODO: display some sort of error alert? std::vector dp = pDoc->disk_usage.projects; double diskusage=0.0; @@ -206,9 +206,9 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { PROJECT* tp = dp[i]; std::string tname; tp->get_name(tname); - wxString t1(wxString(tname.c_str(),wxConvUTF8)); - if(t1.IsSameAs(wxString(projectname.c_str(),wxConvUTF8)) || t1.IsSameAs(wxString(project->master_url, wxConvUTF8))) { - diskusage =tp->disk_usage; + wxString t1(wxString(tname.c_str(), wxConvUTF8)); + if(t1.IsSameAs(wxString(projectname.c_str(), wxConvUTF8)) || t1.IsSameAs(wxString(project->master_url, wxConvUTF8))) { + diskusage = tp->disk_usage; break; } } @@ -218,10 +218,10 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { SetTitle(wxTitle); //layout controls addSection(_("General")); - addProperty(_("Master URL"),wxString(project->master_url, wxConvUTF8)); - addProperty(_("User name"),wxString(project->user_name.c_str(),wxConvUTF8)); - addProperty(_("Team name"),wxString(project->team_name.c_str(),wxConvUTF8)); - addProperty(_("Resource share"),wxString::Format(wxT("%0.0f"),project->resource_share)); + addProperty(_("Master URL"), wxString(project->master_url, wxConvUTF8)); + addProperty(_("User name"), wxString(project->user_name.c_str(), wxConvUTF8)); + addProperty(_("Team name"), wxString(project->team_name.c_str(), wxConvUTF8)); + addProperty(_("Resource share"), wxString::Format(wxT("%0.0f"), project->resource_share)); if (project->min_rpc_time > dtime()) { addProperty(_("Scheduler RPC deferred for"), FormatTime(project->min_rpc_time - dtime())); } @@ -231,13 +231,13 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { if (project->upload_backoff) { addProperty(_("File uploads deferred for"), FormatTime(project->upload_backoff)); } - addProperty(_("Disk usage"),FormatDiskSpace(diskusage)); + addProperty(_("Disk usage"), FormatDiskSpace(diskusage)); addProperty(_("Computer ID"), wxString::Format(wxT("%d"), project->hostid)); if (project->non_cpu_intensive) { addProperty(_("Non CPU intensive"), _("yes")); } - addProperty(_("Suspended via GUI"),project->suspended_via_gui ? _("yes") : _("no")); - addProperty(_("Don't request more work"),project->dont_request_more_work ? _("yes") : _("no")); + addProperty(_("Suspended via GUI"), project->suspended_via_gui ? _("yes") : _("no")); + addProperty(_("Don't request more work"), project->dont_request_more_work ? _("yes") : _("no")); if (project->scheduler_rpc_in_progress) { addProperty(_("Scheduler call in progress"), _("yes")); } @@ -277,7 +277,7 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { if (!project->non_cpu_intensive) { addSection(_("Scheduling")); - addProperty(_("Scheduling priority"),wxString::Format(wxT("%0.2f"), project->sched_priority)); + addProperty(_("Scheduling priority"), wxString::Format(wxT("%0.2f"), project->sched_priority)); show_rsc(_("CPU"), project->rsc_desc_cpu); if (pDoc->state.have_nvidia) { show_rsc(_("NVIDIA GPU"), project->rsc_desc_nvidia); @@ -285,7 +285,7 @@ void CDlgItemProperties::renderInfos(PROJECT* project_in) { if (pDoc->state.have_ati) { show_rsc(_("ATI GPU"), project->rsc_desc_ati); } - addProperty(_("Duration correction factor"),wxString::Format(wxT("%0.4f"), project->duration_correction_factor)); + addProperty(_("Duration correction factor"), wxString::Format(wxT("%0.4f"), project->duration_correction_factor)); } m_gbSizer->Layout(); m_scrolledWindow->FitInside(); @@ -309,7 +309,7 @@ void CDlgItemProperties::renderInfos(RESULT* result) { } addProperty(_("Application"), FormatApplicationName(result)); - addProperty(_("Workunit name"),wxString(result->wu_name, wxConvUTF8)); + addProperty(_("Workunit name"), wxString(result->wu_name, wxConvUTF8)); addProperty(_("State"), result_description(result, false)); if (result->received_time) { dt.Set((time_t)result->received_time); @@ -446,10 +446,10 @@ wxString CDlgItemProperties::FormatTime(float fBuffer) { // adds a title section label to the dialog void CDlgItemProperties::addSection(const wxString& title) { - wxStaticText* staticText = new wxStaticText( m_scrolledWindow, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0); - staticText->Wrap( -1 ); - staticText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - m_gbSizer->Add( staticText, wxGBPosition( m_current_row, 0 ), wxGBSpan( 1, 2 ), wxALL|wxEXPAND, 3); + wxStaticText* staticText = new wxStaticText(m_scrolledWindow, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0); + staticText->Wrap(-1); + staticText->SetFont(wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString)); + m_gbSizer->Add(staticText, wxGBPosition( m_current_row, 0), wxGBSpan(1, 2), wxALL|wxEXPAND, 3); m_current_row++; } diff --git a/html/user/tree_threader.php b/html/user/tree_threader.php index 707c60be02..d80b1adf52 100644 --- a/html/user/tree_threader.php +++ b/html/user/tree_threader.php @@ -3,7 +3,7 @@ // Handler for TreeThreader remote job submission. // // Assumptions: -// - there is a file "three_threader_templates" in the project root +// - there is a file "tree_threader_templates_files" in the project root // containing (one per line) the names of files containing // gzipped collections of template files // - These files are in the download hierarchy. @@ -24,22 +24,68 @@ function error($s) { exit; } -function handle_submit($r, $user) { - - $batch_id = BoincBatch::insert("(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, '$batch_name', $app->id, ".BATCH_STATE_IN_PROGRESS.")" +function handle_submit($r, $user, $app) { + // read the list of template filenames + // + $files = file("../../tree_threader_template_files"); + if ($files === false) error("no templates file"); + $njobs = sizeof($files); + $now = time(); + $batch_id = BoincBatch::insert( + "(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, 'test batch', $app->id, ".BATCH_STATE_IN_PROGRESS.")" ); + foreach ($files as $file) { + $cmd = "cd ../..; ./bin/create_work --appname tree_thread --batch $batch_id $file"; + $ret = system($cmd); + if ($ret === false) { + error("can't create job"); + } + } + echo "$batchid\n"; } -function handle_abort($r) { -} +// Enumerate all the successfully completed WUs for this batch. +// Combine their output files into a zip file in /tmp, +// make a symbolic link to this from /download, +// and return the resulting URL +// +function handle_get_output($r, $batch) { + $wus = BoincWorkUnit::enum("batchid=$batch->id"); + $outdir = "/tmp/tree_threader_".$batch->id; + 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; -function handle_status($r) { -} + // there's only one output file + // + $path = $paths[0]; -function handle_get_output($r) { -} + // unzip it into a directory in /tmp + // + $dir = tmpdir(); + $cmd = "cd $dir; unzip -r $path"; + $ret = system($cmd); + if ($ret === false) { + error("can't unzip output file"); + } + $cmd = "cp $dir/* $outdir"; + $ret = system($cmd); + if ($ret === false) { + error("can't copy output files"); + } -function handle_retire($r) { + } + $cmd = "cd /tmp ; zip -r $outdir $outdir"; + $ret = system($cmd); + if ($ret === false) { + error("can't zip output files"); + } + $fname = "tree_threader_".$batch_id.".zip"; + symlink($outdir, "../../download/$fname"); + echo "$fname"; } xml_header(); @@ -68,11 +114,14 @@ if (!$user_submit->submit_all) { } switch ($r->getName()) { - case 'submit': handle_submit($r, $user); break; - case 'abort': handle_abort($r); break; - case 'status': handle_status($r); break; - case 'get_output': handle_get_output($r); break; - case 'retire': handle_retire($r); break; + case 'submit': handle_submit($r, $user, $app); break; + case 'get_output': + $batch_id = (int)$r->batchid; + $batch = BoincBatch::lookup_id($batch_id); + if (!$batch) error("no such batch"); + if ($batch->user_id != $user->id) error("not owner of batch"); + handle_get_output($r, $batch); + break; default: error("bad command"); } diff --git a/tools/tree_threader_splitter.php b/tools/tree_threader_splitter.php new file mode 100644 index 0000000000..b42bc33898 --- /dev/null +++ b/tools/tree_threader_splitter.php @@ -0,0 +1,9 @@ +