Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/submit_menu.py
Дата изменения: Fri Apr 8 12:46:13 2016
Дата индексирования: Sun Apr 10 23:49:09 2016
Кодировка:
#MODULE submit_menu.py
#
#***********************************************************************
"""

**PURPOSE** --
This Gridware Submission selection menu.

**DEVELOPER** --
K. Clark and D. Chance

**MODIFICATION HISTORY** --
o Initial implementation 1/ 2/03
o add xev as option. 12/3/03
o change submit button name to execute. 1/13/04
o set ccs_product to None when a run is started. 1/13/04
o updated to get rid of 'broken pipe' messages. 1/21/04
o added pdbman. dc 4/19/04
o added buttons for megg, opc cat, and load checking. dc 8/6/04
o automatically saved pickle only goes in output area. dc 8/12/04
o keep history on state of buttons. dc 9/22/04
o add lga_comm button. dc 9/28/04
o allow megg, lga comm and mosr to be run independent ms/cl runs.
dc 11/30/04
o jump around sanity checks when doing just pdbman. dc 1/4/05
o check cl continuity. dc 2/2/05
o fix cl continuity check. dc 3/31/05
o add try block around cl run prep. dc 8/2/05
o running of dst now independent of running of ms. dc 1/17/06
o fix xev config path. dc 5/22/06
o add queue menu. dc 6/28/06
o raise an error if the logfile doesn't get created after one minute.
dc 3/5/07
o modified for SGE 6. dc 5/8/07
o check tdrs schedule drc 11/7/11
o fix window sizing issue. drc 8/14/12
o code cleanup. drc 2/16/16
"""
#***********************************************************************

__version__ = "16.02.16"

import shutil
import os
import glob
import time
import time_util
import threading
import Queue
import Tix
import spss_sys_util
from Tkinter import Frame, TOP, YES, BOTH, X, LEFT, IntVar, Checkbutton, W, Scrollbar
from Tkinter import Y, Text, RAISED, RIGHT, Button, N, END, NW, Label
import Pmw
import select_option_menu
from pass_product import PASS_SOFTWARE_VERSIONS
import pass_util
import tkMessageBox
import abstract_pass_menu
import mscl_util
import sys
import traceback
from pass_environ_setup import PASS_SYSTEM, DATABASENAME
from batch_util import find_queues, PASS_QUEUE


class submit_menu(abstract_pass_menu.abstract_pass_menu):
def __init__(self, parent, pass_run=None, verbose=0):
abstract_pass_menu.abstract_pass_menu.__init__(self, parent, verbose)
self.parent = parent
self.pass_run = pass_run
self.button_history = {}

# Create new frames
top_frame = Frame(self.frame)
top_frame.pack(side=TOP, expand=YES, fill=BOTH)
middle_frame = Frame(self.frame)
middle_frame.pack(side=TOP, expand=YES, fill=BOTH)
bottom_frame = Frame(self.frame)
bottom_frame.pack(side=TOP, expand=YES, fill=BOTH)

# Create a PASS software version selection menu.
comment = "PASS SW version to use: "

#create a more user friendly list and translation dictionary to actual values
#list software linked directory in option menu
self.software_dict = {}
self.software_dict_invert = {}
sw_disk = spss_sys_util.get_environ_variable("PASS_SOFTWARE_DISK")[0]
for sw_version in PASS_SOFTWARE_VERSIONS:
sw_dir = os.path.join(sw_disk, "op_%s" % sw_version)
if os.path.isdir(sw_dir):
key_value = sw_version
if os.path.islink(sw_dir):
key_value = "%s -> %s" % (sw_version,
os.path.basename(os.path.normpath(os.readlink(sw_dir))))
self.software_dict.update({key_value: sw_version})
self.software_dict_invert.update({sw_version: key_value})

self.pass_sw_version_menu = select_option_menu.select_option_menu(top_frame,
comment,
self.software_dict.keys(),
self.software_dict_invert['ops'])
self.pass_sw_version_menu.frame.pack(pady=10)

if PASS_SYSTEM == 'test':
# Create a batch queue selection menu
comment = "Select a batch queue:"
queues = ["Any"] + find_queues()
self.batch_queue_menu = select_option_menu.select_option_menu(top_frame,
comment,
queues,
'Any')
self.batch_queue_menu.frame.pack(pady=10)

