Пример #1
0
def main():

    options = parse_args()

    if options.version:
        print_msg(dr14_version())
        return

    init_log(logging.DEBUG)
    logging.disable(logging.INFO)

    numpy.seterr(all='ignore')

    #print( options )

    if options.enable_database:
        enable_database()
        return

    if options.disable_database:
        enable_db(False)
        print_msg("The local DR database is disabled! ")
        return

    if options.dump_database:
        db = dr_database_singletone().get()
        db.dump()
        return

    if db_is_enabled():
        db = dr_database_singletone().get()
        f = db.is_db_valid()

        if not f:
            print_err("It seems that there is some problem with the db ... ")
            fix_problematic_database()
            return

    if options.query != None:

        if not database_exists():
            print_err("Error: The database does not exists")
            print_err("Error: type dr14_tmeter -q for more info.")
            return

        if len(options.query) == 0:
            query_helper()
            return

        if options.query[0] not in [
                "help", "top", "top_alb", "worst", "worst_alb", "top_art",
                "hist", "evol", "codec"
        ]:

            print_err("Error: -q invalid parameter .")
            print_err("Error: type dr14_tmeter -q for more info.")
            return

        table_code = database_exec_query(options)

        if table_code is not None:
            print_out(table_code)

        return

    if options.path_name != None:
        path_name = os.path.abspath(options.path_name)
    else:
        path_name = os.path.abspath('.')

    if not (os.path.exists(path_name)):
        print_msg("Error: The input directory \"%s\"  does not exists!" %
                  path_name)
        return

    if options.out_dir and not (os.path.exists(options.out_dir)):
        print_msg(
            "Error (-o): The target directory \"%s\"  does not exists! " %
            options.out_dir)
        return

    if options.quiet:
        set_quiet_msg()

    if not options.quiet and not options.skip_version_check:
        l_ver = TestVer()
        l_ver.start()

    print_msg(path_name)
    print_msg("")

    if options.recursive:
        subdirlist = list_rec_dirs(path_name)
    else:
        subdirlist = []
        subdirlist.append(path_name)

    if run_analysis_opt(options, path_name):
        return 1

    if options.scan_file:

        dr = DynamicRangeMeter()

        dr.write_to_local_db(db_is_enabled())

        r = dr.scan_file(path_name)

        if r == 1:
            print_out("")
            print_out(dr.res_list[0]['file_name'] + " :")
            print_out("DR      = %d" % dr.res_list[0]['dr14'])
            print_out("Peak dB = %.2f" % dr.res_list[0]['dB_peak'])
            print_out("Rms dB  = %.2f" % dr.res_list[0]['dB_rms'])
            return 1
        else:
            print_msg("Error: invalid audio file")
            return 0

    if options.out_dir == "":
        out_dir = None
    else:
        out_dir = options.out_dir

    if options.append and out_dir == None:
        out_dir = path_name

    if options.files_list:
        (success, clock, r) = scan_files_list(options.path_name, options,
                                              out_dir)
    else:
        (success, clock, r) = scan_dir_list(subdirlist, options, out_dir)

    if success:
        print_msg("Success! ")
        print_msg("Elapsed time: %2.2f sec" % clock)
    else:
        print_msg("No audio files found\n")
        print_msg(
            " Usage: %s [options] path_name \n\nfor more details type \n%s --help\n"
            % (get_exe_name(), get_exe_name()))

    if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
        subprocess.call("stty sane", shell=True)

    if test_new_version():
        print_msg(
            "\n----------------------------------------------------------------------"
        )
        print_msg(
            " A new version of dr14_t.meter [ %s ] is available for download"
            " \n please visit: %s" % (get_new_version(), get_home_url()))

        print_msg(
            "----------------------------------------------------------------------\n"
        )

    if not database_exists():
        print_msg(" ")
        print_msg(" News ... News ... News ... News ... News  !!! ")
        print_msg(
            " With the version 2.0.0 there is the possibility to store all results in a database"
        )
        print_msg(" If you want to enable this database execute the command:")
        print_msg("  > %s --enable_database " % get_exe_name())
        print_msg("")
        print_msg(
            " for more details visit: http://dr14tmeter.sourceforge.net/index.php/DR_Database "
        )

    return r
