Exemplo n.º 1
0
 def time_to(self, time = None, string = False):
     """Compute the time until this closure starts, from a given time.
     
     :param time: The reference time for this closure.
     :param string: Return the time to this closure as a six-character string.
     
     """
     time = Time.now() if time is None else time
     ttc = (self.start - time)
     if string:
         return human_time(ttc.to("s").value)
     return ttc
Exemplo n.º 2
0
    def _update_console(self, value=None):
        """
        Update the progress bar to the given value (out of the total
        given to the constructor).
        """

        if self._total == 0:
            frac = 1.0
        else:
            frac = float(value) / float(self._total)

        file = self._file
        write = file.write

        if frac > 1:
            bar_fill = int(self._bar_length)
        else:
            bar_fill = int(float(self._bar_length) * frac)
        write('\r|')
        color_print('=' * bar_fill, 'blue', file=file, end='')
        if bar_fill < self._bar_length:
            color_print('>', 'green', file=file, end='')
            write('-' * (self._bar_length - bar_fill - 1))
        write('|')

        if value >= self._total:
            t = time.time() - self._start_time
            prefix = '     '
        elif value <= 0:
            t = None
            prefix = ''
        else:
            t = ((time.time() - self._start_time) * (1.0 - frac)) / frac
            prefix = ' ETA '
        write(' {0:>4s}/{1:>4s}'.format(
            human_file_size(value),
            self._human_total))
        write(' ({0:>6s}%)'.format('{0:.2f}'.format(frac * 100.0)))
        write(prefix)
        if t is not None:
            write(human_time(t))
        self._file.flush()
Exemplo n.º 3
0
    def _update_console(self, value=None):
        """
        Update the progress bar to the given value (out of the total
        given to the constructor).
        """

        if self._total == 0:
            frac = 1.0
        else:
            frac = float(value) / float(self._total)

        file = self._file
        write = file.write

        if frac > 1:
            bar_fill = int(self._bar_length)
        else:
            bar_fill = int(float(self._bar_length) * frac)
        write('\r|')
        color_print('=' * bar_fill, 'blue', file=file, end='')
        if bar_fill < self._bar_length:
            color_print('>', 'green', file=file, end='')
            write('-' * (self._bar_length - bar_fill - 1))
        write('|')

        if value >= self._total:
            t = time.time() - self._start_time
            prefix = '     '
        elif value <= 0:
            t = None
            prefix = ''
        else:
            t = ((time.time() - self._start_time) * (1.0 - frac)) / frac
            prefix = ' ETA '
        write(' {0:>4s}/{1:>4s}'.format(human_file_size(value),
                                        self._human_total))
        write(' ({0:>6s}%)'.format('{0:.2f}'.format(frac * 100.0)))
        write(prefix)
        if t is not None:
            write(human_time(t))
        self._file.flush()
Exemplo n.º 4
0
 def __exit__(self, *args):
     end = self.timer()
     self.elapsed_secs = end - self.start
     self.elapsed = self.elapsed_secs
     LOGGER.info('{}, Elapsed time: {}'.format(self.name,
                                               human_time(self.elapsed)))
Exemplo n.º 5
0
def test_human_time(seconds, string):
    human_time = console.human_time(seconds)
    assert human_time == string
Exemplo n.º 6
0
def test_human_time(seconds, string):
    human_time = console.human_time(seconds)
    assert human_time == string
Exemplo n.º 7
0
    #    decm = decm[1:]
    #    decs = decs[1:]
    
    EQ = ['2000.' for i in decd]
    #print(DEC)
    #out = Table((name, coord_str, EQ),
    #                     names=('name','coord', 'eq'))
    #out = Table((name, RA, DEC, priority),
    #                 names=('name','ra','dec' 'prio'))
    #out = Table((name, RA, DEC, priority),
    #                     names=('name','ra', 'dec', 'prio'))
    #name     rah  ram  ras    decd  decm  decs   equinox
    out = Table((name, rah, ram, ras,
                 decd, decm, decs, EQ),
                 names=('name','rah',  'ram',  'ras', 'decd',  'decm',
                          'decs',   'equinox'))
    print("Test")          
    print(out)           
    out_name= table_name + '.skycalc'
    
                         
    
    #fmts = {'name':'%s', 'coord':'%s', 'prio':'%d'}
    ascii.write(out, out_name, format='no_header')#, formats=fmts)
    
    print("Output: ", out_name)
    
    
    
    print("Elapsed time: {0:s}" .format(human_time(time.time() - start_time)))