# Create checkboxes for the PASS components to run.
self.run_group = Pmw.Group(top_frame,
tag_text='Choose which PASS components to run:')
self.run_group_frames = [Frame(self.run_group.interior(), height=90),
Frame(self.run_group.interior(), height=90),
Frame(self.run_group.interior(), height=90)]
for f in self.run_group_frames:
f.pack(side=LEFT, fill=X, expand=YES)

self.button_dict = {}
self.make_run_buttons()

# Create the Batch queue checkbutton menu.
# self.que_list(self.frame)

# Create the "View Log file on Execute" checkbutton
self.view_logfile_button_value = IntVar()
self.view_logfile_button_value.set(1)
self.view_logfile_checkbutton = Checkbutton(top_frame,
text='View Log file on Execute',
selectcolor='green',
variable=self.view_logfile_button_value)
self.view_logfile_checkbutton.pack(padx=5, pady=5, anchor=W)

# Create message box
scroll = Scrollbar(middle_frame)
self.output_box = Text(middle_frame,
bd=2,
relief=RAISED,
yscrollcommand=scroll.set,
setgrid=YES)
scroll['command'] = self.output_box.yview
scroll.pack(side=RIGHT, fill=Y, anchor=N)
self.output_box.pack(side=LEFT, expand=YES, fill=BOTH, anchor=N)

# Create the job submission button
self.su_button = Button(bottom_frame,
text="Execute",
command=self.submit)
self.su_button.pack(pady=10, anchor=N)

def submit(self):
"""Method to submit a gridware batch job
"""
# Turn the cursor to a watch
old_cursor = self.parent.cget("cursor")
self.parent.configure(cursor="watch")

rtime = time_util.spss_time()

# Set the run time and create the top-level output directories
self.pass_run.set_run_time(rtime)
self.pass_run.make_run_dirs()

# Create the config file
config_path = self.pass_run.make_new_config_file_name()
try:
# When you're only running PDBMAN, only a prd pickle is required.
if ('pdbman' in self.button_dict and self.button_dict['pdbman'].get()
and not (self.pass_run.get_ms() and self.button_dict['ms'].get())
and not (self.pass_run.get_cls() and self.button_dict['cl0'].get())):
self.pass_run.create_config_file(config_path, ['prd'])
else:
#validate input before running
try:
self.pass_run.validate_input()
except Exception, e:
self.parent.configure(cursor=old_cursor)
dialog = Pmw.MessageDialog(self.parent,
title='Input validation ERROR!',
buttons=['Abort', 'Continue'],
message_text=e)
result = dialog.activate()
if result == 'Abort':
return
self.pass_run.create_config_file(config_path)
except:
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Couldn't create the config file
errortype, errorvalue, tb = sys.exc_info()
if self.verbose:
print self.pass_run.get_config()
print str(errortype)
print str(errorvalue)
for line in traceback.format_tb(tb):
print line
tkMessageBox.showerror("Error creating config file",
"Could not create config file: %s\n %s" %
(config_path, str(errorvalue)))
return

# Create the script list
scripts = pass_util.pass_script_list(output_area=self.pass_run.run_area)

if self.pass_run.get_run_name():
scripts.set_jobname(self.pass_run.get_run_name())

# Set the batch queue

if PASS_SYSTEM == 'test':
scripts.set_queue(self.batch_queue_menu.get_value())
else:
scripts.set_queue(PASS_QUEUE)

pdbman = self.pass_run.get_pdbman()
ms = self.pass_run.get_ms()
cls = self.pass_run.get_cls()
outtext = "Script path: %s\n" % scripts.get_script_path()
outtext += "Logfile path: %s\n" % scripts.get_logpath()
outtext += "Jobname: %s\n" % scripts.get_jobname()
outtext += "Config file path: %s\n" % config_path
ms_pnm = False
cl_pnm = False
mosr_pnm = False
if pdbman and self.button_dict['pdbman'].get():
try:
pdbman.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
pdbman.set_run_time(rtime)
pdbman.set_config_file(config_path)
pdbman.run_prep()
except:
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Error preping for PDBMAN run
errortype, errorvalue, tb = sys.exc_info()
if self.verbose:
print str(errortype)
print str(errorvalue)
for line in traceback.format_tb(tb):
print line
tkMessageBox.showerror("PDBMAN prep error",
"Error preparing for PDBMAN run:\n %s" %
str(errorvalue))
return

scripts.append(pdbman.get_script_obj())
if self.verbose:
print "\n\n*** PDBMAN object ***"
for key in pdbman.__dict__.keys():
print key, pdbman.__dict__[key]
else:
outtext += "Software version: %s\n" % pdbman.get_software_version()
outtext += "Submitting PDBMAN run: %s\n" % str(pdbman)