Пример #2
0
def main():
                
    options = parse_args()

    if options.version :
        print_msg( dr14_version() )
        return

    init_log( logging.DEBUG )
    logging.disable( logging.INFO )
    
    numpy.seterr(all='ignore')
    
    #print( options )

    if options.enable_database :
        enable_database()
        return 
    
    if options.disable_database :
        enable_db( False )
        print_msg( "The local DR database is disabled! " )
        return

    if options.dump_database :
        db = dr_database_singletone().get()
        db.dump() 
        return 
    
    if db_is_enabled() :
        db = dr_database_singletone().get()
        f = db.is_db_valid()
        
        if not f :
            print_err( "It seems that there is some problem with the db ... " )
            fix_problematic_database()
            return 
         

    if options.query != None :
        
        if not database_exists() :
            print_err( "Error: The database does not exists" )
            print_err( "Error: type dr14_tmeter -q for more info." )
            return 
        
        if len( options.query ) == 0 :
            query_helper()
            return 
        
        if options.query[0] not in [ "help" , "top" , "top_alb" , 
                                    "worst" , "worst_alb" , "top_art" ,
                                    "hist" , "evol" , "codec" ] :
            
            print_err( "Error: -q invalid parameter ." )
            print_err( "Error: type dr14_tmeter -q for more info." )
            return 
        
        table_code = database_exec_query( options )
        
        if table_code is not None:
            print_out( table_code )
        
        return  
    
    
    if options.path_name != None:
        path_name = os.path.abspath( options.path_name )
    else:
        path_name = os.path.abspath( '.' )
        
    if not( os.path.exists( path_name ) ) :
        print_msg( "Error: The input directory \"%s\"  does not exists!" % path_name )
        return 

    if options.out_dir and not( os.path.exists( options.out_dir ) ) :
        print_msg( "Error (-o): The target directory \"%s\"  does not exists! " % options.out_dir )
        return 

    if options.quiet :
        set_quiet_msg()

    l_ver = TestVer()
    l_ver.start()
    
    print_msg( path_name )
    print_msg( "" )

    if options.recursive :
        subdirlist = list_rec_dirs( path_name )
    else :
        subdirlist = [] 
        subdirlist.append( path_name )

    if run_analysis_opt( options , path_name ) :
        return 1

     
    if options.scan_file:
                
        dr = DynamicRangeMeter()
        
        dr.write_to_local_db( db_is_enabled() )
        
        r = dr.scan_file( path_name )
        
        if r == 1:
            print_out( "" )
            print_out( dr.res_list[0]['file_name'] + " :" )
            print_out( "DR      = %d" % dr.res_list[0]['dr14'] )
            print_out( "Peak dB = %.2f" % dr.res_list[0]['dB_peak'] )
            print_out( "Rms dB  = %.2f" % dr.res_list[0]['dB_rms'] )
            return 1 
        else:
            print_msg( "Error: invalid audio file" )
            return 0


    if options.out_dir == "" :
        out_dir = None
    else :
        out_dir = options.out_dir

    if options.append and out_dir == None:
        out_dir = path_name
    
    if options.files_list:
        (success,clock,r) = scan_files_list(options.path_name,options,out_dir)
    else:    
        (success,clock,r) = scan_dir_list(subdirlist,options,out_dir)
            
    if success :
        print_msg( "Success! " )
        print_msg( "Elapsed time: %2.2f sec" % clock )
    else:
        print_msg("No audio files found\n")
        print_msg(" Usage: %s [options] path_name \n\nfor more details type \n%s --help\n" % ( get_exe_name() , get_exe_name() ) )

    if sys.platform.startswith('linux'):
        subprocess.call( "stty sane" , shell=True ) 

    if test_new_version() :
        print_msg( "\n----------------------------------------------------------------------" )
        print_msg( " A new version of dr14_t.meter [ %s ] is available for download \n please visit: %s" % ( get_new_version() , get_home_url() ) )
        print_msg( "----------------------------------------------------------------------\n" )
    
    if not database_exists() :
        print_msg( " " )
        print_msg( " News ... News ... News ... News ... News  !!! " )
        print_msg( " With the version 2.0.0 there is the possibility to store all results in a database" )
        print_msg( " If you want to enable this database execute the command:" )
        print_msg( "  > %s --enable_database " % get_exe_name() )
        print_msg( "" )
        print_msg( " for more details visit: http://dr14tmeter.sourceforge.net/index.php/DR_Database " )                
        
    
    return r
