def line(name, ix):
     if self.user[ix] != 0:
         per = self.host[ix]/self.user[ix]*100
     else:
         per = 0
     return '{} user: {:>{u}}, host: {:>{h}}, {:>3.0f}%'.format(name,
                                                                util.fmtNumber(self.user[ix], '.0f'),
                                                                util.fmtNumber(self.host[ix], '.0f'),
                                                                per,
                                                                u = length_user,
                                                                h = length_host)
 def __str__(self):
     length_user = len(util.fmtNumber(self.user[0], '.0f')) # user will always be longer than host
     length_host = len(util.fmtNumber(self.host[0], '.0f')) # user will always be longer than host
     
     def line(name, ix):
         if self.user[ix] != 0:
             per = self.host[ix]/self.user[ix]*100
         else:
             per = 0
         return '{} user: {:>{u}}, host: {:>{h}}, {:>3.0f}%'.format(name,
                                                                    util.fmtNumber(self.user[ix], '.0f'),
                                                                    util.fmtNumber(self.host[ix], '.0f'),
                                                                    per,
                                                                    u = length_user,
                                                                    h = length_host)
     return "{}\n{} ".format(line('Total credit, ', 0), 
                             line('Avg credit,   ', 1))
 def __str__(self):
     s = 'Worldcommunitygrid.org\nLast result returned: {0}\n'.format(self.lastResult)
     run = 'Run time {0:>20} total (#{2}), {1:>10} per day'.format(util.timedeltaToStr(self.runtime), 
                                                                   util.timedeltaToStr(self.runtimePerDay), 
                                                                   util.fmtNumber(self.runtimeRank))
     p   = 'Points   {0:>20} total (#{2}), {1:>10} per day'.format(util.fmtNumber(self.points), 
                                                                   util.fmtNumber(self.pointsPerDay, '.1f'), 
                                                                   util.fmtNumber(self.pointsRank))
     res = 'Results  {0:>20} total (#{2}), {1:>10} per day'.format(util.fmtNumber(self.results), 
                                                                   util.fmtNumber(self.resultsPerDay, '.1f'), 
                                                                   util.fmtNumber(self.resultsRank))
     s += '{:>10}\n{:>10}\n{:>10}\n'.format(run, p, res)
     return s
 def results_str(self):
     return util.fmtNumber(self.results)
 def credit_str(self):
     return util.fmtNumber(self.credit)