def userInterfaceExceptionTest(): exceptionName = tse.USER_INTERFACE_EXCEPTION for errorName in tse.UserInterfaceException.errorNames: message = 'Test(%s, %s)' % (exceptionName, errorName) myLogger.debug('***** %s / %s *****' % (exceptionName, errorName)) try: raise tse.UserInterfaceException(errorName, message) except tse.UserInterfaceException, e1: tse.displayError(e1) except Exception, e1: sys.stderr.write('Unknown exception: %s' % e1)
def programExceptionTest(): exceptionName = tse.PROGRAM_EXCEPTION for errorName in tse.ProgramException.errorNames: message = 'Test(%s, %s)' % (exceptionName, errorName) myLogger.debug('***** %s / %s *****' % (exceptionName, errorName)) try: raise tse.ProgramException(errorName, message) except tse.ProgramException, e1: tse.displayError(e1) except Exception, e1: sys.stderr.write('Unknown exception: %s' % e1)
def inputoutputExceptionTest(): exceptionName = tse.INPUT_OUTPUT_EXCEPTION for errorName in tse.InputOutputException.errorNames: message = 'Test(%s, %s)' % (exceptionName, errorName) myLogger.debug('***** %s / %s *****' % (exceptionName, errorName)) try: raise tse.InputOutputException(errorName, message) except tse.InputOutputException, e1: tse.displayError(e1) except Exception, e1: sys.stderr.write('Unknown exception: %s' % e1)
buildAuthors=__authors__, buildCopyright=__copyright__, buildLicense=__license__, buildCredits=__credits__, buildTitleVersionDate=mainTitleVersionDate, buildHeader=__header__, # getOptions=getOptions, runTimeTitle='main', logs=[], runTimeEntryPoint=theMainApplication) theApplication.runMainApplication() except Exception, applicationError: if isinstance(applicationError, tse.TsExceptions): msg = str(applicationError).replace("'", "") tse.displayError(applicationError) exitStatus = applicationError.exitCode else: msg = None sys.stderr.write(traceback.format_exc()) exitStatus = tse.INVALID_ERROR_CODE if msg == tse.NO_ERROR: sys.stdout.write(msg + '\n') elif msg is not None: sys.stderr.write(msg + '\n') # Return (exitStatus) sys.exit(exitStatus)
buildCopyright=__copyright__, buildLicense=__license__, buildCredits=__credits__, buildTitleVersionDate=mainTitleVersionDate, buildHeader=__header__, # getOptions=getOptions, runTimeTitle='main', logs=[], runTimeEntryPoint=theMainApplication) theApplication.runMainApplication() except Exception, e: if isinstance(e, tse.TsExceptions): msg = str(e).replace("'", "") tse.displayError(e) exitStatus = e.exitCode else: msg = None sys.stderr.write(traceback.format_exc()) exitStatus = tse.INVALID_ERROR_CODE if msg == tse.NO_ERROR: sys.stdout.write(msg + '\n') elif msg is not None: sys.stderr.write(msg + '\n') # Return (exitStatus) sys.exit(exitStatus)
def prototype(*args, **kw): ''' Simulated main program entry point with simulated exception inducing exit test. ''' print('\n%s\n' % getRunTimeTitleVersionDate()) rawArgsOptions = sys.argv[1:] print('\trawArgsOptions=%s' % str(rawArgsOptions)) maxArgs = len(rawArgsOptions) theModule = tsOperatorSettingsParser theClass = theModule.TsOperatorSettingsParser() (args, options) = theClass.parseCommandLineDispatch() if True or DEBUG: print('\n\ttsCommandLineEnv.prototype (parameter list): ' + \ '\n\t\targs=%s;\n\t\tkw=%s' % (str(args), str(kw))) print('\n\ttsCommandLineEnv.prototype (command line argv): ' + \ '\n\t\targs=%s;\n\t\toptions (unsorted)=%s' % ( str(args), str(options))) fmt1 = '\n\ttsCommandLineEnv.prototype (command line argv): ' fmt2 = '\n\t\targs (positional) =%s' % str(args) keys = sorted(options.keys()) text = '' for key in keys: value = '"%s"' % options[key] if text == '': text = '{%s: %s' % (str(key), str(value)) else: text += ', %s: %s' % (str(key), str(value)) text += '}' fmt3 = '\n\t\toptions (sorted)= %s' % text msg = fmt1 + fmt2 + fmt3 print(msg) try: myLogger = tsLogger.TsLogger( threshold = tsLogger.DEBUG, start = time.time(), name = 'testDisplay.log') ## myLogger = tsLogger.TsLogger( ## threshold = tsLogger.DEBUG, ## name = ' ') myLogger.notice('About to invoke displayTest') testApplication = displayTest(myLogger) except Exception, e: if isinstance(e, tse.TsExceptions): msg = str(e) tse.displayError(e) exitStatus = e.exitCode else: msg = None sys.stderr.write(traceback.format_exc()) exitStatus = tse.INVALID_ERROR_CODE