From 5cbccf71266d67e523cc1814f7ee05d148f4ef09 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 23 Oct 2012 09:23:35 -0700 Subject: [PATCH] - server: add stage_file to project setup; add error checking to stage_file --- checkin_notes | 9 +++++ py/Boinc/setup_project.py | 78 ++++++++++++++++++++++++++++++--------- tools/create_work_example | 13 +++++-- tools/stage_file | 22 +++++++---- 4 files changed, 93 insertions(+), 29 deletions(-) mode change 100644 => 100755 tools/create_work_example diff --git a/checkin_notes b/checkin_notes index 0d1f350b0f..d1d9b68e77 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6323,3 +6323,12 @@ Rom 23 Oct 2012 clientscr/ screensaver_x11.cpp + +David 23 Oct 2012 + - server: add stage_file to project setup; add error checking to stage_file + + py/Boinc/ + setup_project.py + tools/ + create_work_example + stage_file diff --git a/py/Boinc/setup_project.py b/py/Boinc/setup_project.py index a5c9b2a909..856ac2514a 100644 --- a/py/Boinc/setup_project.py +++ b/py/Boinc/setup_project.py @@ -344,10 +344,21 @@ def install_boinc_files(dest_dir, install_web_files, install_server_files): force_symlink(dir('bin', 'start'), dir('bin', 'stop')) force_symlink(dir('bin', 'start'), dir('bin', 'status')) map(lambda (s): install(srcdir('py/Boinc',s), dir('py/Boinc',s)), - [ '__init__.py', 'add_util.py', 'boinc_db.py', 'boinc_project_path.py', - 'boincxml.py', 'configxml.py', 'database.py', - 'db_base.py', 'db_mid.py', 'projectxml.py', - 'sched_messages.py', 'tools.py', 'util.py' ]) + [ + '__init__.py', + 'add_util.py', + 'boinc_db.py', + 'boinc_project_path.py', + 'boincxml.py', + 'configxml.py', + 'database.py', + 'db_base.py', + 'db_mid.py', + 'projectxml.py', + 'sched_messages.py', + 'tools.py', + 'util.py' + ]) print >>open(dir('bin', 'boinc_path_config.py'), 'w'), ''' # Generated by make_project import sys, os @@ -372,23 +383,54 @@ sys.path.insert(0, os.path.join('%s', 'py')) map(lambda (s): install(builddir('sched',s), dir('cgi-bin',s)), [ 'cgi', 'file_upload_handler']) map(lambda (s): install(builddir('sched',s), dir('bin',s)), - [ 'make_work', 'feeder', 'transitioner', 'transitioner_catchup.php', - 'sample_bitwise_validator', 'sample_trivial_validator', - 'file_deleter', 'antique_file_deleter', - 'sample_dummy_assimilator', - 'sample_assimilator', 'sample_work_generator', - 'single_job_assimilator', - 'assimilator.py', 'pymw_assimilator.py', - 'update_stats', 'db_dump', 'db_purge', 'show_shmem', 'census', - 'delete_file', 'get_file', 'put_file' ]) + [ + 'antique_file_deleter', + 'assimilator.py', + 'census', + 'db_dump', + 'db_purge', + 'delete_file', + 'feeder', + 'file_deleter', + 'get_file', + 'make_work', + 'put_file', + 'pymw_assimilator.py', + 'sample_assimilator', + 'sample_bitwise_validator', + 'sample_dummy_assimilator', + 'sample_trivial_validator', + 'sample_work_generator', + 'show_shmem', + 'single_job_assimilator', + 'transitioner', + 'transitioner_catchup.php', + 'update_stats' + ]) map(lambda (s): install(builddir('vda',s), dir('bin',s)), [ 'vda', 'vdad' ]) map(lambda (s): install(srcdir('tools',s), dir('bin',s)), - [ 'appmgr', 'create_work', 'xadd', 'dbcheck_files_exist', 'run_in_ops', - 'update_versions', 'parse_config', 'grep_logs', 'db_query', - 'watch_tcp', 'sign_executable', 'dir_hier_move', - 'manage_privileges', 'cancel_jobs', - 'dir_hier_path', 'boinc_submit', 'demo_submit', 'demo_query' ]) + [ + 'appmgr', + 'boinc_submit', + 'cancel_jobs', + 'create_work', + 'dbcheck_files_exist', + 'db_query', + 'demo_query', + 'demo_submit', + 'dir_hier_move', + 'dir_hier_path', + 'grep_logs', + 'manage_privileges', + 'parse_config', + 'run_in_ops', + 'sign_executable', + 'stage_file', + 'update_versions', + 'watch_tcp', + 'xadd' + ]) map(lambda (s): install(srcdir('lib',s), dir('bin',s)), [ 'crypt_prog' ]) map(lambda (s): install(srcdir('sched',s), dir('',s)), diff --git a/tools/create_work_example b/tools/create_work_example old mode 100644 new mode 100755 index 26bcdc885d..684ec44553 --- a/tools/create_work_example +++ b/tools/create_work_example @@ -1,12 +1,19 @@ +#!/bin/bash + # example of how to create a workunit -# copy the input file from a known place into the download hierarchy +# stage the input file # -cp download/input `bin/dir_hier_path input` +bin/stage_file --copy project.xml +if [ $? -ne 0 ] +then + echo "stage_file failed" + exit 1 +fi # Run create_work to create the WU. # The WU name ("wu_nodelete") includes the string "nodelete". # This causes the file deleter to not delete its input files, # so that we can use make_work. # -bin/create_work --appname example_app --wu_name wu_nodelete --wu_template templates/example_app_in --result_template templates/example_app_out input +bin/create_work --appname example_app --wu_name wu_nodelete --wu_template templates/example_app_in --result_template templates/example_app_out project.xml diff --git a/tools/stage_file b/tools/stage_file index a34bae773a..19bf0453b8 100755 --- a/tools/stage_file +++ b/tools/stage_file @@ -30,18 +30,24 @@ // Use this if you specify in the // --copy Copy the file (default is to move it) +function error_exit($msg) { + echo $msg; + exit(1); +} + if (!file_exists("html/inc/dir_hier.inc") || !file_exists("config.xml") ) { - die("This script must be run in the project directory.\n"); + error_exit("This script must be run in the project directory.\n"); } require_once("html/inc/dir_hier.inc"); require_once("html/inc/util_basic.inc"); function usage() { - die("usage: stage_file [--gzip] [--copy] file - --gzip make a gzipped version of file + error_exit("usage: stage_file [--gzip] [--copy] file + --gzip make a gzipped version of file for compressed download + (use with in the input template) --copy copy the file (default is to move it) "); } @@ -65,13 +71,13 @@ for ($i=1; $i<$argc-1; $i++) { } $path = $argv[$argc-1]; -if (!file_exists($path)) die("no such file: $path\n"); +if (!file_exists($path)) error_exit("no such file: $path\n"); $file = basename($path); $fanout = parse_config(get_config(), ""); -if (!$fanout) die("can't find in config.xml"); +if (!$fanout) error_exit("can't find in config.xml"); $download_dir = parse_config(get_config(), ""); -if (!$download_dir) die("can't find in config.xml"); +if (!$download_dir) error_exit("can't find in config.xml"); $dl_path = dir_hier_path($file, $download_dir, $fanout); $dl_md5_path = "$dl_path.md5"; @@ -89,7 +95,7 @@ if (file_exists($dl_path)) { $dl_md5 = md5_file($dl_path); } if ($md5 != $dl_md5) { - die("There is already a file in your project's download directory + error_exit("There is already a file in your project's download directory with that name, but different contents. This is not allowed by BOINC, which requires that files are 'immutable'. Please use a different file name. @@ -119,7 +125,7 @@ if ($gzip) { if (!file_exists($dl_gzip_path)) { $output = system("gzip -c $dl_path > $dl_gzip_path", $retval); if ($retval) { - die("failed to gzip file: $output\n"); + error_exit("failed to gzip file: $output\n"); } } }