if self.verbose and 'ms' in self.button_dict:
print "self.button_dict['ms'].get()", self.button_dict['ms'].get()
if ms and self.button_dict['ms'].get():
ms_pnm = True
ms.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
ms.set_run_time(rtime)
#ms.set_create_dummy_tdrs(self.button_dict['dst'].get())
ms.set_config_file(config_path)
if PASS_SYSTEM != 'test' and ms.get_intercept_time() is None and ms.get_run_type() != 'test':
# Check that the latest TDRS schedule was used.
sched = self.pass_run.get_config()['sch']
dat_path = sched.get_environment_dictionary()['CFG_TDRSSCHD']
sched_time = os.path.getmtime(dat_path)
dat_files = glob.glob(dat_path[:-7] + '*' + dat_path[-4:])
for f in dat_files:
if os.path.getmtime(f) > sched_time:
TDRS_schedule_check(self, dat_path, f)
if self.TDRS_sched_check_message != 'Continue':
self.parent.configure(cursor=old_cursor)
return
if PASS_SYSTEM != 'test' and spss_sys_util.glob(os.path.join(ms.get_output_directory(), "*")):
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Output directory is not empty
tkMessageBox.showerror("MS directory not empty",
"MS output directory:\n%s\nis not empty.\nPlease delete its contents and try again." %
ms.get_output_directory())
return
try:
ms.run_prep()
except:
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Couldn't create the config file
errortype, errorvalue, tb = sys.exc_info()
if self.verbose:
print str(errortype)
print str(errorvalue)
for line in traceback.format_tb(tb):
print line
tkMessageBox.showerror("MS prep error",
"Error preparing for MS run: %s" %
str(errorvalue))
return

scripts.append(ms.get_script_obj())
if self.verbose:
print "\n\n*** MS object ***"
for key in ms.__dict__.keys():
print key, ms.__dict__[key]
else:
outtext += "Software version: %s\n" % ms.get_software_version()
outtext += "Submitting MS run: %s\n" % str(ms)
outtext += "MS output directory: %s\n" % ms.get_output_directory()

if ms and self.button_dict['dst'].get():
# Generate an updated tdrs.lis file using DST and DSDT PASS executables
Dst = mscl_util.dst(ms)
Dst.run_prep()
scripts.append(Dst.get_script_obj())
self.pass_run.set_dst(Dst)

if ms and self.button_dict['megg'].get():
# Generate the events file and MEGG
Megg = mscl_util.megg(ms)
Megg.run_prep()
scripts.append(Megg.get_script_obj())
self.pass_run.set_megg(Megg)

if ms and self.button_dict['lga_comm'].get():
# Generate the LGA COMM timeline
# The LGA comm timeline must be generated after DST since it will use
# the tdrs.lis file that DST generates.
Comm = mscl_util.comm(ms)
Comm.run_prep()
scripts.append(Comm.get_script_obj())
self.pass_run.set_comm(Comm)

for i in range(len(cls)):
cl_pnm = True
if self.button_dict['cl%i' % i].get():
# Do a sanity check on the CL continuity
# Don't do the check if there is not a database, since
# find_default_cont_cl depends on it.
if i == 0 and ms and DATABASENAME:
calculated_continuity = cls[i].find_default_cont_cl()
input_continuity = cls[i].get_cont_cl()
if not calculated_continuity:
calculated_continuity = 'NONE'
if not input_continuity:
input_continuity = 'NONE'
if calculated_continuity != input_continuity:
self.CLContCheck_message = ''
CLContCheck(self, input_continuity, calculated_continuity)
if self.CLContCheck_message != 'Continue':
# Abort, if the returned message is not Continue.
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
return
cls[i].set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
cls[i].set_run_time(rtime)
cls[i].set_config_file(config_path)
cls[i].set_gen_opcs(self.button_dict['opc'].get())
cls[i].set_run_loadchecks(self.button_dict['loadcheck'].get())
cldir_contents = spss_sys_util.glob(os.path.join(cls[i].get_output_directory(), "*"))
if PASS_SYSTEM != 'test' and cldir_contents:
# Output directory is not empty
# Having an opc directory is OK so long as it's empty
if not (len(cldir_contents) == 1 and os.path.basename(cldir_contents[0]) == 'opc'):
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
tkMessageBox.showerror("CL%i directory not empty" % (i+1),
"CL%i output directory:\n%s\nis not empty.\nPlease delete its contents and try again." %
((i+1), cls[i].get_output_directory()))

