Hello !
Certains d'entre nous utilisent
Boinctasks pour suspendre automatiquement des WUs selon certains critères (complétion, temps de calcul restant, etc), principalement pour effectuer des "lâchers" au début des périodes de compétition.
Sauf que BoincTasks ne dispose pas d'option pour reprendre automatiquement ces tâches suspendues.
Il faut donc se trouver devant son ordinateur pour les relancer manuellement.
J'ai donc bricolé un petit script batch (Windows) dont le lancement peut être programmé dans le "Planificateur de tâches".
Je vous préviens : c'est mon premier batch sur Windows... C'est testé et fonctionnel, mais très certainement "moche" niveau code.
Bref. Je vous pose ça là. C'est commenté à mort pour ceux qui veulent (essayer de) comprendre.
N'hésitez pas à suggérer des modifs
J'ai publié tout ça sur StackOverflow :
https://stackoverflow.com/questions/43503810/boinc-a-windows-batch-file-to-resume-suspended-tasks-with-the-schedulerÇa vaudra le coup d'y faire un tour dans quelque temps : il y aura peut-être des idées d'amélioration (?)
@echo off
setlocal enableextensions EnableDelayedExpansion
rem Settings
rem ==============================================================
rem Defines the url of the project we want the tasks to be resumed
set ResumeProjectUrl=https://wuprop.boinc-af.org/
rem ==============================================================
rem Defines the path to the client_state.xml Boinc file
set ClientStateFile=%ProgramData%\BOINC\client_state.xml
rem Defines the path to the boinccmd.exe
set BoincCmdFile=%ProgramFiles%\BOINC\boinccmd.exe
rem This is real content, extracted from client_state.xml
rem (useful to have a quick reference)
rem <project_master_url>https://wuprop.boinc-af.org/</project_master_url>
rem <result_name>data_collect_v4_1490525102_609550_0</result_name>
rem <active_task_state>1</active_task_state>
rem Find the lines that contains a specific string... "project_master_url" seems OK (1st line in the above example)
for /f "delims=:" %%I in ('findstr.exe /I /L /N /C:"project_master_url" "%ClientStateFile%" 2^>nul') do (
rem assign variables :
rem a is the first line number, containing <project_master_url>value</project_master_url>
rem b is the next line number, containing <result_name>value</result_name>
rem c is the next line number, containing <active_task_state>value</active_task_state>
set /a a=%%I
set /a b=a+1
set /a c=a+2
rem As we want to resume only a specific project WUs, let's evaluate the url first
rem read first line (a)
for /f "tokens=1* delims=]" %%A in ('^<"%ClientStateFile%" FIND /N /V "" ^| FINDSTR /B /C:"[!a!]"') do (
rem extract project_master_url value (between <tag></tag>)
rem %%a is opening tag, %%b is the value, %%c is closing tag
for /f "tokens=2-4delims=<>" %%a in ("%%B") do (
rem Let's compare the project_master_url value and the desired url (in Settings)
if "%ResumeProjectUrl%"=="%%b" (
rem If values are the same let's find if <active_task_state> is 0 (suspended)
rem Read third line (c)
for /f "tokens=1* delims=]" %%A in ('^<"%ClientStateFile%" FIND /N /V "" ^| FINDSTR /B /C:"[!c!]"') do (
rem extract active_task value (between <tag></tag>)
rem %%a is opening tag, %%b is the value, %%c is closing tag
for /f "tokens=2-4delims=<>" %%a in ("%%B") do (
rem Value is 0 (suspended)
if "%%b"=="0" (
rem Read second line (b)
for /f "tokens=1* delims=]" %%A in ('^<"%ClientStateFile%" FIND /N /V "" ^| FINDSTR /B /C:"[!b!]"') do (
rem extract result_name value (between <tag></tag>)
rem %%a is opening tag, %%b is the value, %%c is closing tag
for /f "tokens=2-4delims=<>" %%a in ("%%B") do (
rem let's call the boinccmd executable to resume the task
start "Resuming" /B "%BoincCmdFile%" --task %ResumeProjectUrl% %%b resume
)
)
)
rem if "%%b" NEQ "0" (
rem echo "Good project, but the task is active"
rem )
)
)
)
rem if "%ResumeProjectUrl%" NEQ "%%b" (
rem echo "This task is from another project"
rem )
)
)
rem clear variables
set a=
set b=
set c=
)
endlocal