mirror of https://github.com/BOINC/boinc.git
parent
eb52ef9545
commit
d35758bedb
|
@ -19,6 +19,8 @@ error_reporting(E_ALL);
|
|||
ini_set('display_errors', true);
|
||||
ini_set('display_startup_errors', true);
|
||||
|
||||
$app_name = "uppercase";
|
||||
|
||||
function error($s) {
|
||||
echo "<error>\n<message>$s</message>\n</error>\n";
|
||||
exit;
|
||||
|
@ -90,7 +92,45 @@ function handle_get_output($r, $batch) {
|
|||
|
||||
xml_header();
|
||||
|
||||
if (0) {
|
||||
$r = simplexml_load_string($_POST['request']);
|
||||
} else {
|
||||
$x = <<<EOF
|
||||
<tt_request>
|
||||
<action>submit</action>
|
||||
<sequence><![CDATA[
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Add platform and application records to the BOINC database.
|
||||
Reads info from "project.xml", e.g.:
|
||||
|
||||
<boinc>
|
||||
<platform>
|
||||
<name>i686-pc-linux-gnu</name>
|
||||
<user_friendly_name>Linux/x86</user_friendly_name>
|
||||
</platform>
|
||||
<app>
|
||||
<name>astropulse</name>
|
||||
<user_friendly_name>AstroPulse</user_friendly_name>
|
||||
</app>
|
||||
</boinc>
|
||||
|
||||
See http://boinc.berkeley.edu/tool_xadd.php
|
||||
'''
|
||||
|
||||
import boinc_path_config
|
||||
from Boinc import database, db_mid, projectxml
|
||||
|
||||
database.connect()
|
||||
projectxml.default_project().commit_all()
|
||||
|
||||
]]></sequence>
|
||||
<auth>157f96a018b0b2f2b466e2ce3c7f54db</auth>
|
||||
</tt_request>
|
||||
EOF;
|
||||
$r = simplexml_load_string($x);
|
||||
}
|
||||
|
||||
if (!$r) {
|
||||
error("can't parse request message");
|
||||
|
@ -99,11 +139,11 @@ if (!$r) {
|
|||
// authenticate the user
|
||||
//
|
||||
$auth = (string)$r->auth;
|
||||
$user = BoincUser::lookup("auth='$auth'");
|
||||
$user = BoincUser::lookup("authenticator='$auth'");
|
||||
if (!$user) error("invalid authenticator");
|
||||
$user_submit = BoincUserSubmit::lookup_userid($user->id);
|
||||
if (!$user_submit) error("no submit access");
|
||||
$app = BoincApp::lookup("name='tree_threader'");
|
||||
$app = BoincApp::lookup("name='$app_name'");
|
||||
if (!$app) error("no tree_threader app");
|
||||
|
||||
if (!$user_submit->submit_all) {
|
||||
|
@ -113,7 +153,7 @@ if (!$user_submit->submit_all) {
|
|||
}
|
||||
}
|
||||
|
||||
switch ($r->getName()) {
|
||||
switch ((string)$r->action) {
|
||||
case 'submit': handle_submit($r, $user, $app); break;
|
||||
case 'get_output':
|
||||
$batch_id = (int)$r->batchid;
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
#! /usr/bin/env php
|
||||
<?php
|
||||
|
||||
// ./bin/tree_threader_splitter input_dir
|
||||
//
|
||||
// input_dir: a directory with a number of template files
|
||||
//
|
||||
// Split these into N groups, make each group into a zip file
|
||||
// named "tree_threader_template_T_i"
|
||||
// where T is the current time and i is the index.
|
||||
// Put these in the download hierarchy,
|
||||
// and write a file "tree_threader_template_files"
|
||||
// containing the file names
|
||||
|
||||
$files_per_group = 10;
|
||||
|
||||
require_once("html/inc/dir_hier.inc");
|
||||
|
||||
if ($argc != 2) die("usage: tree_threader_splitter dir\n");
|
||||
if (!is_dir($argv[1])) die("usage: tree_threader_splitter dir\n");
|
||||
|
||||
$now = time();
|
||||
$flist = fopen("tree_threader_template_files", "w");
|
||||
|
||||
function start_group($i) {
|
||||
global $now;
|
||||
mkdir("/tmp/tree_threader_template_".$now."_$i");
|
||||
}
|
||||
|
||||
function add_file_to_group($i, $path) {
|
||||
global $now;
|
||||
$dir = "/tmp/tree_threader_template_".$now."_$i";
|
||||
$cmd = "cp $path $dir";
|
||||
system($cmd);
|
||||
}
|
||||
|
||||
$config = simplexml_load_string(file_get_contents("config.xml"));
|
||||
if (!$config) die("can't parse config.xml");
|
||||
$fanout = (int)$config->config->uldl_dir_fanout;
|
||||
|
||||
function finish_group($i) {
|
||||
global $now, $fanout, $flist;
|
||||
$dir = "tree_threader_template_".$now."_$i";
|
||||
$dirpath = "/tmp/$dir";
|
||||
$cmd = "zip -r $dirpath $dirpath";
|
||||
system($cmd);
|
||||
$f = "$dir.zip";
|
||||
$path = dir_hier_path($f, "download", $fanout);
|
||||
if (rename("/tmp/$f", $path)) {
|
||||
echo "renamed /tmp/$f to $path\n";
|
||||
} else {
|
||||
die("can't rename /tmp/$f to $path\n");
|
||||
}
|
||||
fprintf($flist, "$f\n");
|
||||
}
|
||||
|
||||
$dir = $argv[1];
|
||||
$d = opendir($dir);
|
||||
$igp = 0;
|
||||
$gpsize = 0;
|
||||
while (($f = readdir($d)) !== false) {
|
||||
$p = "$dir/$f";
|
||||
echo "processing $p\n";
|
||||
if (!is_file($p)) continue;
|
||||
if ($gpsize == 0) {
|
||||
start_group($igp);
|
||||
}
|
||||
add_file_to_group($igp, $p);
|
||||
$gpsize++;
|
||||
if ($gpsize == $files_per_group) {
|
||||
finish_group($igp);
|
||||
$gpsize = 0;
|
||||
$igp++;
|
||||
}
|
||||
}
|
||||
if ($gpsize) {
|
||||
finish_group($igp);
|
||||
}
|
||||
fclose($flist);
|
||||
|
||||
?>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
// input: a directory with 6,000 template files
|
||||
//
|
||||
// Split these into N groups, make each group into a zip file,
|
||||
// put these in the download hierarchy,
|
||||
// and write a file containing the file names
|
||||
|
||||
?>
|
|
@ -5,7 +5,7 @@
|
|||
// from the Institute for Computing Technology in Beijing
|
||||
//
|
||||
|
||||
define("PROJECT", "http://test.foo.bar");
|
||||
define("PROJECT", "http://isaac.ssl.berkeley.edu/test/");
|
||||
|
||||
function usage() {
|
||||
die("
|
||||
|
@ -23,7 +23,7 @@ tt_boinc retire batchid auth
|
|||
}
|
||||
|
||||
function do_http_op($xml) {
|
||||
$ch = curl_init(PROJECT."/tree_threader.php");
|
||||
$ch = curl_init(PROJECT."tree_threader.php");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "request=$xml");
|
||||
|
@ -54,7 +54,7 @@ $seq
|
|||
list($reply, $errmsg) = do_http_op($req_xml);
|
||||
if ($errmsg) die("Error: $errmsg\n");
|
||||
$id = (int)$reply->id;
|
||||
echo "batch ID: %d\n";
|
||||
echo "batch ID: $id\n";
|
||||
}
|
||||
|
||||
function handle_abort() {
|
||||
|
|
Loading…
Reference in New Issue