Beispiel #1
0
def remove_dupes_module(folder, outfile):

	#add quotes to image path in case of spaces
	quoted_path = "'" +folder +"'"

	#ask if user wants to backup their files before removing dupes
	answer = boolbox(msg='Do you want to make a backup copy of your folder before removing the dupes?', title=' ', choices=('Yes', 'No'), image=None)

	if(answer == 1):
		copy_command = "sudo cp -r " + quoted_path + " /tmp"
		print("Copying folder to /tmp\n")
		subprocess.call([copy_command], shell=True)
	
		msgbox(msg='(Your folder has been copied to /tmp)', title='Copy Complete ', ok_button='OK', image=None, root=None)

	no_quotes = quoted_path.replace("'","")
	log_file_path = "/tmp/duplicates_log.txt"

	remove_dupes_command = "sudo fdupes -r -d -N " + quoted_path + " >> /tmp/fdupes_duplicates_log.txt"
	print ("The remove dupes command is: " + remove_dupes_command, end ="\n\n")
	print ("Removing duplicate files recursively from folder: " + quoted_path, end ="\n\n")


	#run the remove dupes command
	subprocess.call([remove_dupes_command], shell=True)

	#get filesize of mmls_output.txt
	file_size = os.path.getsize("/tmp/fdupes_duplicates_log.txt") 

	#if filesize of mmls output is 0 then run parted
	if(file_size == 0):
		print("No duplicates found\n")
		outfile = open(log_file_path, 'wt+')
		outfile.write("No duplicate files found!")
		os.remove("/tmp/fdupes_duplicates_log.txt")
		#close outfile
		outfile.close()
	else:
		#if log file exists then run unix2dos against the logfile
		unix2dos("/tmp/fdupes_duplicates_log.txt")

		
		

	#remove empty directories	
	for root,dirs,files in os.walk(no_quotes):
		for directories in dirs:
			dir_name = os.path.join(root,directories)
			#if directory is empty then delete it
			if not os.listdir(dir_name):
				os.rmdir(dir_name)

	#move log file to folder
	move_command = "mv /tmp/*duplicates_log.txt " + quoted_path
	subprocess.call([move_command], shell=True)
def remove_dupes_module_noask(evidence, outfile, folder):

	#add quotes to image path in case of spaces
	quoted_path = "'" +folder +"'"

	log_file_path = "/tmp/duplicates_log.txt"

	no_quotes = quoted_path.replace("'","")

	remove_dupes_command = "sudo fdupes -r -d -N " + quoted_path + " > /tmp/fdupes_duplicates_log.txt"
	print ("The remove dupes command is: " + remove_dupes_command)
	print ("Removing duplicate files recursively from folder: " + quoted_path, end ="\n\n")


	#run the remove dupes command
	subprocess.call([remove_dupes_command], shell=True)

	#get filesize of mmls_output.txt
	file_size = os.path.getsize("/tmp/fdupes_duplicates_log.txt") 

	#if filesize of mmls output is 0 then run parted
	if(file_size == 0):
		print("No duplicates found\n")
		outfile = open(log_file_path, 'wt+')
		outfile.write("No duplicate files found!")
		#os.remove("/tmp/fdupes_duplicates_log.txt")
		#close outfile
		outfile.close()
	else:
		#if log file exists then run unix2dos against the logfile
		unix2dos("/tmp/fdupes_duplicates_log.txt")

		
		

	#remove empty directories	
	for root,dirs,files in os.walk(no_quotes):
		for directories in dirs:
			dir_name = os.path.join(root,directories)
			#if directory is empty then delete it
			if not os.listdir(dir_name):
				os.rmdir(dir_name)

	#move log file to folder
	shutil.move("/tmp/fdupes_duplicates_log.txt", no_quotes)