return
elif spss_sys_util.glob(os.path.join(cldir_contents[0], "*")):
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# the opc directory is not empty
tkMessageBox.showerror("CL%i OPC directory not empty" % (i+1),
"CL%i OPC output directory:\n%s\nis not empty.\nPlease delete its contents and try again." %
((i+1), cldir_contents[0]))

return

try:
cls[i].run_prep()
except Exception, e:
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# the opc directory is not empty
tkMessageBox.showerror("CL%i setup error" % (i+1), e)
return
scripts.append(cls[i].get_script_obj())
if self.verbose:
print '\n\n*** CL %i object ***' % (i+1)
for key in cls[i].__dict__.keys():
print key, cls[i].__dict__[key]
else:
outtext += "Submitting CL run: %s\n" % str(cls[i])
outtext += "CL output directory: %s\n" % cls[i].get_output_directory()
# For the last CL, run XEV if the XEV checkbutton is on
if cls and cls[-1] and 'xev' in self.button_dict and self.button_dict['xev'].get():
mosr_pnm = True
Xev = mscl_util.xev(cls[-1])
Xev.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
Xev.set_config_file(config_path)
if spss_sys_util.glob(os.path.join(Xev.get_output_directory(), "*")):
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Output directory is not empty
tkMessageBox.showerror("XEV directory not empty",
"XEV output directory:\n%s\nis not empty.\nPlease delete its contents and try again." %
Xev.get_output_directory())
return
Xev.run_prep()
scripts.append(Xev.get_script_obj())
self.pass_run.set_xev(Xev)
if self.verbose:
print '\n\n*** XEV object ***'
for key in Xev.__dict__.keys():
print key, Xev.__dict__[key]
else:
outtext += "Submitting XEV run: %s\n" % str(Xev)

self.output_box.insert("end", outtext)
try:
scripts.submit(verbose=self.verbose)
except:
# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)
# Error generating the script
errortype, errorvalue, tb = sys.exc_info()
if self.verbose:
print str(errortype)
print str(errorvalue)
for line in traceback.format_tb(tb):
print line
tkMessageBox.showerror("Script generation error",
"Script generation error:\n %s" %
str(errorvalue))
return

if PASS_SYSTEM == 'test':
# Create a PNM on the test system
try:
self.pass_run.set_ccs_product(xfer_type="TEST",
inc_ms=ms_pnm,
inc_sms=ms_pnm,
inc_cl=cl_pnm,
inc_megg=ms_pnm,
inc_mosr=mosr_pnm)
except:
errortype, errorvalue, tb = sys.exc_info()
if self.verbose:
print str(errortype)
print str(errorvalue)
for line in traceback.format_tb(tb):
print line
else:
# After submitting, set CCS product object to None
self.pass_run.my_ccs_product = None

# Always save submitted runs
new_pickle_path = self.pass_run.configure_pickle()

if PASS_SYSTEM == 'test':
# Move the pickle into the output area
pickle_dir = os.path.join(self.pass_run.run_area, 'pickles')
if not os.path.isdir(pickle_dir):
os.makedirs(pickle_dir)
shutil.copy(new_pickle_path, pickle_dir)
os.remove(new_pickle_path)

if self.view_logfile_button_value.get():
# Create text dialog box with contents of the log file
try:
log = Logfile_dialog(self.parent, scripts.get_logpath())
log.activate()
except BatchQueueError:
errmsg = "ERROR -- The job you just submitted does not\n"
errmsg += " seem to be running! After one minute,\n"
errmsg += " the logfile for your job has still not\n"
errmsg += " been created. Possibly there is a\n"
errmsg += " problem with the Sun Grid Engine.\n"
print errmsg
tkMessageBox.showerror("Error -- Job not running", errmsg)

# Turn the cursor back to whatever it was before
self.parent.configure(cursor=old_cursor)

return

def set_CLContCheck_message(self, message):
self.CLContCheck_message = message

def get_CLContCheck_message(self):
return self.CLContCheck_message

def set_TDRS_sched_check_message(self, message):
self.TDRS_sched_check_message = message

def get_TDRS_sched_check_message(self):
return self.TDRS_sched_check_message

