Changeset - 536058b6e341
[Not reviewed]
default
0 2 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-05-29 13:36:52
e@ethanzonca.com
Fixed the recalc process to remove interaction, need to add php hook on server for getting render_power
2 files changed with 16 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/server/simpleslave.c
Show inline comments
 
@@ -59,14 +59,15 @@ int main(int argc, char *argv[])
 
  server = NULL;
 
  username = NULL;
 
  password = NULL;
 
  hostname = NULL;
 

	
 
  char curopt;
 
  int runBenchmark = 0;
 

	
 
  while(((char)-1) != (curopt = getopt(argc, argv, "u:th")))
 
  while(((char)-1) != (curopt = getopt(argc, argv, "u:rh")))
 
     {
 
       if(curopt == ':')
 
         {
 
           fprintf(stderr, "-%c: is missing an argument\n", optopt);
 
           return 1;
 
         }
 
@@ -74,23 +75,25 @@ int main(int argc, char *argv[])
 
         {
 
           fprintf(stderr, "-%c: invalid option specified\n", optopt);
 
           return 1;
 
         }
 
       else if(curopt == 'h')
 
         {
 
           fprintf(stderr, "Usage: distrenslave [option] \nStarts a distren slave\n\t-u\tset username (run after fresh install)\n\t-t\tEnter test mode\n\t-h\tshow this help\n");
 
           fprintf(stderr, "Usage: distrenslave [option] \nStarts a distren slave\n\t-u\tset username (run after fresh install)\n\t-r\tRecalculate render power (benchmark)\n\t-h\tshow this help\n");
 
           return 2;
 
         }
 
       else if(curopt == 't')
 
       else if(curopt == 'r')
 
         {
 
           slaveTest();
 
           return 0;
 
           runBenchmark = 1;
 
           break;
 
         }
 
       else if(curopt == 'u')
 
         username = strdup(optarg);
 
         if(DEBUG)
 
         fprintf(stderr, "Putting username \"%s\" in distrenslave.conf\n", username);
 

	
 
         conf_replace("distrenslave.conf", "!username", username);
 
         fprintf(stderr, "Please invoke distrenslave with no arguments to run with the username you just set\n");
 
         return 0;
 
     }
 

	
 
  /* Get conf data */
 
@@ -120,19 +123,18 @@ int main(int argc, char *argv[])
 
    {
 
      fprintf(stderr, "hostname not set\n");
 
      return 1;
 
    }
 

	
 
  
 

	
 
  /* Notifies the user if there no username in .conf */
 
  if(checkUsername(username))
 
    return 1;
 
  if(!strncmp(password, "!password",10))
 
    {
 
      fprintf(stderr, "You haven't specified a password. Please edit your distrenslave.conf file appropriately\n");
 
      fprintf(stderr, "You haven't specified a password. Please edit distrenslave.conf!\n");
 
      return 1;
 
    }
 

	
 
  // Variables needed for main loop
 
  int jobnum = 0;
 
  int framenum = 0;
 
@@ -154,34 +156,34 @@ int main(int argc, char *argv[])
 
  char *pathtoJobfile; /* Full path to the job's main file */
 
  char *outputExt = "jpg";     /* Output Extension (e.g., JPG) */
 

	
 
  int haveWork = 0;
 
  int quit = 0;
 

	
 
  fprintf(stderr,"DistRenSimpleSlave Pre-Alpha\n\t- this version of DistRen is still experimental\n\t  so things might go horribly wrong!\n");
 
  fprintf(stderr,"\nDistRen SimpleSlave Pre-Alpha %s\n- Experimental build: Use at your own risk!\n\n", PACKAGE_VERSION);
 

	
 
  int benchmarkTime = 0;
 
  int renderPower = 0;
 

	
 
  char option[1] = "";
 
  fprintf(stderr,"Do you want to recalculate render power? (y/n): ");
 
  scanf("%s", option);
 
  if(!strcmp(option, "y"))
 
  // @TODO: create _web function to force recalc if !isset($render_power) on server
 
  if(runBenchmark)
 
    {
 
      if(slaveBenchmark(datadir, &benchmarkTime, &renderPower))
 
	{
 
	  fprintf(stderr,"Benchmark failed! Exiting.\n");
 
	  return 1;
 
	}
 
      else
 
	{
 
	  fprintf(stderr,"Benchmark successful, time taken was %d seconds, giving you a render power of %d.\n",
 
		  benchmarkTime, renderPower);
 
	  _web_setrenderpower(slavekey, password, renderPower);
 
	  return 0;
 
	}
 
    }
 

	
 
  if(!DEBUG)
 
    fprintf(stderr, "Running..");
 
  // Main loop
 
  while(!quit)
 
    {
 

	
src/server/slavefuncs.c
Show inline comments
 
@@ -535,13 +535,13 @@ int checkUsername(char *username)
 
   }
 
   else
 
     if( username != NULL || strcmp(username, "!username") != 0 )
 
       {
 
         // Log in the user
 
         if(login_user(username) == 1){
 
           fprintf(stderr, "You should now be logged into distren.\n");
 
           // Logged in OK
 
           return 0;
 
         }
 
         else
 
           {
 
             fprintf(stderr, "Login failed, please check your username. If you have not registered, please do so on the DistRen website.\n");
 
             return 1;
 
@@ -724,12 +724,13 @@ void _web_resetframe(int slavekey, char 
 
  fprintf(stderr,"%s\n", data.memory);
 
  if(data.memory)
 
    free(data.memory);
 
}
 

	
 
void _web_startframe(int slavekey, char *slavepass, int jobnum, int framenum){
 
  if(DEBUG)
 
  fprintf(stderr,"Marking frame %d started on server... ",framenum);
 
  char *url;
 
  _distren_asprintf(&url,"http://dev.distren.org/slave/act.php?mode=startframe&slavekey=%d&slavepass=%s&jobnum=%d&framenum=%d", slavekey, slavepass, jobnum, framenum);
 
  struct _web_memorystruct data = _web_getrequest(url);
 
  free(url);
 

	
0 comments (0 inline, 0 general)