def remove_duplicates_mr(root_folder_path, evidence):

	print("The output folder is: " + root_folder_path)
	print("The evidence to process is: " + evidence)

	evidence = '"' + evidence + '"'

	#get datetime
	now = datetime.datetime.now()
	
	#create output folder path
	folder_path = root_folder_path + "/" + "Remove_Duplicates"
	check_for_folder(folder_path, "NONE")
	

	remove_dupes_command = "sudo fdupes -r -d -N " + evidence + " > " + '"' + folder_path + "/fdupes_duplicates_log.txt" + '"'
	print ("The remove dupes command is: " + remove_dupes_command + "\n\n")
	print ("Removing duplicate files recursively from folder: " + evidence + "\n\n")

	#run the remove dupes command
	subprocess.call([remove_dupes_command], shell=True)

	#get filesize of mmls_output.txt
	file_size = os.path.getsize(folder_path + "/fdupes_duplicates_log.txt") 

	#if filesize of mmls output is 0 then run parted
	if(file_size == 0):
		print("No duplicates found\n")
		outfile = open(folder_path + "/fdupes_duplicates_log.txt", 'wt+')
		outfile.write("No duplicate files found!")
		#close outfile
		outfile.close()
	else:
		#if log file exists then run unix2dos against the logfile
		unix2dos(folder_path + "/fdupes_duplicates_log.txt")	

	#remove empty directories	
	for root,dirs,files in os.walk(root_folder_path):
		for directories in dirs:
			dir_name = os.path.join(root,directories)
			#if directory is empty then delete it
			if not os.listdir(dir_name):
				os.rmdir(dir_name)
def remove_duplicates_mr(root_folder_path, evidence):

    print("The output folder is: " + root_folder_path)
    print("The evidence to process is: " + evidence)

    evidence = '"' + evidence + '"'

    #get datetime
    now = datetime.datetime.now()

    #create output folder path
    folder_path = root_folder_path + "/" + "Remove_Duplicates"
    check_for_folder(folder_path, "NONE")

    remove_dupes_command = "sudo fdupes -r -d -N " + evidence + " > " + '"' + folder_path + "/fdupes_duplicates_log.txt" + '"'
    print("The remove dupes command is: " + remove_dupes_command + "\n\n")
    print("Removing duplicate files recursively from folder: " + evidence +
          "\n\n")

    #run the remove dupes command
    subprocess.call([remove_dupes_command], shell=True)

    #get filesize of mmls_output.txt
    file_size = os.path.getsize(folder_path + "/fdupes_duplicates_log.txt")

    #if filesize of mmls output is 0 then run parted
    if (file_size == 0):
        print("No duplicates found\n")
        outfile = open(folder_path + "/fdupes_duplicates_log.txt", 'wt+')
        outfile.write("No duplicate files found!")
        #close outfile
        outfile.close()
    else:
        #if log file exists then run unix2dos against the logfile
        unix2dos(folder_path + "/fdupes_duplicates_log.txt")

    #remove empty directories
    for root, dirs, files in os.walk(root_folder_path):
        for directories in dirs:
            dir_name = os.path.join(root, directories)
            #if directory is empty then delete it
            if not os.listdir(dir_name):
                os.rmdir(dir_name)
def remove_dupes_module_noask(evidence, outfile, folder):

    #add quotes to image path in case of spaces
    quoted_path = "'" + folder + "'"

    log_file_path = "/tmp/duplicates_log.txt"

    no_quotes = quoted_path.replace("'", "")

    remove_dupes_command = "sudo fdupes -r -d -N " + quoted_path + " > /tmp/fdupes_duplicates_log.txt"
    print("The remove dupes command is: " + remove_dupes_command)
    print("Removing duplicate files recursively from folder: " + quoted_path,
          end="\n\n")

    #run the remove dupes command
    subprocess.call([remove_dupes_command], shell=True)

    #get filesize of mmls_output.txt
    file_size = os.path.getsize("/tmp/fdupes_duplicates_log.txt")

    #if filesize of mmls output is 0 then run parted
    if (file_size == 0):
        print("No duplicates found\n")
        outfile = open(log_file_path, 'wt+')
        outfile.write("No duplicate files found!")
        #os.remove("/tmp/fdupes_duplicates_log.txt")
        #close outfile
        outfile.close()
    else:
        #if log file exists then run unix2dos against the logfile
        unix2dos("/tmp/fdupes_duplicates_log.txt")

    #remove empty directories
    for root, dirs, files in os.walk(no_quotes):
        for directories in dirs:
            dir_name = os.path.join(root, directories)
            #if directory is empty then delete it
            if not os.listdir(dir_name):
                os.rmdir(dir_name)

    #move log file to folder
    shutil.move("/tmp/fdupes_duplicates_log.txt", no_quotes)
