Commit ca7a47e6 authored by Rom Walton's avatar Rom Walton
Browse files

Merge branch 'master' of https://github.com/BOINC/boinc

parents 5cc2e121 6708cb2f
......@@ -15,6 +15,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#include <math.h>
#include "parse.h"
#include "client_msgs.h"
......@@ -322,6 +324,10 @@ int RESULT::write(MIOFILE& out, bool to_server) {
#ifndef SIM
static const char* cpu_string(double ncpus) {
return (ncpus==1)?"CPU":"CPUs";
}
int RESULT::write_gui(MIOFILE& out) {
out.printf(
"<result>\n"
......@@ -378,24 +384,31 @@ int RESULT::write_gui(MIOFILE& out) {
if (avp->gpu_usage.rsc_type) {
if (avp->gpu_usage.usage == 1) {
sprintf(resources,
"%.3g CPUs + 1 %s",
"%.3g %s + 1 %s",
avp->avg_ncpus,
cpu_string(avp->avg_ncpus),
rsc_name_long(avp->gpu_usage.rsc_type)
);
} else {
sprintf(resources,
"%.3g CPUs + %.3g %ss",
"%.3g %s + %.3g %ss",
avp->avg_ncpus,
cpu_string(avp->avg_ncpus),
avp->gpu_usage.usage,
rsc_name_long(avp->gpu_usage.rsc_type)
);
}
} else if (avp->missing_coproc) {
sprintf(resources, "%.3g CPUs + %s GPU (missing)",
avp->avg_ncpus, avp->missing_coproc_name
sprintf(resources, "%.3g %s + %s GPU (missing)",
avp->avg_ncpus,
cpu_string(avp->avg_ncpus),
avp->missing_coproc_name
);
} else if (!project->non_cpu_intensive && (avp->avg_ncpus != 1)) {
sprintf(resources, "%.3g CPUs", avp->avg_ncpus);
sprintf(resources, "%.3g %s",
avp->avg_ncpus,
cpu_string(avp->avg_ncpus)
);
} else {
strcpy(resources, " ");
}
......@@ -407,9 +420,20 @@ int RESULT::write_gui(MIOFILE& out) {
if (avp->gpu_usage.rsc_type) {
COPROC& cp = coprocs.coprocs[avp->gpu_usage.rsc_type];
if (cp.count > 1) {
sprintf(buf, " (device %d)",
cp.device_nums[coproc_indices[0]]
);
// if there are multiple GPUs of this type,
// show the user which one(s) are being used
//
int n = (int)ceil(avp->gpu_usage.usage);
strcpy(buf, n>1?" (devices ":" (device ");
for (int i=0; i<n; i++) {
char buf2[256];
sprintf(buf2, "%d", cp.device_nums[coproc_indices[i]]);
if (i > 0) {
strcat(buf, ", ");
}
strcat(buf, buf2);
}
strcat(buf, ")");
}
}
}
......
......@@ -313,7 +313,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"), format_number(project->sched_priority, 2));
show_rsc(_("CPU"), project->rsc_desc_cpu);
if (pDoc->state.host_info.coprocs.have_nvidia()) {
show_rsc(
......
......@@ -1125,8 +1125,8 @@ void CViewProjects::GetDocResourcePercent(wxInt32 item, double& fBuffer) const {
}
wxInt32 CViewProjects::FormatResourceShare(double fBuffer, double fBufferPercent, wxString& strBuffer) const {
strBuffer.Printf(wxT("%0.0f (%0.2f%%)"), fBuffer, fBufferPercent);
wxInt32 CViewProjects::FormatResourceShare(double share, double share_pct, wxString& strBuffer) const {
strBuffer.Printf(wxT("%s (%s%%)"), format_number(share, 0), format_number(share_pct, 2));
return 0;
}
......
......@@ -1223,17 +1223,14 @@ AC_SUBST(CLIENTLIBS)
## --------------------
## some more tweaking to turn non-standard libs into statically linked ones
if test "${enable_debug}" = yes; then
if test "${enable_debug}" = "yes" ; then
CLIENTGUIFLAGS="${CLIENTGUIFLAGS} -D_DEBUG -DDEBUG"
fi
AC_ARG_ENABLE(wx-debug,
AS_HELP_STRING([--enable-wx-debug],
[ use wxWidgets debug libraries ]),
[enable_wx_debug="yes"
AC_DEFINE(USE_WX_DEBUG,[1],[Define to 1 to use the wxWidgets debug libraries])
],
[enable_wx_debug="no"])
# disable wxWidgets debug support which is by default enabled since 2.9.1
if test "${enable_wx_debug}" = "no" ; then
CLIENTGUIFLAGS="${CLIENTGUIFLAGS} -DNDEBUG"
fi
CLIENTGUILIBS="${WX_LIBS} ${SQLITE3_LIBS}"
......
......@@ -1140,6 +1140,68 @@ function boinccore_url_pagination_handler($type, $object_id = NULL) {
$path = NULL;
$params = array();
switch ($type) {
case 'boinc-forum':
// Redirect requests to a BOINC forum to the Drupal forum
$forum_id = db_result(db_query('
SELECT tid
FROM {boincimport_temp_forum}
WHERE forum_id = %d',
$object_id
));
if ($forum_id) {
drupal_goto("community/forum/{$forum_id}");
}
break;
case 'boinc-forum-index':
// Redirect requests to the top level BOINC forum to Drupal forums
drupal_goto("community/forum");
break;
case 'boinc-forum-post':
// Redirect requests to a BOINC forum post to the Drupal comment
$cid = db_result(db_query('
SELECT cid
FROM {boincimport_temp_post}
WHERE post_id = %d',
$object_id
));
if ($cid) {
drupal_goto("goto/comment/{$cid}");
}
break;
case 'boinc-forum-topic':
// Redirect requests to a BOINC forum topic to the Drupal node
$nid = db_result(db_query('
SELECT nid
FROM {boincimport_temp_topic}
WHERE topic_id = %d',
$object_id
));
if ($nid) {
drupal_goto("node/{$nid}");
}
break;
case 'boinc-host':
// Redirect requests to BOINC host details to the host page in Drupal
drupal_goto("host/{$object_id}");
break;
case 'boinc-hosts-user':
// Redirect requests to a BOINC user host list to the host list in Drupal
$uid = boincuser_lookup_uid($object_id);
if ($uid) {
drupal_goto("account/{$uid}/computers");
}
break;
case 'boinc-result':
// Redirect requests to BOINC task details to the task page in Drupal
drupal_goto("task/{$object_id}");
case 'boinc-results-host':
// Redirect requests to BOINC tasks by host to the host task page in Drupal
drupal_goto("host/{$object_id}/tasks");
break;
case 'boinc-results-user':
// Redirect requests to a BOINC user's tasks to the Drupal account tasks
drupal_goto("account/tasks");
break;
case 'boinc-user':
// Redirect requests to a BOINC user ID to the Drupal profile
$uid = boincuser_lookup_uid($object_id);
......@@ -1147,6 +1209,10 @@ function boinccore_url_pagination_handler($type, $object_id = NULL) {
drupal_goto("account/{$uid}");
}
break;
case 'boinc-workunit':
// Redirect requests to BOINC workunits to the workunit page in Drupal
drupal_goto("workunit/{$object_id}");
break;
case 'comment':
$object = _comment_load($object_id);
if ($object) {
......
......@@ -2290,7 +2290,6 @@ function boincimport_posts_op($offset, $batch_size, &$context) {
}
$input_format = variable_get('boincimport_input_format', 0);
$posts_imported = 0;
// Get the topics with posts to import
db_set_active('boinc');
......@@ -2315,6 +2314,7 @@ function boincimport_posts_op($offset, $batch_size, &$context) {
$first_post = true;
$success = FALSE;
$posts_imported = 0;
$empty_posts = 0;
$error_posts = 0;
$duplicate_posts = 0;
......@@ -3943,13 +3943,15 @@ function _boincimport_replace_links($html) {
// Update links to posts, threads, and forums
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?forum_thread\.php\?id=(\d+)(&\w+=\w*)*?(#(\d+)?)}i', array($transformer, 'transformPostLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?forum_thread\.php\?id=(\d+)}i', array($transformer, 'transformTopicLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?forum_forum\.php\?id=(\d+)}i', array($transformer, 'transformForumLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?forum_thread\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformTopicLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?forum_forum\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformForumLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?show_user\.php\?userid=(\d+)((&\w+=\w*)+)?}i', array($transformer, 'transformUserLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?workunit\.php\?wuid=(\d+)}i', array($transformer, 'transformWorkUnitLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?result\.php\?resultid=(\d+)}i', array($transformer, 'transformResultLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?results\.php\?hostid=(\d+)}i', array($transformer, 'TransformHostResultsLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?show_host_detail\.php\?hostid=(\d+)}i', array($transformer, 'transformHostLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?workunit\.php\?wuid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformWorkUnitLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?result\.php\?resultid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformResultLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?results\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserResultsLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?results\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostResultsLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?show_host_detail\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostLinks'), $html);
$html = preg_replace_callback('{(?:(http|https)://(.*?))?(?:/)?hosts_user\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserHostsLinks'), $html);
// Update any links to the top level index
$html = preg_replace('{forum_index.php}i', "{$transformer->basePath}community/forum", $html);
......@@ -3972,11 +3974,22 @@ class BoincImportUrlTransformer {
function BoincImportUrlTransformer() {
global $base_url;
global $base_path;
$base_url_boinc = variable_get('boincimport_base_url_boinc', '');
$base_url_drupal = variable_get('boincimport_base_url_drupal', $base_url);
$boinc_base_urls = variable_get('boincimport_base_url_boinc', '');
$drupal_base_url = variable_get('boincimport_base_url_drupal', $base_url);
$this->basePath = $base_path;
$this->boincDomain = parse_url($base_url_boinc, PHP_URL_HOST);
$this->drupalDomain = parse_url($base_url_drupal, PHP_URL_HOST);
$this->drupalDomain = parse_url($drupal_base_url, PHP_URL_HOST);
$this->boincDomains = array();
$boinc_base_urls = explode("\n", $boinc_base_urls);
foreach ($boinc_base_urls as $url) {
$domain = parse_url($url, PHP_URL_HOST);
if ($domain) {
$this->boincDomains[$domain] = TRUE;
}
}
if (!$this->boincDomains) {
watchdog('boincimport', 'No valid BOINC base URLs found to transform!',
array(), WATCHDOG_WARNING);
}
}
/**
......@@ -3986,12 +3999,12 @@ class BoincImportUrlTransformer {
$http = $matches[1];
$domain = trim($matches[2], '/');
if ($http) {
if ($domain == $this->boincDomain) {
// This is a URL for this domain
if (isset($this->boincDomains[$domain])) {
// This is a URL configured to be transformed
return "{$http}://{$this->drupalDomain}{$this->basePath}";
}
else {
// This is a URL for another domain!
// This URL should not be transformed
return NULL;
}
}
......@@ -4102,6 +4115,15 @@ class BoincImportUrlTransformer {
return $link;
}
function transformUserResultsLinks($matches) {
$link = $matches[0];
$newBaseUrl = $this->getNewBaseUrl($matches);
if ($newBaseUrl !== NULL) {
$link = "{$newBaseUrl}account/tasks";
}
return $link;
}
function transformHostLinks($matches) {
$link = $matches[0];
$newBaseUrl = $this->getNewBaseUrl($matches);
......@@ -4111,5 +4133,17 @@ class BoincImportUrlTransformer {
}
return $link;
}
function transformUserHostsLinks($matches) {
$link = $matches[0];
$newBaseUrl = $this->getNewBaseUrl($matches);
if ($newBaseUrl !== NULL) {
$uid = boincuser_lookup_uid($matches[3]);
if ($uid) {
$link = "{$newBaseUrl}account/{$uid}/computers";
}
}
return $link;
}
}
......@@ -7,6 +7,7 @@
function boincimport_admin_settings() {
global $conf ;
global $db_url;
global $base_url;
$stage = variable_get('boincimport_config_stage', 0);
// Start with a quick sanity check on the BOINC environment
......@@ -278,6 +279,38 @@ function boincimport_admin_settings() {
$form['bbcode']['result'] = array('#value' => $output);
// URL transform settings
$form['url_transforms'] = array(
'#type' => 'fieldset',
'#title' => t('URL transforms'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
if (!variable_get('boincimport_base_url_boinc', 0)) {
$form['url_transforms']['#collapsed']= FALSE;
$output = '<span class="marker">';
$ready_for_migration = 0;
}
// List of BOINC domains possible in URLs to transform
$form['url_transforms']['boincimport_base_url_boinc'] = array(
'#type' => 'textarea',
'#title' => t('BOINC base URLs to transform'),
'#default_value' => variable_get('boincimport_base_url_boinc', ''),
'#description' => t('List URL bases that should be transformed from
BOINC format to Drupal format (enter one domain per line, including http://).'),
);
// The Drupal domain to use in URL transform results
$form['url_transforms']['boincimport_base_url_drupal'] = array(
'#type' => 'textfield',
'#title' => t('Target Drupal base URL'),
'#default_value' => variable_get('boincimport_base_url_drupal', ''),
'#description' => t('Specify the URL base to use in transform results. If
left blank, the base_url configured in this Drupal environment will be
used (currently: %url)', array('%url' =>$base_url)),
);
// Are we ready for migration?
$form['migration'] = array(
'#type' => 'fieldset',
......
No preview for this file type
No preview for this file type
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment