Exemplo n.º 1
0
    def prettytime(cls, eta):
        '''
        time display with variable precision: only show the most interesting
        time unit.
        '''
        def round_to(val, stepsize):
            return (val + stepsize / 2) // stepsize * stepsize

        prefix = 'ETA '
        if eta < 0:
            eta = -eta
            prefix = '+'
        hh, mm, ss = util.splittime(eta)
        if hh > 3:
            timestr = '%2d hrs' % hh
        elif hh > 0.25:
            hh = round_to(hh * 100, 25) / 100
            timestr = '%.2f h' % hh
        elif mm > 0.8:
            timestr = '%2d min' % int(mm + 0.5)
        elif ss > 20:
            timestr = '%2d sec' % round_to(ss, 20)
        elif ss > 5:
            timestr = '%2d sec' % round_to(ss, 5)
        else:
            timestr = '%2d sec' % ss
        return prefix + timestr
Exemplo n.º 2
0
    def prettytime(cls, eta):
        '''
        time display with variable precision: only show the most interesting
        time unit.
        '''
        def round_to(val, stepsize):
            return (val + stepsize / 2) // stepsize * stepsize

        prefix = 'ETA '
        if eta < 0:
            eta = -eta
            prefix = '+'
        hh, mm, ss = util.splittime(eta)
        if hh > 3:
            timestr = '%2d hrs' % hh
        elif hh > 0.25:
            hh = round_to(hh * 100, 25) / 100
            timestr = '%.2f h' % hh
        elif mm > 0.8:
            timestr = '%2d min' % int(mm + 0.5)
        elif ss > 20:
            timestr = '%2d sec' % round_to(ss, 20)
        elif ss > 5:
            timestr = '%2d sec' % round_to(ss, 5)
        else:
            timestr = '%2d sec' % ss
        return prefix + timestr
Exemplo n.º 3
0
    def prettytime(cls, eta):
        """
        time display with variable precision: only show the most interesting
        time unit.
        """

        def round_to(val, stepsize):
            return (val + stepsize / 2) // stepsize * stepsize

        prefix = "ETA "
        if eta < 0:
            eta = -eta
            prefix = "+"
        hh, mm, ss = util.splittime(eta)
        if hh > 3:
            timestr = "%2d hrs" % hh
        elif hh > 0.25:
            hh = round_to(hh * 100, 25) / 100
            timestr = "%.2f h" % hh
        elif mm > 0.8:
            timestr = "%2d min" % int(mm + 0.5)
        elif ss > 20:
            timestr = "%2d sec" % round_to(ss, 20)
        elif ss > 5:
            timestr = "%2d sec" % round_to(ss, 5)
        else:
            timestr = "%2d sec" % ss
        return prefix + timestr
Exemplo n.º 4
0
 def timefmt(cls, eta):
     """the default time format: [+]hh:mm:ss"""
     overtime = "ETA "
     if eta < 0:
         eta = -eta
         overtime = "+"
     hh, mm, ss = util.splittime(eta)
     return "%(ot)s%(hh)02d:%(mm)02d:%(ss)02d" % {"hh": hh, "mm": mm, "ss": ss, "ot": overtime}
Exemplo n.º 5
0
 def etastr(self):
     """String version of remaining time estimate. A negative `eta` is marked
     as positive overtime."""
     overtime = ""
     eta = self.eta
     if eta < 0:
         eta = -eta
         overtime = "+"
     hh, mm, ss = util.splittime(eta)
     return "%(ot)s%(hh)02d:%(mm)02d:%(ss)02d" % {"hh": hh, "mm": mm, "ss": ss, "ot": overtime}
Exemplo n.º 6
0
 def timefmt(cls, eta):
     '''the default time format: [+]hh:mm:ss'''
     overtime = 'ETA '
     if eta < 0:
         eta = -eta
         overtime = '+'
     hh, mm, ss = util.splittime(eta)
     return '%(ot)s%(hh)02d:%(mm)02d:%(ss)02d' % {
         'hh': hh,
         'mm': mm,
         'ss': ss,
         'ot': overtime,
     }
Exemplo n.º 7
0
 def timefmt(cls, eta):
     '''the default time format: [+]hh:mm:ss'''
     overtime = 'ETA '
     if eta < 0:
         eta = -eta
         overtime = '+'
     hh, mm, ss = util.splittime(eta)
     return '%(ot)s%(hh)02d:%(mm)02d:%(ss)02d' % {
                                                  'hh': hh,
                                                  'mm': mm,
                                                  'ss': ss,
                                                  'ot':overtime,
                                                  }
Exemplo n.º 8
0
 def etastr(self):
     """String version of remaining time estimate. A negative `eta` is marked
     as positive overtime."""
     overtime = ''
     eta = self.eta
     if eta < 0:
         eta = -eta
         overtime = '+'
     hh, mm, ss = util.splittime(eta)
     return '%(ot)s%(hh)02d:%(mm)02d:%(ss)02d' % {
         'hh': hh,
         'mm': mm,
         'ss': ss,
         'ot': overtime,
     }
Exemplo n.º 9
0
 def etastr(self):
     """String version of remaining time estimate. A negative `eta` is marked
     as positive overtime."""
     overtime = ''
     eta = self.eta
     if eta < 0:
         eta = -eta
         overtime = '+'
     hh, mm, ss = util.splittime(eta)
     return '%(ot)s%(hh)02d:%(mm)02d:%(ss)02d' % {
                                                  'hh': hh,
                                                  'mm': mm,
                                                  'ss': ss,
                                                  'ot':overtime,
                                                  }