Beispiel #6
0
def remove_dupes_module(folder, outfile):

    #add quotes to image path in case of spaces
    quoted_path = "'" + folder + "'"

    #ask if user wants to backup their files before removing dupes
    answer = boolbox(
        msg=
        'Do you want to make a backup copy of your folder before removing the dupes?',
        title=' ',
        choices=('Yes', 'No'),
        image=None)

    if (answer == 1):
        copy_command = "sudo cp -r " + quoted_path + " /tmp"
        print("Copying folder to /tmp\n")
        subprocess.call([copy_command], shell=True)

        msgbox(msg='(Your folder has been copied to /tmp)',
               title='Copy Complete ',
               ok_button='OK',
               image=None,
               root=None)

    no_quotes = quoted_path.replace("'", "")
    log_file_path = "/tmp/duplicates_log.txt"

    remove_dupes_command = "sudo fdupes -r -d -N " + quoted_path + " >> /tmp/fdupes_duplicates_log.txt"
    print("The remove dupes command is: " + remove_dupes_command, end="\n\n")
    print("Removing duplicate files recursively from folder: " + quoted_path,
          end="\n\n")

    #run the remove dupes command
    subprocess.call([remove_dupes_command], shell=True)

    #get filesize of mmls_output.txt
    file_size = os.path.getsize("/tmp/fdupes_duplicates_log.txt")

    #if filesize of mmls output is 0 then run parted
    if (file_size == 0):
        print("No duplicates found\n")
        outfile = open(log_file_path, 'wt+')
        outfile.write("No duplicate files found!")
        os.remove("/tmp/fdupes_duplicates_log.txt")
        #close outfile
        outfile.close()
    else:
        #if log file exists then run unix2dos against the logfile
        unix2dos("/tmp/fdupes_duplicates_log.txt")

    #remove empty directories
    for root, dirs, files in os.walk(no_quotes):
        for directories in dirs:
            dir_name = os.path.join(root, directories)
            #if directory is empty then delete it
            if not os.listdir(dir_name):
                os.rmdir(dir_name)

    #move log file to folder
    move_command = "mv /tmp/*duplicates_log.txt " + quoted_path
    subprocess.call([move_command], shell=True)
from protein_information import *
from unix2dos import *

file_directory = '/home/qcq/python/'
if os.path.exists(file_directory):
	for index_T in range(1 , len(KT_list_input) + 1):
	    file_directory_T = file_directory + str(index_T) + '/'
	    if os.path.exists(file_directory_T):
		for index_FA in FA_list:
		    file_directory_FA = file_directory_T + str(index_FA) + '/'
		    if os.path.exists(file_directory_FA):
			for index_MC in MC_list:
			    file_directory_MC = file_directory_FA + str(index_MC) + '/'
			    if os.path.exists(file_directory_MC):
			        for protein in want_to_run:
			            file_directory_protein = file_directory_MC + protein + '/'
			            if os.path.exists(file_directory_protein):
			                file_deal_with = []
			                file_directory_data = file_directory_protein + 'data.txt'
			                file_directory_information = file_directory_protein + 'information.txt'
			                file_directory_test = file_directory_protein + 'test.txt'
			                file_directory_temperature = file_directory_protein + 'temperature.txt'
			                file_deal_with.append(file_directory_data)
			                file_deal_with.append(file_directory_information)
			                file_deal_with.append(file_directory_test)
			                file_deal_with.append(file_directory_temperature)
			                for index_file in file_deal_with:
					    if os.path.exists(index_file):
			                        unix2dos(index_file)  #unix to dos
						#dos2unix(index_file)