Ejemplo n.º 1
0
def cli_convert_main(input_files):
    loop = gobject.MainLoop()
    gobject.threads_init()
    context = loop.get_context()
    error.set_error_handler(error.ErrorPrinter())

    output_type = settings['cli-output-type']
    output_suffix = settings['cli-output-suffix']

    generator = TargetNameGenerator()
    generator.suffix = output_suffix

    progress = CliProgress()

    queue = TaskQueue()
    for input_file in input_files:
        input_file = SoundFile(input_file)
        output_name = generator.get_target_name(input_file)
        c = Converter(input_file, output_name, output_type)
        c.init()
        c.start()
        while c.running:
            if c.get_duration():
                percent = min(100,
                              100.0 * (c.get_position() / c.get_duration()))
                percent = '%.1f %%' % percent
            else:
                percent = '/-\|'[int(time.time()) % 4]
            progress.show(
                '%s: %s' %
                (unquote_filename(c.sound_file.filename[-65:]), percent))
            time.sleep(0.01)
            context.iteration(True)
        print

    previous_filename = None
    '''
    queue.start()
    
    #running, progress = queue.get_progress(perfile)
    while queue.running:
        t = None #queue.get_current_task()
        if t and not settings['quiet']:
            if previous_filename != t.sound_file.get_filename_for_display():
                if previous_filename:
                    print _('%s: OK') % previous_filename
                previous_filename = t.sound_file.get_filename_for_display()

            percent = 0
            if t.get_duration():
                percent = '%.1f %%' % ( 100.0* (t.get_position() / t.get_duration() ))
            else:
                percent = '/-\|' [int(time.time()) % 4]
            progress.show('%s: %s' % (t.sound_file.get_filename_for_display()[-65:], percent ))
        time.sleep(0.10)
        context.iteration(True)
    '''
    if not settings['quiet']:
        progress.clear()
Ejemplo n.º 2
0
def cli_convert_main(input_files):
    loop = gobject.MainLoop()
    gobject.threads_init()
    context = loop.get_context()
    error.set_error_handler(error.ErrorPrinter())

    output_type = settings['cli-output-type']
    output_suffix = settings['cli-output-suffix']

    generator = TargetNameGenerator()
    generator.suffix = output_suffix

    progress = CliProgress()

    queue = TaskQueue()
    for input_file in input_files:
        input_file = SoundFile(input_file)
        output_name = generator.get_target_name(input_file)
        c = Converter(input_file, output_name, output_type)
        c.overwrite = True
        c.init()
        c.start()
        while c.running:
            if c.get_duration():
                percent = min(100, 100.0* (c.get_position() / c.get_duration()))
                percent = '%.1f %%' % percent
            else:
                percent = '/-\|' [int(time.time()) % 4]
            progress.show('%s: %s' % (unquote_filename(c.sound_file.filename[-65:]), percent ))
            time.sleep(0.01)
            context.iteration(True)
        print

    previous_filename = None
    
    '''
    queue.start()
    
    #running, progress = queue.get_progress(perfile)
    while queue.running:
        t = None #queue.get_current_task()
        if t and not settings['quiet']:
            if previous_filename != t.sound_file.get_filename_for_display():
                if previous_filename:
                    print _('%s: OK') % previous_filename
                previous_filename = t.sound_file.get_filename_for_display()

            percent = 0
            if t.get_duration():
                percent = '%.1f %%' % ( 100.0* (t.get_position() / t.get_duration() ))
            else:
                percent = '/-\|' [int(time.time()) % 4]
            progress.show('%s: %s' % (t.sound_file.get_filename_for_display()[-65:], percent ))
        time.sleep(0.10)
        context.iteration(True)
    '''
    if not settings['quiet']:
        progress.clear()
Ejemplo n.º 3
0
def set_error_handler(handler):
    """Replaces the standard error handler (which prints to stderr). An error handler
    takes these arguments:
        - C{line}: A line printed to stderr by the failing operation.
        - C{op}: The failing operation.
        - C{input}: The input to the failing operation.
        - C{host}: The host on which the error occurred (in case of remote execution).
    """
    error.set_error_handler(handler)
Ejemplo n.º 4
0
def cli_tags_main(input_files):
    error.set_error_handler(error.ErrorPrinter())
    loop = gobject.MainLoop()
    gobject.threads_init()
    context = loop.get_context()
    for input_file in input_files:
        input_file = SoundFile(input_file)
        if not settings['quiet']:
            print(input_file.filename)
        t = TagReader(input_file)
        t.start()
        while t.running:
            time.sleep(0.01)
            context.iteration(True)
            
        if not settings['quiet']:
            for key in sorted(input_file.tags):
                print('     %s: %s' % (key, input_file.tags[key]))
Ejemplo n.º 5
0
def cli_tags_main(input_files):
    error.set_error_handler(error.ErrorPrinter())
    loop = gobject.MainLoop()
    gobject.threads_init()
    context = loop.get_context()
    for input_file in input_files:
        input_file = SoundFile(input_file)
        if not settings['quiet']:
            print(input_file.filename)
        t = TagReader(input_file)
        t.start()
        while t.running:
            time.sleep(0.01)
            context.iteration(True)

        if not settings['quiet']:
            for key in sorted(input_file.tags):
                print('     %s: %s' % (key, input_file.tags[key]))