Пример #3
0
def main():
    
    options = parse_args()

    #print( options )

    path_name = os.path.abspath( options.path_name )

    if not( os.path.exists( path_name ) ) :
        print( "Error: The input directory \"%s\" don't exixst! " % path_name )
        return 

    if options.out_dir and not( os.path.exists( options.out_dir ) ) :
        print( "Error (-o): The target directory \"%s\" don't exixst! " % options.out_dir )
        return 

    l_ver = TestVer()
    l_ver.start()
    
    print ( path_name )
    print( "" )

    if options.recursive :
        subdirlist = list_rec_dirs( path_name )
    else :
        subdirlist = [] 
        subdirlist.append( path_name )
    
          
    #print ( subdirlist )

    if options.histogram:
        if test_hist_modules() == False:
            return 0
        
        print("Start histo:")
        
        dr = DynamicRangeMeter() ;
        dr.histogram = True
        r = dr.scan_file( path_name )
        
        return 1 
        
    if options.scan_file:
        dr = DynamicRangeMeter()
        r = dr.scan_file( path_name )
        
        if r == 1:
            print( "" )
            print( dr.res_list[0]['file_name'] + " :" )
            print( "DR      = %d" % dr.res_list[0]['dr14'] )
            print( "Peak dB = %.2f" % dr.res_list[0]['dB_peak'] )
            print( "Rms dB  = %.2f" % dr.res_list[0]['dB_rms'] )
            return 1 
        else:
            print ( "Error: invalid audio file" )
            return 0


    if options.out_dir == "" :
        out_dir = None
    else :
        out_dir = options.out_dir

    if options.append and out_dir == None:
        out_dir = path_name
        
    a = time.time()

    success = False

    for cur_dir in subdirlist :
        dr = DynamicRangeMeter()
        print ( "\n------------------------------------------------------------ " )		        
        print ( "> Scan Dir: %s \n" % cur_dir )
        
        cpu = multiprocessing.cpu_count()
                
        if ( options.disable_multithread == True ) :
            r = dr.scan_dir( cur_dir )
        else:
            cpu = cpu / 2
            if cpu <= 2:
                cpu = 2
            else:
                cpu = int( round( cpu ) )
                
            r = dr.scan_dir_mt( cur_dir , cpu )
            
        if r == 0:
            continue
        else:
            success = True
            
        
        write_results( dr , options , out_dir , cur_dir )        
         
    
    b = time.time() - a
    
    if success :
        print("Success! ")
        print( "Elapsed time: %2.2f" % b )
    else:
        print("No audio files found\n")
        print(" Usage: %s [options] path_name \n\nfor more details type \n%s --help\n" % ( get_exe_name() , get_exe_name() ) )

    if sys.platform.startswith('linux'):
        subprocess.call( "stty sane" , shell=True ) 

    if test_new_version() :
        print( "\n----------------------------------------------------------------------" )
        print( " A new version of dr14_t.meter [ %s ] is available for download \n please visit: %s" % ( get_new_version() , get_home_url() ) )
        print( "----------------------------------------------------------------------\n" )
    
    return r
Пример #4
0
def main():
        
    
    
    options = parse_args()

    if options.version :
        print_msg( dr14_version() )
        return

    init_log( logging.DEBUG )
    logging.disable( logging.INFO )
    
    numpy.seterr(all='ignore')
    
    #print( options )

    if options.path_name != None:
        path_name = os.path.abspath( options.path_name )
    else:
        path_name = os.path.abspath( '.' )
        
    if not( os.path.exists( path_name ) ) :
        print_msg( "Error: The input directory \"%s\" don't exixst! " % path_name )
        return 

    if options.out_dir and not( os.path.exists( options.out_dir ) ) :
        print_msg( "Error (-o): The target directory \"%s\" don't exixst! " % options.out_dir )
        return 

    if options.quiet :
        set_quiet_msg()

    l_ver = TestVer()
    l_ver.start()
    
    print_msg( path_name )
    print_msg( "" )

    if options.recursive :
        subdirlist = list_rec_dirs( path_name )
    else :
        subdirlist = [] 
        subdirlist.append( path_name )
    
          
    #print ( subdirlist )

    if run_analysis_opt( options , path_name ) :
        return 1

     
    if options.scan_file:
                
        dr = DynamicRangeMeter()
        r = dr.scan_file( path_name )
        
        if r == 1:
            print_out( "" )
            print_out( dr.res_list[0]['file_name'] + " :" )
            print_out( "DR      = %d" % dr.res_list[0]['dr14'] )
            print_out( "Peak dB = %.2f" % dr.res_list[0]['dB_peak'] )
            print_out( "Rms dB  = %.2f" % dr.res_list[0]['dB_rms'] )
            return 1 
        else:
            print_msg( "Error: invalid audio file" )
            return 0


    if options.out_dir == "" :
        out_dir = None
    else :
        out_dir = options.out_dir

    if options.append and out_dir == None:
        out_dir = path_name
    
    if options.files_list:
        (success,clock,r) = scan_files_list(options.path_name,options,out_dir)
    else:    
        (success,clock,r) = scan_dir_list(subdirlist,options,out_dir)
            
    if success :
        print_msg( "Success! " )
        print_msg( "Elapsed time: %2.2f sec" % clock )
    else:
        print_msg("No audio files found\n")
        print_msg(" Usage: %s [options] path_name \n\nfor more details type \n%s --help\n" % ( get_exe_name() , get_exe_name() ) )

    if sys.platform.startswith('linux'):
        subprocess.call( "stty sane" , shell=True ) 

    if test_new_version() :
        print_msg( "\n----------------------------------------------------------------------" )
        print_msg( " A new version of dr14_t.meter [ %s ] is available for download \n please visit: %s" % ( get_new_version() , get_home_url() ) )
        print_msg( "----------------------------------------------------------------------\n" )
    
    return r