import sys, os

from ij.gui import GenericDialog

def find(name, path):
    result = []
    for root, dirs, files in os.walk(path):
        # print root
        if name in files:
            result.append(os.path.join(root, name))
    return result


gd = GenericDialog("Warning")
gd.enableYesNoCancel()
gd.addMessage("Do you really want to reset the pre-existing settings?")

gd.showDialog()

if gd.wasOKed():
	dir_path = os.path.dirname(os.path.realpath("__file__"))
	f = find("Cluster_Analysis_BETA_v3.py", dir_path)
	if f:
		ini_path = os.path.dirname(f[0])
		ini_path = os.path.join(ini_path, "ini.cfg")
		print ini_path

	if os.path.isfile(ini_path):
		os.remove(ini_path)
		print "Settings cleared!"
	else:
		print "No pre-existing settings found, proceed with the analysis"