def button_setup(self, name, text, button_count, default_state=1):
"""Create a checkbutton.
"""
if name not in self.button_dict:
self.button_dict[name] = Submit_Checkbutton(self.run_group_frames[button_count % len(self.run_group_frames)],
text,
default_state)
self.button_dict[name].pack()
return button_count + 1

def make_run_buttons(self):
"""Make a checkbutton for each PASS component.
"""
button_count = 0
if self.pass_run:
ms = self.pass_run.get_ms()
cls = self.pass_run.get_cls()
pdbman = self.pass_run.get_pdbman()
if pdbman:
button_count = self.button_setup('pdbman', 'PDBMAN ', button_count, 0)

if ms:
button_count = self.button_setup('ms', 'MS ', button_count, 1)
button_count = self.button_setup('megg', 'MEGG ', button_count, 1)
button_count = self.button_setup('dst', 'Create/update TDRS schedule (DST)', button_count, 1)
button_count = self.button_setup('lga_comm', 'LGA COMM Timeline', button_count, 1)

if cls:
for i in range(len(cls)):
button_count = self.button_setup('cl%i' % i, 'CL%i ' % (i+1), button_count, 1)
button_count = self.button_setup('opc', 'OPC Catalog ', button_count, 1)
button_count = self.button_setup('loadcheck', 'Load Check ', button_count, 1)

if ms and cls:
button_count = self.button_setup('xev', 'XEV (MOSR)', button_count, 1)

self.run_group.pack(padx=5, pady=5, expand=YES, fill=X, anchor=N)

def destroy_run_buttons(self):
"""Destory the run buttons
"""
for button in self.button_dict.values():
button.destroy()

def on_raise(self, run_obj):
self.pass_run = run_obj
# destroy the run buttons and remake each time this tab is rasied
#self.destroy_run_buttons()

self.make_run_buttons()

# set the software version to that of the incoming ms or cls if there
# is no ms
if self.pass_run:
ms = self.pass_run.get_ms()
if ms:
self.pass_sw_version_menu.set_value(
self.software_dict_invert[ms.get_software_version()])
elif self.pass_run.get_cls():
self.pass_sw_version_menu.set_value(
self.software_dict_invert[self.pass_run.get_cls()[0].get_software_version()])
if self.verbose:
print "in submit_menu.on_raise"
if self.pass_run and self.pass_run.get_ms():
print "self.pass_run.get_ms():", self.pass_run.get_ms()
elif self.pass_run and self.pass_run.get_cls():
print "self.pass_run.get_cls():", self.pass_run.get_cls()

def on_lower(self, run_obj):
if self.pass_run:
ms = self.pass_run.get_ms()
pdbman = self.pass_run.get_pdbman()
if pdbman:
pdbman.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
if ms:
ms.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
for cl in self.pass_run.get_cls():
cl.set_software_version(self.software_dict[self.pass_sw_version_menu.get_value()])
if self.verbose:
print "in submit_menu.on_lower"
if pdbman:
print "pdbman sw version", self.pass_run.get_pdbman().get_software_version()
if ms:
print "ms sw version:", self.pass_run.get_ms().get_software_version()
for cl in self.pass_run.get_cls():
print "cl sw version:", cl.get_software_version()
print "cl begin time:", cl.get_begin_time()
return self.pass_run


class GuiPart:
"""Handle the logfile dialog box using threads. Based upon a recipe
created by Jacob Hallen, AB Strakt, Sweden. 2001-10-17.

The following comment comes from the original recipe:
This recipe describes how to handle asynchronous I/O in an environment where
you are running Tkinter as the graphical user interface. Tkinter is safe
to use as long as all the graphics commands are handled in a single thread.
Since it is more efficient to make I/O channels to block and wait for something
to happen rather than poll at regular intervals, we want I/O to be handled
in separate threads. These can communicate in a threasafe way with the main,
GUI-oriented process through one or several queues. In this solution the GUI
still has to make a poll at a reasonable interval, to check if there is
something in the queue that needs processing. Other solutions are possible,
but they add a lot of complexity to the application.

"""
def __init__(self, parent, queue, endCommand, logpath):
self.queue = queue
self.endCommand = endCommand
# Set up the GUI
self.dialog = Pmw.TextDialog(parent,
scrolledtext_labelpos='n',
title='Logfile %s' % logpath,
defaultbutton=0,
command=self.destroy,
label_text='Logfile output')
self.dialog.withdraw()

def destroy(self, event=None):
self.dialog.deactivate()
self.endCommand()

