(source_directory, output_folder, with_color=True)
Executes flowdroid over a set of samples

    Parameters
    ----------
    :param source_directory: Folder containing apk files
    :param output_folder: Folder where files generated by FlowDroid are saved
    :param with_color: If colors are used to print messages
Executes flowdroid over a set of samples
Executes flowdroid over a set of samples
def run_flowdroid(source_directory, output_folder, with_color=True):
    """
    Executes flowdroid over a set of samples

    Parameters
    ----------
    :param source_directory: Folder containing apk files
    :param output_folder: Folder where files generated by FlowDroid are saved
    :param with_color: If colors are used to print messages
    """
    if not os.path.exists(source_directory):
        print print_message("Folder not found!", with_color, 'red')

    if not os.path.exists(output_folder):
        os.makedirs(output_folder)

    list_apks = []
    for path, subdirs, files in os.walk(source_directory):
        for name in files:
            if name.endswith(".apk"):
                list_apks.append(os.path.join(path, name))

    for apk_path in tqdm(list_apks):

        apk_id = os.path.basename(apk_path)
        #print "RUNNING FLOWDROID FOR: " + str(apk_id)

        if os.path.isfile(join_dir(output_folder, apk_id.replace(".apk", ".json"))) or "assets" in apk_id:
            continue
        flowdroid_call = get_call_flowdroid(apk_path)

        origen_wd = os.getcwd()
        os.chdir(os.path.join(os.path.abspath(sys.path[0]), FLOWDROID_FOLDER))

        process = subprocess.Popen(flowdroid_call, shell=True, stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT)  # , env={'PATH': FLOWDROID_FOLDER})

        os.chdir(origen_wd)  # get back to our original working directory

        timer = Timer(MAX_TIME_ANALYSIS * 59, kill, [process])
        try:
            timer.start()
            stdout, stderr = process.communicate()

        finally:
            timer.cancel()

        with open(join_dir(output_folder, apk_id.replace(".apk", ".json")), "w") as output:
            output.write(str(stdout))
def run_flowdroid ( source_directory , output_folder , with_color = True ) : if not os . path . exists ( source_directory ) : print print_message ( "Folder not found!" , with_color , 'red' ) if not os . path . exists ( output_folder ) : os . makedirs ( output_folder ) list_apks = [ ] for path , subdirs , files in os . walk ( source_directory ) : for name in files : if name . endswith ( ".apk" ) : list_apks . append ( os . path . join ( path , name ) ) for apk_path in tqdm ( list_apks ) : apk_id = os . path . basename ( apk_path ) #print "RUNNING FLOWDROID FOR: " + str(apk_id) if os . path . isfile ( join_dir ( output_folder , apk_id . replace ( ".apk" , ".json" ) ) ) or "assets" in apk_id : continue flowdroid_call = get_call_flowdroid ( apk_path ) origen_wd = os . getcwd ( ) os . chdir ( os . path . join ( os . path . abspath ( sys . path [ 0 ] ) , FLOWDROID_FOLDER ) ) process = subprocess . Popen ( flowdroid_call , shell = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) # , env={'PATH': FLOWDROID_FOLDER}) os . chdir ( origen_wd ) # get back to our original working directory timer = Timer ( MAX_TIME_ANALYSIS * 59 , kill , [ process ] ) try : timer . start ( ) stdout , stderr = process . communicate ( ) finally : timer . cancel ( ) with open ( join_dir ( output_folder , apk_id . replace ( ".apk" , ".json" ) ) , "w" ) as output : output . write ( str ( stdout ) )