# Path: Utilities/jtools.py
# class OutOfOrderException(Exception):
# class AnalysisError(Exception):
# class CycledList(list):
#     def __getitem__(self, key):
# def slurm_id_from_output(sbatch_output):
# def check_slurm_for_job(squeue_output):
# def get_slurm_exit_state(sjobexitmod_output):
# def write_finished_file(f):
# def midpoint(x1, x2):
# def distance(x1, x2):
# def ANobj_times_to_time_window(t):
# def break_path(p, line_length):
# def text_location(xrange, yrange):
# def valid_int_from_str(s):
# def valid_float_from_str(s):
# def complex_mag(z):
# def complex_mag_list(zz):
# def type_verify(var, typ):
# def time_window_to_filelike_str(w):
# def scan_config(f):
# def in_tkStringVar_array(s, tksvarr):
# def valid_probe_array(s, f = DEFAULT_CONFIG_FILE):
# def return_methods():
# def valid_method(s):
# def probe_positions(probe_array):
# def valid_window(s):
# def remove_key(d, k):
# def time_window_parser(s):
# def t_in_window(t, win):
# def window_subset(w1, w2):
# def valid_num_or_range(s):
# def valid_shot_str(s):
# def shot_str_parser(s):
# def reverse_shot_str_parser(shot_list):
# def squareish_grid(n, swapxy=False):
# def find_closest(arr, x):


    import tkinter as tk
    import Tkinter as tk
import subprocess
from CONSTANTS import *
from Utilities import jtools as jt
            elif exit_state == "FAILED":
                self.root.event_generate("<<clustering_failed>>", when="tail")
                return
            elif exit_state == "CANCELLED+":
                self.root.event_generate("<<clustering_failed>>", when="tail")
            else:
                print("UNKNOWN EXIT STATE: ({})".format(exit_state))
        self.message.set("Waiting for worker\nnode to complete\njob # {}.\n"
                         "Checking again in:\n{} seconds.\n"
                         "Total time elapsed:\n{} seconds.".format(self.jobid, self._cur, self.total_time))
        self.root.after(1000, self.countdown)
        return

    def slurm_clustering_complete(self, e):
        self.root.title("SLURM Clustering Complete!")
        self.root.wm_protocol("WM_DELETE_WINDOW", self.root.destroy)
        # self.root.geometry("330x320")
        self.message.set("SLURM clustering complete!\nYour Analysis object\nwas saved to:\n{}\n"
                         "Total time elapsed: {} seconds"
                         .format(jt.break_path(self.ANobj_file, 23), self.total_time))
        self.cancel_button.destroy()
        ok_button = tk.Button(master=self.root, text="OK", command=self.root.destroy, font=(font_name, 18))
        ok_button.grid(row=1, column=0)
        self.master.event_generate("<<slurm_clustering_complete>>", when="tail")
        return

    def clustering_failed(self, e):
        self.root.title("Clustering Failed!")
        self.root.wm_protocol("WM_DELETE_WINDOW", self.root.destroy)
        self.message.set("Clustering Failed! Check\n{}\nfor more details."

# Path: Utilities/jtools.py
# class OutOfOrderException(Exception):
# class AnalysisError(Exception):
# class CycledList(list):
#     def __getitem__(self, key):
# def slurm_id_from_output(sbatch_output):
# def check_slurm_for_job(squeue_output):
# def get_slurm_exit_state(sjobexitmod_output):
# def write_finished_file(f):
# def midpoint(x1, x2):
# def distance(x1, x2):
# def ANobj_times_to_time_window(t):
# def break_path(p, line_length):
# def text_location(xrange, yrange):
# def valid_int_from_str(s):
# def valid_float_from_str(s):
# def complex_mag(z):
# def complex_mag_list(zz):
# def type_verify(var, typ):
# def time_window_to_filelike_str(w):
# def scan_config(f):
# def in_tkStringVar_array(s, tksvarr):
# def valid_probe_array(s, f = DEFAULT_CONFIG_FILE):
# def return_methods():
# def valid_method(s):
# def probe_positions(probe_array):
# def valid_window(s):
# def remove_key(d, k):
# def time_window_parser(s):
# def t_in_window(t, win):
# def window_subset(w1, w2):
# def valid_num_or_range(s):
# def valid_shot_str(s):
# def shot_str_parser(s):
# def reverse_shot_str_parser(shot_list):
# def squareish_grid(n, swapxy=False):
# def find_closest(arr, x):


# Path: GUI/ClusteringWindow.py
    import tkinter as tk
    import Tkinter as tk
import subprocess
from CONSTANTS import *
from Utilities import jtools as jt

            elif exit_state == "FAILED":
                self.root.event_generate("<<clustering_failed>>", when="tail")
                return
            elif exit_state == "CANCELLED+":
                self.root.event_generate("<<clustering_failed>>", when="tail")
            else:
                print("UNKNOWN EXIT STATE: ({})".format(exit_state))
        self.message.set("Waiting for worker\nnode to complete\njob # {}.\n"
                         "Checking again in:\n{} seconds.\n"
                         "Total time elapsed:\n{} seconds.".format(self.jobid, self._cur, self.total_time))
        self.root.after(1000, self.countdown)
        return

    def slurm_clustering_complete(self, e):
        self.root.title("SLURM Clustering Complete!")
        self.root.wm_protocol("WM_DELETE_WINDOW", self.root.destroy)
        # self.root.geometry("330x320")
        self.message.set("SLURM clustering complete!\nYour Analysis object\nwas saved to:\n{}\n"
                         "Total time elapsed: {} seconds"
                         .format(jt.break_path(self.ANobj_file, 23), self.total_time))
        self.cancel_button.destroy()
        ok_button = tk.Button(master=self.root, text="OK", command=self.root.destroy, font=(font_name, 18))
        ok_button.grid(row=1, column=0)
        self.master.event_generate("<<slurm_clustering_complete>>", when="tail")
        return

    def clustering_failed(self, e):
        self.root.title("Clustering Failed!")
        self.root.wm_protocol("WM_DELETE_WINDOW", self.root.destroy)
        self.message.set("Clustering Failed! Check\n{}\nfor more details."

                         .format(jt.break_path(os.path.join(IRIS_CSCRATCH_DIR,