Package theia :: Module main
[hide private]
[frames] | no frames]

Source Code for Module theia.main

 1  '''Main module of theia, defines the main function.''' 
 2   
 3  # Provides: 
 4  #   main 
 5   
 6  import os 
 7  import sys 
 8  from .helpers import settings 
 9  from .helpers.interaction import welcomeString, recursionErrorString 
10  from .helpers.tools import InputError 
11  from .running import simulation 
12   
13 -def main(options, args):
14 '''Main function of theia.''' 15 16 # global variables dic 17 dic = {} 18 dic['info'] = options.info 19 dic['warning'] = options.warning 20 dic['text'] = options.text 21 dic['cad'] = options.cad 22 dic['fname'] = os.path.splitext(args[1])[0] #basename 23 24 # initiate globals 25 settings.init(dic) 26 27 #exit with error if file not found 28 if not os.path.isfile(settings.fname + '.tia'): 29 print "theia: Error: "+ settings.fname + '.tia: No such file.\nAborting.' 30 sys.exit(1) 31 32 #create simulation object 33 simu = simulation.Simulation(settings.fname) 34 35 #welcome to theia 36 print welcomeString 37 38 #load initial data 39 print "theia: Run: Reading input data." 40 try: 41 simu.load() 42 except InputError as IE: 43 print "theia: Error: " + IE.Message + "\nAborting." 44 sys.exit(1) 45 46 print "theia: Run: Done." 47 48 #run simulation 49 print "theia: Run: Running simulation." 50 try: 51 simu.run() 52 except RuntimeError: 53 print "theia: Error: Maximum recursion depth reached. Aborting."\ 54 + recursionErrorString 55 sys.exit(1) 56 print "theia: Run: Done." 57 58 #write results to .out file 59 if settings.text: 60 print "theia: Run: Writing output file." 61 simu.writeOut() 62 print "theia: Run: Done." 63 64 #write CAD file 65 if settings.cad: 66 print "theia: Run: Writing CAD file." 67 simu.writeCAD() 68 print "theia: Run: Done." 69 70 sys.exit(0)
71