def processIncoming(self):
"""
Handle all the messages currently in the queue (if any).
"""
while self.queue.qsize():
try:
msg = self.queue.get(0)
self.dialog.insert(END, msg)
except Queue.Empty:
pass


class BatchQueueError(RuntimeError):
pass


class Logfile_dialog:
"""
Launch the main part of the GUI and the worker thread. periodicCall and
endApplication could reside in the GUI part, but putting them here
means that you have all the thread controls in a single place.
"""
def __init__(self, parent, path):
"""
Start the GUI and the asynchronous threads. We are in the main
(original) thread of the application, which will later be used by
the GUI. We spawn a new thread for the worker.
"""
self.master = parent

# Create the dialog.
self.logpath = path

# Create the queue
self.queue = Queue.Queue()

# Wait for the log to be created
count = 0
while not os.path.isfile(self.logpath):
# Wait one minute for the log file to be created before raising an error.
if count > 60:
raise BatchQueueError
time.sleep(1)
count += 1

# Set up the GUI part
self.gui = GuiPart(parent, self.queue, self.endApplication, self.logpath)

# Set up the thread to do asynchronous I/O
# More can be made if necessary
self.running = 1
self.thread1 = threading.Thread(target=self.workerThread1)
self.thread1.start()

# Start the periodic call in the GUI to check if the queue contains
# anything
self.periodicCall()

def periodicCall(self):
"""
Check every 100 ms if there is something new in the queue.
"""
self.gui.processIncoming()
if not self.running:
self.gui.destroy()
self.master.after(100, self.periodicCall)

def workerThread1(self):
"""
This is where we handle the asynchronous I/O. For example, it may be
a 'select()'.
One important thing to remember is that the thread has to yield
control.
"""
lastsize = os.path.getsize(self.logpath)
while self.running:
size = os.path.getsize(self.logpath)
if size > lastsize:
f = open(self.logpath)
f.seek(lastsize)
part = f.read(size-lastsize)
f.close()
self.queue.put(part)
lastsize = size
elif size == lastsize:
time.sleep(0.2)
elif size < lastsize:
print "file %s truncated" % self.logpath
lastsize = size

def endApplication(self):
self.running = 0

def activate(self):
self.gui.dialog.activate()


class Submit_Checkbutton:
def __init__(self, parent, text, value=1):
self.button_value = IntVar()
self.button_value.set(value)
self.button = Checkbutton(parent,
text=text,
selectcolor='green',
anchor=NW,
variable=self.button_value)

def pack(self):
self.button.pack(padx=5, pady=5, anchor=NW)

def destroy(self):
self.button.destroy()

def set(self, value):
self.button_value.set(value)

def get(self):
return self.button_value.get()


class CLContCheck:
def __init__(self, submit_menu, input_path='', calc_path=''):
self.submit_menu = submit_menu
self.dialog = Pmw.Dialog(submit_menu.parent,
buttons=('Continue', 'Abort'),
defaultbutton='Abort',
title="Possibly incorrect CL history?",
command=self.execute)
Label(self.dialog.interior(), text=
('The CL history directory you have chosen is:\n%s\n\n' % input_path) +
('But, based on the MS you have chosen, the CL history directory looks like it should be:\n%s\n\n' % calc_path) +
'Do you wish to continue with your choice or abort?').pack(expand=1,
fill='both',
padx=4,
pady=4)
self.dialog.activate()

def execute(self, result):
self.submit_menu.set_CLContCheck_message(result)
self.dialog.destroy()


class TDRS_schedule_check:
def __init__(self, submit_menu, tdrs_sched_path='', newer_sched_path=''):
self.submit_menu = submit_menu
self.dialog = Pmw.Dialog(submit_menu.parent,
buttons=('Continue', 'Abort'),
defaultbutton='Abort',
title="Possibly incorrect TDRS schedule?",
command=self.execute)
Label(self.dialog.interior(), text=
('The TDRS schedule you have chosen is:\n%s\n\n' % tdrs_sched_path) +
('However, a newer TDRS schedule exists for this timeframe:\n%s\n\n' % newer_sched_path) +
'Do you wish to continue with your choice or abort?').pack(expand=1,
fill='both',
padx=4,
pady=4)
self.dialog.activate()

def execute(self, result):
self.submit_menu.set_TDRS_sched_check_message(result)
self.dialog.destroy()


if __name__ == '__main__':
root = Tix.Tk()
menu = submit_menu(root)
menu.frame.pack(padx=10, pady=10)
root.mainloop()