diff --git a/TODO b/TODO --- a/TODO +++ b/TODO @@ -4,6 +4,7 @@ B-Initial of person who needs to fix thi M-LordofWar needs to fix this E-normaldotcom needs to fix this x-finished task +=-Long-term goal Build @@ -19,7 +20,10 @@ Slave *-Add calls to remoteio, once it works or even before it works -Add code to write arguments for exec_blender based on the contents of a job's xml file *-Other XML-writing/reading + +Parse XML file and toss data in blendjob struct + +Update exec_blender() to use the struct rather than other vars -Add errorcatchers to return in libcurl functions +=-Make code more flexible for different types of jobs Options -Rewrite some stuff, try to make it simpler diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -112,25 +112,24 @@ options_init(argc,argv,&my_cfg, myopts, } -/* Somewhat pseudo Rendering code */ + +/* These should all be filled by remotio and other code @TODO: Make this less blender-specific and more jobtype-flexible */ +int jobnum; +int framenum; -/* These should all be filled by remotio and other code */ -int jobnum; // Filled by the server telling the client what to render -int framenum; // same as above -char *outputext = "JPG"; +/* These should be filled by the xml file that comes with a job */ +char *outputExt = "JPG"; +char *outputRes = "1600x1200"; + int gotframe; // set this to 1 after data for a job is received from the server - int busy = 0; // Client business 1=busy 0=idle -char *pathtoOutput; - - char *urltoTar; // Full URL to the server-side location of job#.tgz char *pathtoTar; // Full path to the location of the job#.tgz char *urltoOutput; // Full URL where output is posted char *pathtoJobfile; // Full path to the job's main file - +char *pathtoOutput; // Full path to the output (rendered) file // If the slave is getting job info... if(gotframe ==1) @@ -151,10 +150,16 @@ if(gotframe ==1) _distren_asprintf(&pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/job%d/output/", jobdatapath ); // Prepares the URL where output is posted - _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputext ); // Prepares the path to the jobfile + _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputExt ); // Prepares the path to the jobfile + + // Download the data if it isn't present. (prevents re-downloading for same-job frames) @TODO: Delete old job data - // Download the data - curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar + struct stat buffer; + int fstatus = stat(pathtoJobfile, &buffer); + if(fstatus != -1){ + fprintf(stderr, "Using cached job file...\n"); + curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar + } _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); /*< @todo free() */ mkdir("/tmp/distren", 0750); @@ -164,7 +169,7 @@ if(gotframe ==1) system(tarcmd); free(tarcmd); - // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // So this should grab data from the struct? I have no idea. @TODO: Ohnobinki, we should clear this up. + // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: Make a xml --> struct function // Consider placing the following in the exec_blender() function while(busy == 1){ diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -38,6 +38,12 @@ #include #include + +/** Stub, writes struct from xml */ +int buildstruct(struct blendjob* blendjob, char *pathtoxml){ + return 1; +} + /** Stub stub stubbiness ugh */ void tell_the_server(char *stuff){ } @@ -315,13 +321,14 @@ return 1; // Success */ /** Executor function for Blender operations */ -void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame) +void exec_blender(struct blendjob* blendjob, char *input, char *output, char *outputres, int frame) { int ret; char *frame_str; /* start execio code */ char *command = "blender"; // @TODO: append .exe if win32? + // @TODO: Put in code for output resolution, maybe... mayyyyyyybe.... char *cmd[] = { command, "-b", "-o", output, input, "-f", frame_str, (char *)NULL }; char buf[10]; diff --git a/src/server/slavefuncs.h b/src/server/slavefuncs.h --- a/src/server/slavefuncs.h +++ b/src/server/slavefuncs.h @@ -22,7 +22,8 @@ #include "blendjob.h" #include - +int buildstruct(struct blendjob* blendjob, char *pathtoxml); +void tell_the_server(char *stuff); size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream); int curlget(char *url, char *out); int curlpost(char *filename, char *url); @@ -30,7 +31,7 @@ int ssh_keygen(); int register_user(char *username, char *email); int login_user(char *username); int conf_replace(char *username); -void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame); +void exec_blender(struct blendjob* blendjob, char *input, char *output, char *outputres, int frame); #endif